@@ -25,6 +25,10 @@ |
||
| 25 | 25 | public function get_historic() { |
| 26 | 26 | return array_reverse( get_option( $this->name_option ) ); |
| 27 | 27 | } |
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * @param integer $id |
|
| 31 | + */ |
|
| 28 | 32 | public function row_model( $id, $date, $amount, $payments ) { |
| 29 | 33 | return array( 'id' => $id, 'date' => $date, 'amount' => $amount, 'payments' => $payments ); |
| 30 | 34 | } |
@@ -1,4 +1,6 @@ |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
| 2 | + exit; |
|
| 3 | +} |
|
| 2 | 4 | class wps_pos_addon_bank_deposit_histo { |
| 3 | 5 | public $name_option = 'bank_deposit_historic'; |
| 4 | 6 | public function __construct() { |
@@ -1,47 +1,47 @@ |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) exit; |
|
| 2 | 2 | class wps_pos_addon_bank_deposit_histo { |
| 3 | 3 | public $name_option = 'bank_deposit_historic'; |
| 4 | 4 | public function __construct() { |
| 5 | 5 | /** Call metaboxes */ |
| 6 | - add_action( 'admin_init', array( $this, 'metaboxes' ) ); |
|
| 7 | - add_action( 'admin_enqueue_scripts', array( $this, 'vars_js' ), 11 ); |
|
| 8 | - add_option( $this->name_option, array(), '', 'yes' ); |
|
| 6 | + add_action('admin_init', array($this, 'metaboxes')); |
|
| 7 | + add_action('admin_enqueue_scripts', array($this, 'vars_js'), 11); |
|
| 8 | + add_option($this->name_option, array(), '', 'yes'); |
|
| 9 | 9 | } |
| 10 | 10 | public function metaboxes() { |
| 11 | - add_meta_box( 'wpspos-bank-deposit-histo-metabox', __( 'Historic bank deposit', 'wps-pos-i18n' ), array( $this, 'metabox' ), 'wpspos-bank-deposit', 'wpspos-bank-deposit-right' ); |
|
| 11 | + add_meta_box('wpspos-bank-deposit-histo-metabox', __('Historic bank deposit', 'wps-pos-i18n'), array($this, 'metabox'), 'wpspos-bank-deposit', 'wpspos-bank-deposit-right'); |
|
| 12 | 12 | } |
| 13 | 13 | public function metabox() { |
| 14 | - require( wpshop_tools::get_template_part( WPSPOS_DIR, WPSPOS_TEMPLATES_MAIN_DIR, 'backend/bank_deposit', 'metabox', 'bank_deposit_histo' ) ); |
|
| 14 | + require(wpshop_tools::get_template_part(WPSPOS_DIR, WPSPOS_TEMPLATES_MAIN_DIR, 'backend/bank_deposit', 'metabox', 'bank_deposit_histo')); |
|
| 15 | 15 | } |
| 16 | - public function add_historic( $new_value ) { |
|
| 17 | - $histo = get_option( $this->name_option ); |
|
| 16 | + public function add_historic($new_value) { |
|
| 17 | + $histo = get_option($this->name_option); |
|
| 18 | 18 | $histo[] = ''; |
| 19 | - end( $histo ); |
|
| 20 | - $id = key( $histo ); |
|
| 19 | + end($histo); |
|
| 20 | + $id = key($histo); |
|
| 21 | 21 | $new_value['id'] = $id; |
| 22 | 22 | $histo[$id] = $new_value; |
| 23 | - update_option( $this->name_option, $histo ); |
|
| 23 | + update_option($this->name_option, $histo); |
|
| 24 | 24 | } |
| 25 | 25 | public function get_historic() { |
| 26 | - return array_reverse( get_option( $this->name_option ) ); |
|
| 26 | + return array_reverse(get_option($this->name_option)); |
|
| 27 | 27 | } |
| 28 | - public function row_model( $id, $date, $amount, $payments ) { |
|
| 29 | - return array( 'id' => $id, 'date' => $date, 'amount' => $amount, 'payments' => $payments ); |
|
| 28 | + public function row_model($id, $date, $amount, $payments) { |
|
| 29 | + return array('id' => $id, 'date' => $date, 'amount' => $amount, 'payments' => $payments); |
|
| 30 | 30 | } |
| 31 | 31 | public function vars_js() { |
| 32 | - wp_localize_script( 'wpspos-backend-bank-deposit-js', 'historics', $this->get_historic() ); |
|
| 33 | - wp_localize_script( 'wpspos-backend-bank-deposit-js', 'templates_url', admin_url( 'admin-post.php' ) ); |
|
| 32 | + wp_localize_script('wpspos-backend-bank-deposit-js', 'historics', $this->get_historic()); |
|
| 33 | + wp_localize_script('wpspos-backend-bank-deposit-js', 'templates_url', admin_url('admin-post.php')); |
|
| 34 | 34 | } |
| 35 | 35 | public function save_historic_ajax() { |
| 36 | - $list_payments = !empty( $_POST['payments'] ) ? (array) $_POST['payments'] : array(); |
|
| 36 | + $list_payments = !empty($_POST['payments']) ? (array)$_POST['payments'] : array(); |
|
| 37 | 37 | $payments = array(); |
| 38 | - foreach( $list_payments as $payment ) { |
|
| 39 | - if( is_float( $payment ) ) { |
|
| 40 | - $payments[] = (float) $payment; |
|
| 38 | + foreach ($list_payments as $payment) { |
|
| 39 | + if (is_float($payment)) { |
|
| 40 | + $payments[] = (float)$payment; |
|
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | - $this->add_historic( $this->row_model( 0, sanitize_text_field( $_POST['date'] ), sanitize_text_field( $_POST['amount'] ), $payments ) ); |
|
| 44 | - echo json_encode( $this->get_historic() ); |
|
| 43 | + $this->add_historic($this->row_model(0, sanitize_text_field($_POST['date']), sanitize_text_field($_POST['amount']), $payments)); |
|
| 44 | + echo json_encode($this->get_historic()); |
|
| 45 | 45 | wp_die(); |
| 46 | 46 | } |
| 47 | 47 | } |
@@ -105,7 +105,7 @@ |
||
| 105 | 105 | |
| 106 | 106 | /** |
| 107 | 107 | * Generate barcode image |
| 108 | - * @param object $barcode Instance of wps_barcodegen |
|
| 108 | + * @param wps_barcodegen $barcode Instance of wps_barcodegen |
|
| 109 | 109 | * @param string $meta Numerical code of barcode |
| 110 | 110 | * @param string $type Texte for complete message |
| 111 | 111 | * @param string $price Price of product |
@@ -1,4 +1,6 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
| 2 | + exit; |
|
| 3 | +} |
|
| 2 | 4 | |
| 3 | 5 | class wps_barcode_ajax { |
| 4 | 6 | public function __construct() { |
@@ -10,8 +12,9 @@ discard block |
||
| 10 | 12 | public function imgProduct() { |
| 11 | 13 | $_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : ''; |
| 12 | 14 | |
| 13 | - if ( !wp_verify_nonce( $_wpnonce, 'imgProduct' ) ) |
|
| 14 | - wp_die(); |
|
| 15 | + if ( !wp_verify_nonce( $_wpnonce, 'imgProduct' ) ) { |
|
| 16 | + wp_die(); |
|
| 17 | + } |
|
| 15 | 18 | |
| 16 | 19 | global $meta, $barcode, $post_ID, $wpdb, $table_prefix, $gg; |
| 17 | 20 | require_once('wps_barcodegen.ctr.php'); |
@@ -50,8 +53,9 @@ discard block |
||
| 50 | 53 | public function imgCoupons() { |
| 51 | 54 | $_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : ''; |
| 52 | 55 | |
| 53 | - if ( !wp_verify_nonce( $_wpnonce, 'imgProduct' ) ) |
|
| 54 | - wp_die(); |
|
| 56 | + if ( !wp_verify_nonce( $_wpnonce, 'imgProduct' ) ) { |
|
| 57 | + wp_die(); |
|
| 58 | + } |
|
| 55 | 59 | |
| 56 | 60 | global $meta, $barcode, $post_ID, $wpdb, $table_prefix; |
| 57 | 61 | |
@@ -90,8 +94,7 @@ discard block |
||
| 90 | 94 | $code = $type.$date.$id; |
| 91 | 95 | $meta = $barcode->checksum($code); |
| 92 | 96 | add_post_meta($post_ID, 'wpshop_coupon_barcode', $meta); |
| 93 | - } |
|
| 94 | - else { |
|
| 97 | + } else { |
|
| 95 | 98 | $meta = $result['wpshop_coupon_barcode'][0]; |
| 96 | 99 | } |
| 97 | 100 | |
@@ -105,8 +108,7 @@ discard block |
||
| 105 | 108 | $array = array('img' => $barcode); |
| 106 | 109 | echo json_encode($array); |
| 107 | 110 | wp_die(); |
| 108 | - } |
|
| 109 | - else { |
|
| 111 | + } else { |
|
| 110 | 112 | echo '<p>'.__('None bardcode generated as coupon has not created.', |
| 111 | 113 | 'wps_barcode').'</p>'; |
| 112 | 114 | wp_die(); |
@@ -158,8 +160,7 @@ discard block |
||
| 158 | 160 | for ($i=0; $i<42 ; $i++) { |
| 159 | 161 | if( substr($binCode, $i, 1) === '0' ) { |
| 160 | 162 | $color = imagecolorallocate($im, 255, 255, 255); |
| 161 | - } |
|
| 162 | - else { |
|
| 163 | + } else { |
|
| 163 | 164 | $color = imagecolorallocate($im, 0, 0, 0); |
| 164 | 165 | } |
| 165 | 166 | |
@@ -187,8 +188,7 @@ discard block |
||
| 187 | 188 | for ($i=42; $i<84 ; $i++) { |
| 188 | 189 | if( substr($binCode, $i, 1) === '0' ) { |
| 189 | 190 | $color = imagecolorallocate($im, 255, 255, 255); |
| 190 | - } |
|
| 191 | - else { |
|
| 191 | + } else { |
|
| 192 | 192 | $color = imagecolorallocate($im, 0, 0, 0); |
| 193 | 193 | } |
| 194 | 194 | |
@@ -241,12 +241,10 @@ discard block |
||
| 241 | 241 | $coupon_postmeta = get_post_meta($post_ID, 'wpshop_coupon_discount_type'); |
| 242 | 242 | if ( $coupon_postmeta[0] === 'percent' ) { |
| 243 | 243 | $price = $price.' %'; |
| 244 | - } |
|
| 245 | - else { |
|
| 244 | + } else { |
|
| 246 | 245 | $price = sprintf( number_format( $price, 2 ). ' '.$currency); |
| 247 | 246 | } |
| 248 | - } |
|
| 249 | - else { |
|
| 247 | + } else { |
|
| 250 | 248 | $price = sprintf( number_format( $price, 2 ). ' '.$currency); |
| 251 | 249 | } |
| 252 | 250 | |
@@ -282,8 +280,7 @@ discard block |
||
| 282 | 280 | } catch (Exception $e) { |
| 283 | 281 | echo __('Generation problem', 'wps_barcode'); |
| 284 | 282 | }*/ |
| 285 | - } |
|
| 286 | - else { |
|
| 283 | + } else { |
|
| 287 | 284 | return '<p>'.sprintf( __('None bardcode generated as you did create %s.', |
| 288 | 285 | 'wps_barcode'), $type).'</p>'; |
| 289 | 286 | } |
@@ -1,15 +1,15 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) exit; |
|
| 2 | 2 | |
| 3 | 3 | class wps_barcode_ajax { |
| 4 | 4 | public function __construct() { |
| 5 | - add_action( 'wp_ajax_barcode_img_product', array($this, 'imgProduct') ); |
|
| 6 | - add_action( 'wp_ajax_barcode_img_coupons', array($this, 'imgCoupons') ); |
|
| 5 | + add_action('wp_ajax_barcode_img_product', array($this, 'imgProduct')); |
|
| 6 | + add_action('wp_ajax_barcode_img_coupons', array($this, 'imgCoupons')); |
|
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | public function imgProduct() { |
| 10 | - $_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : ''; |
|
| 10 | + $_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : ''; |
|
| 11 | 11 | |
| 12 | - if ( !wp_verify_nonce( $_wpnonce, 'imgProduct' ) ) |
|
| 12 | + if (!wp_verify_nonce($_wpnonce, 'imgProduct')) |
|
| 13 | 13 | wp_die(); |
| 14 | 14 | |
| 15 | 15 | global $meta, $barcode, $post_ID, $wpdb, $table_prefix, $gg; |
@@ -23,17 +23,17 @@ discard block |
||
| 23 | 23 | |
| 24 | 24 | /*Select value of barcode*/ |
| 25 | 25 | $result = $wpdb->get_results( |
| 26 | - 'SELECT value FROM '.WPSHOP_DBT_ATTRIBUTE_VALUES_VARCHAR. |
|
| 27 | - ' WHERE attribute_id=(SELECT id FROM '.WPSHOP_DBT_ATTRIBUTE. |
|
| 28 | - ' WHERE code = "barcode") AND entity_id="'.$post_ID.'"', ARRAY_A); |
|
| 26 | + 'SELECT value FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_VARCHAR . |
|
| 27 | + ' WHERE attribute_id=(SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE . |
|
| 28 | + ' WHERE code = "barcode") AND entity_id="' . $post_ID . '"', ARRAY_A); |
|
| 29 | 29 | $meta = !empty($result) ? $result[0]['value'] : ''; |
| 30 | 30 | |
| 31 | 31 | /*Get price of product*/ |
| 32 | - $result = $wpdb->get_results('SELECT value FROM '.WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL. |
|
| 33 | - ' WHERE attribute_id=(SELECT id FROM '.WPSHOP_DBT_ATTRIBUTE. |
|
| 34 | - ' WHERE code="'.WPSHOP_PRODUCT_PRICE_TTC.'") AND entity_id='.$post_ID, ARRAY_A); |
|
| 32 | + $result = $wpdb->get_results('SELECT value FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL . |
|
| 33 | + ' WHERE attribute_id=(SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE . |
|
| 34 | + ' WHERE code="' . WPSHOP_PRODUCT_PRICE_TTC . '") AND entity_id=' . $post_ID, ARRAY_A); |
|
| 35 | 35 | |
| 36 | - if ( !empty($result) && $result[0]['value'] >= 0) { |
|
| 36 | + if (!empty($result) && $result[0]['value'] >= 0) { |
|
| 37 | 37 | $price = $result[0]['value']; |
| 38 | 38 | |
| 39 | 39 | $post = get_post($post_ID, ARRAY_A); |
@@ -47,9 +47,9 @@ discard block |
||
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | public function imgCoupons() { |
| 50 | - $_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : ''; |
|
| 50 | + $_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : ''; |
|
| 51 | 51 | |
| 52 | - if ( !wp_verify_nonce( $_wpnonce, 'imgProduct' ) ) |
|
| 52 | + if (!wp_verify_nonce($_wpnonce, 'imgProduct')) |
|
| 53 | 53 | wp_die(); |
| 54 | 54 | |
| 55 | 55 | global $meta, $barcode, $post_ID, $wpdb, $table_prefix; |
@@ -65,14 +65,14 @@ discard block |
||
| 65 | 65 | $country = '000'; |
| 66 | 66 | $result = get_post_meta($post_ID); |
| 67 | 67 | |
| 68 | - if ( !empty($result) ) { |
|
| 69 | - if ( empty($result['wpshop_coupon_barcode']) ) { |
|
| 68 | + if (!empty($result)) { |
|
| 69 | + if (empty($result['wpshop_coupon_barcode'])) { |
|
| 70 | 70 | $conf = get_option('wps_barcode'); |
| 71 | 71 | if ($conf['type'] === 'internal') { |
| 72 | 72 | $type = $conf['internal_coupons']; |
| 73 | 73 | |
| 74 | - $query = $wpdb->get_results('SELECT post_date FROM '. |
|
| 75 | - $table_prefix.'posts WHERE ID='.$post_ID, ARRAY_A); |
|
| 74 | + $query = $wpdb->get_results('SELECT post_date FROM ' . |
|
| 75 | + $table_prefix . 'posts WHERE ID=' . $post_ID, ARRAY_A); |
|
| 76 | 76 | |
| 77 | 77 | $pDate = new DateTime($query[0]['post_date']); |
| 78 | 78 | $date = $pDate->format('my'); |
@@ -80,13 +80,13 @@ discard block |
||
| 80 | 80 | |
| 81 | 81 | $len = strlen($post_ID); |
| 82 | 82 | $ref = ''; |
| 83 | - if ( $len < 5 ) { |
|
| 84 | - for ($i=0; $i <= $len; $i++) { |
|
| 83 | + if ($len < 5) { |
|
| 84 | + for ($i = 0; $i <= $len; $i++) { |
|
| 85 | 85 | $ref .= '0'; |
| 86 | 86 | } |
| 87 | 87 | } |
| 88 | - $id = $ref.$post_ID; |
|
| 89 | - $code = $type.$date.$id; |
|
| 88 | + $id = $ref . $post_ID; |
|
| 89 | + $code = $type . $date . $id; |
|
| 90 | 90 | $meta = $barcode->checksum($code); |
| 91 | 91 | add_post_meta($post_ID, 'wpshop_coupon_barcode', $meta); |
| 92 | 92 | } |
@@ -94,8 +94,8 @@ discard block |
||
| 94 | 94 | $meta = $result['wpshop_coupon_barcode'][0]; |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - $query = $wpdb->get_results('SELECT post_title FROM '. |
|
| 98 | - $table_prefix.'posts WHERE ID='.$post_ID, ARRAY_A); |
|
| 97 | + $query = $wpdb->get_results('SELECT post_title FROM ' . |
|
| 98 | + $table_prefix . 'posts WHERE ID=' . $post_ID, ARRAY_A); |
|
| 99 | 99 | |
| 100 | 100 | $post = get_post($post_ID, ARRAY_A); |
| 101 | 101 | |
@@ -106,8 +106,8 @@ discard block |
||
| 106 | 106 | wp_die(); |
| 107 | 107 | } |
| 108 | 108 | else { |
| 109 | - echo '<p>'.__('None bardcode generated as coupon has not created.', |
|
| 110 | - 'wps_barcode').'</p>'; |
|
| 109 | + echo '<p>' . __('None bardcode generated as coupon has not created.', |
|
| 110 | + 'wps_barcode') . '</p>'; |
|
| 111 | 111 | wp_die(); |
| 112 | 112 | } |
| 113 | 113 | } |
@@ -121,44 +121,44 @@ discard block |
||
| 121 | 121 | * @param string $title Title of product |
| 122 | 122 | */ |
| 123 | 123 | public function generate_image(&$barcode, $meta, $type, $price, $title, $post_ID = 0) { |
| 124 | - if ( !extension_loaded('gd') ) { |
|
| 125 | - return '<p>'.__('Library GD is requiered.', 'wps_barcode').'</p>'; |
|
| 124 | + if (!extension_loaded('gd')) { |
|
| 125 | + return '<p>' . __('Library GD is requiered.', 'wps_barcode') . '</p>'; |
|
| 126 | 126 | } |
| 127 | - if ( !empty($meta) ) { |
|
| 127 | + if (!empty($meta)) { |
|
| 128 | 128 | $barcode->setGenerateCode($meta); |
| 129 | 129 | $binCode = $barcode->getBinCode(); |
| 130 | 130 | |
| 131 | 131 | $px = 3.779528; |
| 132 | - $x = round(66*$px); //249.449 px |
|
| 133 | - $y = round(50*$px); //188.976 px |
|
| 134 | - $bar_size = round(63.393/72); //0.880 px |
|
| 132 | + $x = round(66 * $px); //249.449 px |
|
| 133 | + $y = round(50 * $px); //188.976 px |
|
| 134 | + $bar_size = round(63.393 / 72); //0.880 px |
|
| 135 | 135 | |
| 136 | 136 | $len = 0; |
| 137 | 137 | $test = ''; |
| 138 | 138 | |
| 139 | - while ($len !== strlen($binCode) ) { |
|
| 140 | - $test .= substr($binCode, $len, 7).' '; |
|
| 141 | - $len = $len+7; |
|
| 139 | + while ($len !== strlen($binCode)) { |
|
| 140 | + $test .= substr($binCode, $len, 7) . ' '; |
|
| 141 | + $len = $len + 7; |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | $im = imagecreate($x, $y); |
| 145 | 145 | $background_color = imagecolorallocate($im, 255, 255, 255); |
| 146 | - $start = round(5.79*$px); //21.883 |
|
| 146 | + $start = round(5.79 * $px); //21.883 |
|
| 147 | 147 | |
| 148 | 148 | /*Write First left guard*/ |
| 149 | - $this->imgNormalGuard($im, $start, $start+$bar_size, |
|
| 149 | + $this->imgNormalGuard($im, $start, $start + $bar_size, |
|
| 150 | 150 | imagecolorallocate($im, 0, 0, 0)); |
| 151 | - $this->imgNormalGuard($im, $start+($bar_size*2), |
|
| 152 | - $start+($bar_size*3), imagecolorallocate($im, 255, 255, 255)); |
|
| 153 | - $this->imgNormalGuard($im, $start+($bar_size*4), |
|
| 154 | - $start+($bar_size*5), imagecolorallocate($im, 0, 0, 0)); |
|
| 151 | + $this->imgNormalGuard($im, $start + ($bar_size * 2), |
|
| 152 | + $start + ($bar_size * 3), imagecolorallocate($im, 255, 255, 255)); |
|
| 153 | + $this->imgNormalGuard($im, $start + ($bar_size * 4), |
|
| 154 | + $start + ($bar_size * 5), imagecolorallocate($im, 0, 0, 0)); |
|
| 155 | 155 | |
| 156 | - $pos = $start+($bar_size*7); |
|
| 157 | - $newPos = $pos+$bar_size; |
|
| 156 | + $pos = $start + ($bar_size * 7); |
|
| 157 | + $newPos = $pos + $bar_size; |
|
| 158 | 158 | |
| 159 | 159 | /*Write left barcode*/ |
| 160 | - for ($i=0; $i<42 ; $i++) { |
|
| 161 | - if( substr($binCode, $i, 1) === '0' ) { |
|
| 160 | + for ($i = 0; $i < 42; $i++) { |
|
| 161 | + if (substr($binCode, $i, 1) === '0') { |
|
| 162 | 162 | $color = imagecolorallocate($im, 255, 255, 255); |
| 163 | 163 | } |
| 164 | 164 | else { |
@@ -166,108 +166,108 @@ discard block |
||
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | $this->imgSymbole($im, $pos, $newPos, $color); |
| 169 | - $newPos = $pos+$bar_size; |
|
| 170 | - $pos = $newPos+$bar_size; |
|
| 169 | + $newPos = $pos + $bar_size; |
|
| 170 | + $pos = $newPos + $bar_size; |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | /*Writer center guard*/ |
| 174 | 174 | $pos = $newPos; |
| 175 | - $this->imgNormalGuard($im, $pos, $newPos+$bar_size, |
|
| 175 | + $this->imgNormalGuard($im, $pos, $newPos + $bar_size, |
|
| 176 | 176 | imagecolorallocate($im, 255, 255, 255)); |
| 177 | - $this->imgNormalGuard($im, $pos+($bar_size*2), |
|
| 178 | - $newPos+($bar_size*3), imagecolorallocate($im, 0, 0, 0)); |
|
| 179 | - $this->imgNormalGuard($im, $pos+($bar_size*4), |
|
| 180 | - $newPos+($bar_size*5), imagecolorallocate($im, 255, 255, 255)); |
|
| 181 | - $this->imgNormalGuard($im, $pos+($bar_size*6), |
|
| 182 | - $newPos+($bar_size*7), imagecolorallocate($im, 0, 0, 0)); |
|
| 183 | - $this->imgNormalGuard($im, $pos+($bar_size*8), |
|
| 184 | - $newPos+($bar_size*9), imagecolorallocate($im, 255, 255, 255)); |
|
| 177 | + $this->imgNormalGuard($im, $pos + ($bar_size * 2), |
|
| 178 | + $newPos + ($bar_size * 3), imagecolorallocate($im, 0, 0, 0)); |
|
| 179 | + $this->imgNormalGuard($im, $pos + ($bar_size * 4), |
|
| 180 | + $newPos + ($bar_size * 5), imagecolorallocate($im, 255, 255, 255)); |
|
| 181 | + $this->imgNormalGuard($im, $pos + ($bar_size * 6), |
|
| 182 | + $newPos + ($bar_size * 7), imagecolorallocate($im, 0, 0, 0)); |
|
| 183 | + $this->imgNormalGuard($im, $pos + ($bar_size * 8), |
|
| 184 | + $newPos + ($bar_size * 9), imagecolorallocate($im, 255, 255, 255)); |
|
| 185 | 185 | |
| 186 | - $pos = $newPos+($bar_size*10); |
|
| 186 | + $pos = $newPos + ($bar_size * 10); |
|
| 187 | 187 | |
| 188 | 188 | /*Write right barcode*/ |
| 189 | - for ($i=42; $i<84 ; $i++) { |
|
| 190 | - if( substr($binCode, $i, 1) === '0' ) { |
|
| 189 | + for ($i = 42; $i < 84; $i++) { |
|
| 190 | + if (substr($binCode, $i, 1) === '0') { |
|
| 191 | 191 | $color = imagecolorallocate($im, 255, 255, 255); |
| 192 | 192 | } |
| 193 | 193 | else { |
| 194 | 194 | $color = imagecolorallocate($im, 0, 0, 0); |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | - $newPos = $pos+$bar_size; |
|
| 197 | + $newPos = $pos + $bar_size; |
|
| 198 | 198 | |
| 199 | 199 | $this->imgSymbole($im, $pos, $newPos, $color); |
| 200 | - $pos = $newPos+$bar_size; |
|
| 200 | + $pos = $newPos + $bar_size; |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | /*Write right guard*/ |
| 204 | - $pos = $newPos+$bar_size; |
|
| 205 | - $this->imgNormalGuard($im, $pos, $pos+$bar_size, |
|
| 204 | + $pos = $newPos + $bar_size; |
|
| 205 | + $this->imgNormalGuard($im, $pos, $pos + $bar_size, |
|
| 206 | 206 | imagecolorallocate($im, 0, 0, 0)); |
| 207 | - $this->imgNormalGuard($im, $pos+($bar_size*2), |
|
| 208 | - $pos+($bar_size*3), imagecolorallocate($im, 255, 255, 255)); |
|
| 209 | - $this->imgNormalGuard($im, $pos+($bar_size*4), |
|
| 210 | - $pos+($bar_size*5), imagecolorallocate($im, 0, 0, 0)); |
|
| 207 | + $this->imgNormalGuard($im, $pos + ($bar_size * 2), |
|
| 208 | + $pos + ($bar_size * 3), imagecolorallocate($im, 255, 255, 255)); |
|
| 209 | + $this->imgNormalGuard($im, $pos + ($bar_size * 4), |
|
| 210 | + $pos + ($bar_size * 5), imagecolorallocate($im, 0, 0, 0)); |
|
| 211 | 211 | |
| 212 | 212 | $textSize = 16; |
| 213 | - $font = WPS_BARCODE_FONTS.'/arialbd.ttf'; |
|
| 214 | - imagettftext($im, $textSize, 0, 8, $y-$start-5, |
|
| 213 | + $font = WPS_BARCODE_FONTS . '/arialbd.ttf'; |
|
| 214 | + imagettftext($im, $textSize, 0, 8, $y - $start - 5, |
|
| 215 | 215 | imagecolorallocate($im, 0, 0, 0), $font, substr($meta, 0, 1)); |
| 216 | 216 | |
| 217 | 217 | $continue = true; |
| 218 | 218 | $i = 28; $j = 0; |
| 219 | 219 | |
| 220 | 220 | /*Write left number code*/ |
| 221 | - while ($j<5) { |
|
| 222 | - $j=$j+1; |
|
| 223 | - imagettftext($im, $textSize, 0, $i, $y-$start-5, |
|
| 221 | + while ($j < 5) { |
|
| 222 | + $j = $j + 1; |
|
| 223 | + imagettftext($im, $textSize, 0, $i, $y - $start - 5, |
|
| 224 | 224 | imagecolorallocate($im, 0, 0, 0), $font, substr($meta, $j, 1)); |
| 225 | - $i = $i+14; |
|
| 225 | + $i = $i + 14; |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | /*Write right number code*/ |
| 229 | - while ($j<11) { |
|
| 230 | - $j=$j+1; |
|
| 231 | - imagettftext($im, $textSize, 0, $i+6, $y-$start-5, |
|
| 229 | + while ($j < 11) { |
|
| 230 | + $j = $j + 1; |
|
| 231 | + imagettftext($im, $textSize, 0, $i + 6, $y - $start - 5, |
|
| 232 | 232 | imagecolorallocate($im, 0, 0, 0), $font, substr($meta, $j, 1)); |
| 233 | - $i = $i+15; |
|
| 233 | + $i = $i + 15; |
|
| 234 | 234 | } |
| 235 | - imagettftext($im, $textSize, 0, $i+4, $y-$start-5, |
|
| 236 | - imagecolorallocate($im, 0, 0, 0), $font, substr($meta, $j+1, 1)); |
|
| 235 | + imagettftext($im, $textSize, 0, $i + 4, $y - $start - 5, |
|
| 236 | + imagecolorallocate($im, 0, 0, 0), $font, substr($meta, $j + 1, 1)); |
|
| 237 | 237 | |
| 238 | 238 | /*Write ref product and price*/ |
| 239 | 239 | $textSize = 12; |
| 240 | 240 | $currency = (wpshop_tools::wpshop_get_currency() === '€') ? "€" : wpshop_tools::wpshop_get_currency(); |
| 241 | 241 | |
| 242 | - if ( $type === __('coupon', 'wps_barcode') ) { |
|
| 242 | + if ($type === __('coupon', 'wps_barcode')) { |
|
| 243 | 243 | $coupon_postmeta = get_post_meta($post_ID, 'wpshop_coupon_discount_type'); |
| 244 | - if ( $coupon_postmeta[0] === 'percent' ) { |
|
| 245 | - $price = $price.' %'; |
|
| 244 | + if ($coupon_postmeta[0] === 'percent') { |
|
| 245 | + $price = $price . ' %'; |
|
| 246 | 246 | } |
| 247 | 247 | else { |
| 248 | - $price = sprintf( number_format( $price, 2 ). ' '.$currency); |
|
| 248 | + $price = sprintf(number_format($price, 2) . ' ' . $currency); |
|
| 249 | 249 | } |
| 250 | 250 | } |
| 251 | 251 | else { |
| 252 | - $price = sprintf( number_format( $price, 2 ). ' '.$currency); |
|
| 252 | + $price = sprintf(number_format($price, 2) . ' ' . $currency); |
|
| 253 | 253 | } |
| 254 | 254 | |
| 255 | - imagettftext($im, $textSize, 0, 20, round(6*$px), |
|
| 255 | + imagettftext($im, $textSize, 0, 20, round(6 * $px), |
|
| 256 | 256 | imagecolorallocate($im, 0, 0, 0), $font, $title); |
| 257 | - imagettftext($im, $textSize, 0, ($x/2)+40, round(6*$px), |
|
| 257 | + imagettftext($im, $textSize, 0, ($x / 2) + 40, round(6 * $px), |
|
| 258 | 258 | imagecolorallocate($im, 0, 0, 0), $font, $price); |
| 259 | 259 | |
| 260 | 260 | ob_start(); |
| 261 | 261 | imagepng($im); |
| 262 | 262 | $img = ob_get_clean(); |
| 263 | 263 | |
| 264 | - return '<p><img src="data:image/png;base64,'.base64_encode($img). |
|
| 265 | - '" id="barcode" width="160" height="90" /></p>'. |
|
| 264 | + return '<p><img src="data:image/png;base64,' . base64_encode($img) . |
|
| 265 | + '" id="barcode" width="160" height="90" /></p>' . |
|
| 266 | 266 | |
| 267 | - '<p style="text-align: right"><button class="button '. |
|
| 268 | - 'button-primary button-large" type="button"'. |
|
| 269 | - 'id="print_barcode">'. |
|
| 270 | - __('Print', 'wps_barcode').'</button></p>'; |
|
| 267 | + '<p style="text-align: right"><button class="button ' . |
|
| 268 | + 'button-primary button-large" type="button"' . |
|
| 269 | + 'id="print_barcode">' . |
|
| 270 | + __('Print', 'wps_barcode') . '</button></p>'; |
|
| 271 | 271 | |
| 272 | 272 | /*wp_mkdir_p( WPS_BARCODE_UPLOAD ); |
| 273 | 273 | |
@@ -286,8 +286,8 @@ discard block |
||
| 286 | 286 | }*/ |
| 287 | 287 | } |
| 288 | 288 | else { |
| 289 | - return '<p>'.sprintf( __('None bardcode generated as you did create %s.', |
|
| 290 | - 'wps_barcode'), $type).'</p>'; |
|
| 289 | + return '<p>' . sprintf(__('None bardcode generated as you did create %s.', |
|
| 290 | + 'wps_barcode'), $type) . '</p>'; |
|
| 291 | 291 | } |
| 292 | 292 | } |
| 293 | 293 | |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | * @param integer $color Color of rectangle |
| 300 | 300 | */ |
| 301 | 301 | private function imgNormalGuard(&$image, $pos, $size, $color) { |
| 302 | - imagefilledrectangle($image, $pos, 180*0.25,$size, 180-10, $color ); |
|
| 302 | + imagefilledrectangle($image, $pos, 180 * 0.25, $size, 180 - 10, $color); |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | /** |
@@ -310,6 +310,6 @@ discard block |
||
| 310 | 310 | * @param integer $color Color of rectangle |
| 311 | 311 | */ |
| 312 | 312 | private function imgSymbole(&$image, $pos, $size, $color) { |
| 313 | - imagefilledrectangle($image, $pos, 180*0.25,$size, 180-40, $color ); |
|
| 313 | + imagefilledrectangle($image, $pos, 180 * 0.25, $size, 180 - 40, $color); |
|
| 314 | 314 | } |
| 315 | 315 | } |
@@ -147,7 +147,7 @@ |
||
| 147 | 147 | |
| 148 | 148 | /** |
| 149 | 149 | * get binary code of barcode |
| 150 | - * @return binary code |
|
| 150 | + * @return string code |
|
| 151 | 151 | */ |
| 152 | 152 | public function getBinCode() { |
| 153 | 153 | return $this->binCode; |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | /** |
| 53 | 53 | * Write line of log |
| 54 | 54 | * @param string $string Line writing |
| 55 | - */ |
|
| 55 | + */ |
|
| 56 | 56 | public function writeLog($string) { |
| 57 | 57 | $this->log .= $string; |
| 58 | 58 | } |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | /** |
| 69 | 69 | * Set generate code for barcode has been generate |
| 70 | 70 | * @param string $code Number code of barcode |
| 71 | - */ |
|
| 71 | + */ |
|
| 72 | 72 | public function setGenerateCode($code) { |
| 73 | 73 | $code = $this->checksum( substr($code, 0, 12) ); |
| 74 | 74 | $this->originalCode = $code; |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | |
| 156 | 156 | /** |
| 157 | 157 | * Read INI configuration for country generate code |
| 158 | - */ |
|
| 158 | + */ |
|
| 159 | 159 | private function readGencodeIni() { |
| 160 | 160 | $ini = parse_ini_file('assets/config/gencode.ini', true); |
| 161 | 161 | |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | |
| 173 | 173 | /** |
| 174 | 174 | * Read INI general configuration |
| 175 | - */ |
|
| 175 | + */ |
|
| 176 | 176 | private function readConfigIni() { |
| 177 | 177 | $ini = parse_ini_file('assets/config/config.ini', true); |
| 178 | 178 | |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | * Cut and parse string for generate code |
| 191 | 191 | * @param string $ctry Country number code |
| 192 | 192 | * @return array String exploding with explode PHP function and parsing |
| 193 | - */ |
|
| 193 | + */ |
|
| 194 | 194 | private function explodingString($ctry) { |
| 195 | 195 | global $count, $gen, $leftRnd; |
| 196 | 196 | |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | * @param string $country International country code |
| 270 | 270 | * @param string $code Type for number code generate (country, distributors...) |
| 271 | 271 | * @return string Number code generate |
| 272 | - */ |
|
| 272 | + */ |
|
| 273 | 273 | private function ean13($country, $code, $ref) { |
| 274 | 274 | global $count, $gen, $leftRnd; |
| 275 | 275 | |
@@ -466,7 +466,7 @@ discard block |
||
| 466 | 466 | /** |
| 467 | 467 | * Generate bincode |
| 468 | 468 | * @param string $code Number code generated by normalization function |
| 469 | - */ |
|
| 469 | + */ |
|
| 470 | 470 | public function bin($code) { |
| 471 | 471 | if ($this->binCode === '') { |
| 472 | 472 | $binCode = ''; |
@@ -495,7 +495,7 @@ discard block |
||
| 495 | 495 | /** |
| 496 | 496 | * Calcul motif for generate barcode |
| 497 | 497 | * @param string $code Number code generate |
| 498 | - */ |
|
| 498 | + */ |
|
| 499 | 499 | private function motifCalc($code) { |
| 500 | 500 | $start = substr($code, 0, 1); |
| 501 | 501 | switch ($start) { |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) exit; |
|
| 2 | 2 | |
| 3 | 3 | /** |
| 4 | 4 | * Generate barcodes with informations |
@@ -30,17 +30,17 @@ discard block |
||
| 30 | 30 | private $config = array(); |
| 31 | 31 | |
| 32 | 32 | public function __construct() { |
| 33 | - $this->setA = array( 0 => '0001101', 1 => '0011001', 2 => '0010011', |
|
| 34 | - 3 => '0111101', 4 => '0100011', 5 => '0110001', 6 => '0101111', |
|
| 35 | - 7 => '0111011', 8 => '0110111', 9 => '0001011' ); |
|
| 33 | + $this->setA = array(0 => '0001101', 1 => '0011001', 2 => '0010011', |
|
| 34 | + 3 => '0111101', 4 => '0100011', 5 => '0110001', 6 => '0101111', |
|
| 35 | + 7 => '0111011', 8 => '0110111', 9 => '0001011'); |
|
| 36 | 36 | |
| 37 | - $this->setB = array( 0 => '0100111', 1 => '0110011', 2 => '0011011', |
|
| 37 | + $this->setB = array(0 => '0100111', 1 => '0110011', 2 => '0011011', |
|
| 38 | 38 | 3 => '0100001', 4 => '0011101', 5 => '0111001', 6 => '0000101', |
| 39 | - 7 => '0010001', 8 => '0001001', 9 => '0010111' ); |
|
| 39 | + 7 => '0010001', 8 => '0001001', 9 => '0010111'); |
|
| 40 | 40 | |
| 41 | - $this->setC = array( 0 => '1110010', 1 => '1100110', 2 => '1101100', |
|
| 41 | + $this->setC = array(0 => '1110010', 1 => '1100110', 2 => '1101100', |
|
| 42 | 42 | 3 => '1000010', 4 => '1011100', 5 => '1001110', 6 => '1010000', |
| 43 | - 7 => '1000100', 8 => '1001000', 9 => '1110100' ); |
|
| 43 | + 7 => '1000100', 8 => '1001000', 9 => '1110100'); |
|
| 44 | 44 | |
| 45 | 45 | //$this->file = fopen(/logs/ean13.log', 'a'); |
| 46 | 46 | } |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | * @param string $code Number code of barcode |
| 71 | 71 | */ |
| 72 | 72 | public function setGenerateCode($code) { |
| 73 | - $code = $this->checksum( substr($code, 0, 12) ); |
|
| 73 | + $code = $this->checksum(substr($code, 0, 12)); |
|
| 74 | 74 | $this->originalCode = $code; |
| 75 | 75 | $this->motifCalc($code); |
| 76 | 76 | $this->bin(substr($code, 1)); |
@@ -82,15 +82,15 @@ discard block |
||
| 82 | 82 | * @return string Number code with checksum |
| 83 | 83 | */ |
| 84 | 84 | public static function checksum($code) { |
| 85 | - $leftRnd = str_split( substr($code, 0, 7) ); |
|
| 86 | - $rightRnd = str_split( substr($code, 7) ); |
|
| 85 | + $leftRnd = str_split(substr($code, 0, 7)); |
|
| 86 | + $rightRnd = str_split(substr($code, 7)); |
|
| 87 | 87 | |
| 88 | 88 | /*Generate checksum*/ |
| 89 | - $leftSum = ($leftRnd[1]+$leftRnd[3]+$leftRnd[5]+$rightRnd[0]+$rightRnd[2]+$rightRnd[4])*3; |
|
| 90 | - $rightSum = $leftRnd[0]+$leftRnd[2]+$leftRnd[4]+$leftRnd[6]+$rightRnd[1]+$rightRnd[3]; |
|
| 91 | - $sum = $leftSum+$rightSum; |
|
| 89 | + $leftSum = ($leftRnd[1] + $leftRnd[3] + $leftRnd[5] + $rightRnd[0] + $rightRnd[2] + $rightRnd[4]) * 3; |
|
| 90 | + $rightSum = $leftRnd[0] + $leftRnd[2] + $leftRnd[4] + $leftRnd[6] + $rightRnd[1] + $rightRnd[3]; |
|
| 91 | + $sum = $leftSum + $rightSum; |
|
| 92 | 92 | |
| 93 | - $checksum = (ceil($sum/10)*10)-$sum; |
|
| 93 | + $checksum = (ceil($sum / 10) * 10) - $sum; |
|
| 94 | 94 | $rightRnd[5] = strval($checksum); |
| 95 | 95 | $gencode = implode($leftRnd); |
| 96 | 96 | $gencode .= implode($rightRnd); |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | public function setCountry($code) { |
| 115 | 115 | $this->country = $code; |
| 116 | 116 | |
| 117 | - if ( $this->fixed !== '' ) { |
|
| 117 | + if ($this->fixed !== '') { |
|
| 118 | 118 | $this->fixed .= ';country'; |
| 119 | 119 | } |
| 120 | 120 | else { |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | public function setEnterpriseCode($code) { |
| 130 | 130 | $this->enterprise = $code; |
| 131 | 131 | |
| 132 | - if ( $this->fixed !== '' ) { |
|
| 132 | + if ($this->fixed !== '') { |
|
| 133 | 133 | $this->fixed .= ';enterprise'; |
| 134 | 134 | } |
| 135 | 135 | else { |
@@ -159,13 +159,13 @@ discard block |
||
| 159 | 159 | private function readGencodeIni() { |
| 160 | 160 | $ini = parse_ini_file('assets/config/gencode.ini', true); |
| 161 | 161 | |
| 162 | - if ( array_key_exists("EAN13", $ini) ) { |
|
| 163 | - $pos = array_search( "EAN13", array_keys($ini) ); |
|
| 162 | + if (array_key_exists("EAN13", $ini)) { |
|
| 163 | + $pos = array_search("EAN13", array_keys($ini)); |
|
| 164 | 164 | $this->ean13 = array_slice($ini["EAN13"], 0); |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - if ( array_key_exists("OTHEREAN13", $ini) ) { |
|
| 168 | - $pos = array_search( "OTHEREAN13" , array_keys($ini) ); |
|
| 167 | + if (array_key_exists("OTHEREAN13", $ini)) { |
|
| 168 | + $pos = array_search("OTHEREAN13", array_keys($ini)); |
|
| 169 | 169 | $this->other_ean13 = array_slice($ini["OTHEREAN13"], 0); |
| 170 | 170 | } |
| 171 | 171 | } |
@@ -176,8 +176,8 @@ discard block |
||
| 176 | 176 | private function readConfigIni() { |
| 177 | 177 | $ini = parse_ini_file('assets/config/config.ini', true); |
| 178 | 178 | |
| 179 | - if ( array_key_exists("general", $ini) ) { |
|
| 180 | - $pos = array_search( "general", array_keys($ini) ); |
|
| 179 | + if (array_key_exists("general", $ini)) { |
|
| 180 | + $pos = array_search("general", array_keys($ini)); |
|
| 181 | 181 | |
| 182 | 182 | $this->enterprise = $ini["general"]["enteprise"]; |
| 183 | 183 | $this->country = $ini["general"]["country"]; |
@@ -199,12 +199,12 @@ discard block |
||
| 199 | 199 | |
| 200 | 200 | /*If minimum two informations*/ |
| 201 | 201 | if ($count > 1) { |
| 202 | - for ($i=0; $i<$count ; $i++) { |
|
| 202 | + for ($i = 0; $i < $count; $i++) { |
|
| 203 | 203 | $pos = strpos($exploding[$i], ":"); |
| 204 | 204 | $gen[$i]["start"] = substr($exploding[$i], 0, $pos); |
| 205 | 205 | |
| 206 | - if ( intval( substr($exploding[$i], $pos) ) < 1 ) { |
|
| 207 | - $gen[$i]["end"] = substr($exploding[$i], $pos+1); |
|
| 206 | + if (intval(substr($exploding[$i], $pos)) < 1) { |
|
| 207 | + $gen[$i]["end"] = substr($exploding[$i], $pos + 1); |
|
| 208 | 208 | } |
| 209 | 209 | else { |
| 210 | 210 | $gen[$i]["end"] = substr($exploding[$i], $pos); |
@@ -215,17 +215,17 @@ discard block |
||
| 215 | 215 | } |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | - $select = mt_rand( 0, count($gen)-1 ); |
|
| 218 | + $select = mt_rand(0, count($gen) - 1); |
|
| 219 | 219 | $g1 = strval($gen[$select]["start"]); |
| 220 | 220 | $g2 = strval($gen[$select]["end"]); |
| 221 | 221 | |
| 222 | - $rand = mt_rand( $g1, $g2 ); |
|
| 222 | + $rand = mt_rand($g1, $g2); |
|
| 223 | 223 | |
| 224 | - if ( $rand >= 10 and $rand < 100 ) { |
|
| 225 | - $strNum = '0'.intval($rand); |
|
| 224 | + if ($rand >= 10 and $rand < 100) { |
|
| 225 | + $strNum = '0' . intval($rand); |
|
| 226 | 226 | } |
| 227 | - else if ( $rand < 10 ) { |
|
| 228 | - $strNum = '00'.intval($rand); |
|
| 227 | + else if ($rand < 10) { |
|
| 228 | + $strNum = '00' . intval($rand); |
|
| 229 | 229 | } |
| 230 | 230 | else { |
| 231 | 231 | $strNum = intval($rand); |
@@ -235,21 +235,21 @@ discard block |
||
| 235 | 235 | $pos = strpos($exploding[0], ":"); |
| 236 | 236 | if ($pos > 0) { |
| 237 | 237 | $gen[0]["start"] = substr($exploding[0], 0, $pos); |
| 238 | - $gen[0]["end"] = substr($exploding[0], $pos+1); |
|
| 238 | + $gen[0]["end"] = substr($exploding[0], $pos + 1); |
|
| 239 | 239 | |
| 240 | - $select = mt_rand( intval($gen[0]["start"]), |
|
| 241 | - intval($gen[0]["end"]) ); |
|
| 240 | + $select = mt_rand(intval($gen[0]["start"]), |
|
| 241 | + intval($gen[0]["end"])); |
|
| 242 | 242 | |
| 243 | 243 | $strNum = strval($select); |
| 244 | 244 | $len = strlen($strNum); |
| 245 | - if ( $len < 3 ) { |
|
| 245 | + if ($len < 3) { |
|
| 246 | 246 | switch ($len) { |
| 247 | 247 | case 1: |
| 248 | - $strNum = '00'.$strNum; |
|
| 248 | + $strNum = '00' . $strNum; |
|
| 249 | 249 | break; |
| 250 | 250 | |
| 251 | 251 | case 2: |
| 252 | - $strNum = '0'.$strNum; |
|
| 252 | + $strNum = '0' . $strNum; |
|
| 253 | 253 | break; |
| 254 | 254 | } |
| 255 | 255 | } |
@@ -258,9 +258,9 @@ discard block |
||
| 258 | 258 | $strNum = strval($exploding[0]); |
| 259 | 259 | } |
| 260 | 260 | } |
| 261 | - $leftRnd[0] = substr( $strNum, 0, 1); |
|
| 262 | - $leftRnd[1] = substr( $strNum, 1, 1); |
|
| 263 | - $leftRnd[2] = substr( $strNum, 2, 1); |
|
| 261 | + $leftRnd[0] = substr($strNum, 0, 1); |
|
| 262 | + $leftRnd[1] = substr($strNum, 1, 1); |
|
| 263 | + $leftRnd[2] = substr($strNum, 2, 1); |
|
| 264 | 264 | return $gen; |
| 265 | 265 | } |
| 266 | 266 | |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | |
| 280 | 280 | $this->readGencodeIni(); |
| 281 | 281 | |
| 282 | - if ( $this->fixed === '' ) { |
|
| 282 | + if ($this->fixed === '') { |
|
| 283 | 283 | $this->readConfigIni(); |
| 284 | 284 | } |
| 285 | 285 | |
@@ -287,28 +287,28 @@ discard block |
||
| 287 | 287 | $explodingConf = explode(";", $this->fixed); |
| 288 | 288 | |
| 289 | 289 | foreach ($explodingConf as $key => $value) { |
| 290 | - if ( strtolower($value) === "country" ) { |
|
| 290 | + if (strtolower($value) === "country") { |
|
| 291 | 291 | $country = $this->country; |
| 292 | 292 | $code = "country"; |
| 293 | 293 | $countryViaConf = true; |
| 294 | 294 | } |
| 295 | - elseif ( strtolower($value) === "enterprise" ) { |
|
| 295 | + elseif (strtolower($value) === "enterprise") { |
|
| 296 | 296 | $enterpriseViaConf = true; |
| 297 | 297 | } |
| 298 | 298 | } |
| 299 | 299 | } |
| 300 | 300 | |
| 301 | - if ( $countryViaConf === true ) { |
|
| 302 | - if ( $this->countryCode !== '' ) |
|
| 301 | + if ($countryViaConf === true) { |
|
| 302 | + if ($this->countryCode !== '') |
|
| 303 | 303 | { |
| 304 | 304 | $strNum = strval($this->countryCode); |
| 305 | - $leftRnd[0] = substr( $strNum, 0, 1); |
|
| 306 | - $leftRnd[1] = substr( $strNum, 1, 1); |
|
| 307 | - $leftRnd[2] = substr( $strNum, 2, 1); |
|
| 305 | + $leftRnd[0] = substr($strNum, 0, 1); |
|
| 306 | + $leftRnd[1] = substr($strNum, 1, 1); |
|
| 307 | + $leftRnd[2] = substr($strNum, 2, 1); |
|
| 308 | 308 | } |
| 309 | 309 | else { |
| 310 | 310 | |
| 311 | - if ( array_key_exists(strtoupper($country), $this->ean13) ) { |
|
| 311 | + if (array_key_exists(strtoupper($country), $this->ean13)) { |
|
| 312 | 312 | $ctry = $this->ean13[strtoupper($country)]; |
| 313 | 313 | } |
| 314 | 314 | |
@@ -339,17 +339,17 @@ discard block |
||
| 339 | 339 | $this->countryGen($country, $code); |
| 340 | 340 | |
| 341 | 341 | /*Generate left section of gencode*/ |
| 342 | - if ( !isset($leftRnd[2]) ) { |
|
| 342 | + if (!isset($leftRnd[2])) { |
|
| 343 | 343 | $leftRnd[2] = mt_rand(0, 9); |
| 344 | 344 | } |
| 345 | 345 | } |
| 346 | 346 | |
| 347 | - if ( $enterpriseViaConf === true ) { |
|
| 347 | + if ($enterpriseViaConf === true) { |
|
| 348 | 348 | $strNum2 = strval($this->enterprise); |
| 349 | - $leftRnd[3] = substr( $strNum2, 0, 1); |
|
| 350 | - $leftRnd[4] = substr( $strNum2, 1, 1); |
|
| 351 | - $leftRnd[5] = substr( $strNum2, 2, 1); |
|
| 352 | - $leftRnd[6] = substr( $strNum2, 3, 1); |
|
| 349 | + $leftRnd[3] = substr($strNum2, 0, 1); |
|
| 350 | + $leftRnd[4] = substr($strNum2, 1, 1); |
|
| 351 | + $leftRnd[5] = substr($strNum2, 2, 1); |
|
| 352 | + $leftRnd[6] = substr($strNum2, 3, 1); |
|
| 353 | 353 | } |
| 354 | 354 | else { |
| 355 | 355 | $leftRnd[3] = mt_rand(0, 9); |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | } |
| 360 | 360 | |
| 361 | 361 | /*Generate right section of gencode*/ |
| 362 | - switch ( strlen($ref) ) { |
|
| 362 | + switch (strlen($ref)) { |
|
| 363 | 363 | case 0: |
| 364 | 364 | $rightRnd[0] = mt_rand(0, 9); |
| 365 | 365 | $rightRnd[1] = mt_rand(0, 9); |
@@ -380,32 +380,32 @@ discard block |
||
| 380 | 380 | $rightRnd[0] = 0; |
| 381 | 381 | $rightRnd[1] = 0; |
| 382 | 382 | $rightRnd[2] = 0; |
| 383 | - $rightRnd[3] = substr( $ref, 0, 1); |
|
| 384 | - $rightRnd[4] = substr( $ref, 1, 1); |
|
| 383 | + $rightRnd[3] = substr($ref, 0, 1); |
|
| 384 | + $rightRnd[4] = substr($ref, 1, 1); |
|
| 385 | 385 | break; |
| 386 | 386 | |
| 387 | 387 | case 3: |
| 388 | 388 | $rightRnd[0] = 0; |
| 389 | 389 | $rightRnd[1] = 0; |
| 390 | - $rightRnd[2] = substr( $ref, 0, 1); |
|
| 391 | - $rightRnd[3] = substr( $ref, 1, 1); |
|
| 392 | - $rightRnd[4] = substr( $ref, 2, 1); |
|
| 390 | + $rightRnd[2] = substr($ref, 0, 1); |
|
| 391 | + $rightRnd[3] = substr($ref, 1, 1); |
|
| 392 | + $rightRnd[4] = substr($ref, 2, 1); |
|
| 393 | 393 | break; |
| 394 | 394 | |
| 395 | 395 | case 4: |
| 396 | 396 | $rightRnd[0] = 0; |
| 397 | - $rightRnd[1] = substr( $ref, 0, 1); |
|
| 398 | - $rightRnd[2] = substr( $ref, 1, 1); |
|
| 399 | - $rightRnd[3] = substr( $ref, 2, 1); |
|
| 400 | - $rightRnd[4] = substr( $ref, 3, 1); |
|
| 397 | + $rightRnd[1] = substr($ref, 0, 1); |
|
| 398 | + $rightRnd[2] = substr($ref, 1, 1); |
|
| 399 | + $rightRnd[3] = substr($ref, 2, 1); |
|
| 400 | + $rightRnd[4] = substr($ref, 3, 1); |
|
| 401 | 401 | break; |
| 402 | 402 | |
| 403 | 403 | case 5: |
| 404 | - $rightRnd[0] = substr( $ref, 0, 1); |
|
| 405 | - $rightRnd[1] = substr( $ref, 1, 1); |
|
| 406 | - $rightRnd[2] = substr( $ref, 2, 1); |
|
| 407 | - $rightRnd[3] = substr( $ref, 3, 1); |
|
| 408 | - $rightRnd[4] = substr( $ref, 4, 1); |
|
| 404 | + $rightRnd[0] = substr($ref, 0, 1); |
|
| 405 | + $rightRnd[1] = substr($ref, 1, 1); |
|
| 406 | + $rightRnd[2] = substr($ref, 2, 1); |
|
| 407 | + $rightRnd[3] = substr($ref, 3, 1); |
|
| 408 | + $rightRnd[4] = substr($ref, 4, 1); |
|
| 409 | 409 | break; |
| 410 | 410 | |
| 411 | 411 | default: |
@@ -443,8 +443,8 @@ discard block |
||
| 443 | 443 | */ |
| 444 | 444 | public function countryGen($country, $code) { |
| 445 | 445 | /*Generation for country selection*/ |
| 446 | - if ( !empty($country) && $code == 'country' ) { |
|
| 447 | - if ( array_key_exists(strtoupper($country), $this->ean13) ) { |
|
| 446 | + if (!empty($country) && $code == 'country') { |
|
| 447 | + if (array_key_exists(strtoupper($country), $this->ean13)) { |
|
| 448 | 448 | $ctry = $this->ean13[strtoupper($country)]; |
| 449 | 449 | $gen = $this->explodingString($ctry); |
| 450 | 450 | } |
@@ -453,8 +453,8 @@ discard block |
||
| 453 | 453 | if ($code == 'distrib' or $code == 'weight' or |
| 454 | 454 | $code == 'interne' or $code == 'coupons' or |
| 455 | 455 | $code == 'issn' or $code == 'isbn') { |
| 456 | - if ( !empty($this->other_ean13) ) { |
|
| 457 | - if ( array_key_exists($code, $this->other_ean13) ) { |
|
| 456 | + if (!empty($this->other_ean13)) { |
|
| 457 | + if (array_key_exists($code, $this->other_ean13)) { |
|
| 458 | 458 | |
| 459 | 459 | $gen = $this->explodingString($this->other_ean13[$code]); |
| 460 | 460 | } |
@@ -471,23 +471,23 @@ discard block |
||
| 471 | 471 | if ($this->binCode === '') { |
| 472 | 472 | $binCode = ''; |
| 473 | 473 | /*Generate left bincode*/ |
| 474 | - for ($i=0; $i<6 ; $i++) { |
|
| 475 | - if( substr($this->motif, $i, 1) === 'A' ) { |
|
| 474 | + for ($i = 0; $i < 6; $i++) { |
|
| 475 | + if (substr($this->motif, $i, 1) === 'A') { |
|
| 476 | 476 | $binCode .= $this->setA[substr($code, $i, 1)]; |
| 477 | 477 | } |
| 478 | - else if ( substr($this->motif, $i, 1) === 'B' ) { |
|
| 478 | + else if (substr($this->motif, $i, 1) === 'B') { |
|
| 479 | 479 | $binCode .= $this->setB[substr($code, $i, 1)]; |
| 480 | 480 | } |
| 481 | 481 | } |
| 482 | 482 | |
| 483 | 483 | /*Generate right bincode*/ |
| 484 | - for ($i=6; $i<12 ; $i++) { |
|
| 484 | + for ($i = 6; $i < 12; $i++) { |
|
| 485 | 485 | $binCode .= $this->setC[substr($code, $i, 1)]; |
| 486 | 486 | } |
| 487 | 487 | } |
| 488 | 488 | |
| 489 | - $this->writeLog( sprintf( __("Bincode generate: %s <br />", 'wps_barcode'), |
|
| 490 | - '<b>'.$binCode.'</b>') ); |
|
| 489 | + $this->writeLog(sprintf(__("Bincode generate: %s <br />", 'wps_barcode'), |
|
| 490 | + '<b>' . $binCode . '</b>')); |
|
| 491 | 491 | |
| 492 | 492 | $this->binCode = $binCode; |
| 493 | 493 | } |
@@ -540,8 +540,8 @@ discard block |
||
| 540 | 540 | break; |
| 541 | 541 | } |
| 542 | 542 | |
| 543 | - $this->writeLog( sprintf( __("Motif: %s<br />", 'wps_barcode'), |
|
| 544 | - $this->motif) ); |
|
| 543 | + $this->writeLog(sprintf(__("Motif: %s<br />", 'wps_barcode'), |
|
| 544 | + $this->motif)); |
|
| 545 | 545 | } |
| 546 | 546 | } |
| 547 | 547 | |
@@ -1,4 +1,6 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
| 2 | + exit; |
|
| 3 | +} |
|
| 2 | 4 | |
| 3 | 5 | /** |
| 4 | 6 | * Generate barcodes with informations |
@@ -116,8 +118,7 @@ discard block |
||
| 116 | 118 | |
| 117 | 119 | if ( $this->fixed !== '' ) { |
| 118 | 120 | $this->fixed .= ';country'; |
| 119 | - } |
|
| 120 | - else { |
|
| 121 | + } else { |
|
| 121 | 122 | $this->fixed .= 'country'; |
| 122 | 123 | } |
| 123 | 124 | } |
@@ -131,8 +132,7 @@ discard block |
||
| 131 | 132 | |
| 132 | 133 | if ( $this->fixed !== '' ) { |
| 133 | 134 | $this->fixed .= ';enterprise'; |
| 134 | - } |
|
| 135 | - else { |
|
| 135 | + } else { |
|
| 136 | 136 | $this->fixed .= 'enterprise'; |
| 137 | 137 | } |
| 138 | 138 | } |
@@ -205,8 +205,7 @@ discard block |
||
| 205 | 205 | |
| 206 | 206 | if ( intval( substr($exploding[$i], $pos) ) < 1 ) { |
| 207 | 207 | $gen[$i]["end"] = substr($exploding[$i], $pos+1); |
| 208 | - } |
|
| 209 | - else { |
|
| 208 | + } else { |
|
| 210 | 209 | $gen[$i]["end"] = substr($exploding[$i], $pos); |
| 211 | 210 | } |
| 212 | 211 | |
@@ -223,15 +222,12 @@ discard block |
||
| 223 | 222 | |
| 224 | 223 | if ( $rand >= 10 and $rand < 100 ) { |
| 225 | 224 | $strNum = '0'.intval($rand); |
| 226 | - } |
|
| 227 | - else if ( $rand < 10 ) { |
|
| 225 | + } else if ( $rand < 10 ) { |
|
| 228 | 226 | $strNum = '00'.intval($rand); |
| 229 | - } |
|
| 230 | - else { |
|
| 227 | + } else { |
|
| 231 | 228 | $strNum = intval($rand); |
| 232 | 229 | } |
| 233 | - } |
|
| 234 | - else { |
|
| 230 | + } else { |
|
| 235 | 231 | $pos = strpos($exploding[0], ":"); |
| 236 | 232 | if ($pos > 0) { |
| 237 | 233 | $gen[0]["start"] = substr($exploding[0], 0, $pos); |
@@ -253,8 +249,7 @@ discard block |
||
| 253 | 249 | break; |
| 254 | 250 | } |
| 255 | 251 | } |
| 256 | - } |
|
| 257 | - else { |
|
| 252 | + } else { |
|
| 258 | 253 | $strNum = strval($exploding[0]); |
| 259 | 254 | } |
| 260 | 255 | } |
@@ -291,8 +286,7 @@ discard block |
||
| 291 | 286 | $country = $this->country; |
| 292 | 287 | $code = "country"; |
| 293 | 288 | $countryViaConf = true; |
| 294 | - } |
|
| 295 | - elseif ( strtolower($value) === "enterprise" ) { |
|
| 289 | + } elseif ( strtolower($value) === "enterprise" ) { |
|
| 296 | 290 | $enterpriseViaConf = true; |
| 297 | 291 | } |
| 298 | 292 | } |
@@ -305,8 +299,7 @@ discard block |
||
| 305 | 299 | $leftRnd[0] = substr( $strNum, 0, 1); |
| 306 | 300 | $leftRnd[1] = substr( $strNum, 1, 1); |
| 307 | 301 | $leftRnd[2] = substr( $strNum, 2, 1); |
| 308 | - } |
|
| 309 | - else { |
|
| 302 | + } else { |
|
| 310 | 303 | |
| 311 | 304 | if ( array_key_exists(strtoupper($country), $this->ean13) ) { |
| 312 | 305 | $ctry = $this->ean13[strtoupper($country)]; |
@@ -314,8 +307,7 @@ discard block |
||
| 314 | 307 | |
| 315 | 308 | $gen = $this->explodingString($ctry); |
| 316 | 309 | } |
| 317 | - } |
|
| 318 | - else { |
|
| 310 | + } else { |
|
| 319 | 311 | /*Generation for country selection*/ |
| 320 | 312 | /*if ( !empty($country) && $code == 'country' ) { |
| 321 | 313 | if ( array_key_exists(strtoupper($country), $this->ean13) ) { |
@@ -350,8 +342,7 @@ discard block |
||
| 350 | 342 | $leftRnd[4] = substr( $strNum2, 1, 1); |
| 351 | 343 | $leftRnd[5] = substr( $strNum2, 2, 1); |
| 352 | 344 | $leftRnd[6] = substr( $strNum2, 3, 1); |
| 353 | - } |
|
| 354 | - else { |
|
| 345 | + } else { |
|
| 355 | 346 | $leftRnd[3] = mt_rand(0, 9); |
| 356 | 347 | $leftRnd[4] = mt_rand(0, 9); |
| 357 | 348 | $leftRnd[5] = mt_rand(0, 9); |
@@ -426,8 +417,7 @@ discard block |
||
| 426 | 417 | foreach ($rightRnd as $key => $value) { |
| 427 | 418 | $codeForChecksum .= $value; |
| 428 | 419 | } |
| 429 | - } |
|
| 430 | - else { |
|
| 420 | + } else { |
|
| 431 | 421 | $codeForChecksum = $this->originalCode; |
| 432 | 422 | } |
| 433 | 423 | |
@@ -448,8 +438,7 @@ discard block |
||
| 448 | 438 | $ctry = $this->ean13[strtoupper($country)]; |
| 449 | 439 | $gen = $this->explodingString($ctry); |
| 450 | 440 | } |
| 451 | - } |
|
| 452 | - else { |
|
| 441 | + } else { |
|
| 453 | 442 | if ($code == 'distrib' or $code == 'weight' or |
| 454 | 443 | $code == 'interne' or $code == 'coupons' or |
| 455 | 444 | $code == 'issn' or $code == 'isbn') { |
@@ -474,8 +463,7 @@ discard block |
||
| 474 | 463 | for ($i=0; $i<6 ; $i++) { |
| 475 | 464 | if( substr($this->motif, $i, 1) === 'A' ) { |
| 476 | 465 | $binCode .= $this->setA[substr($code, $i, 1)]; |
| 477 | - } |
|
| 478 | - else if ( substr($this->motif, $i, 1) === 'B' ) { |
|
| 466 | + } else if ( substr($this->motif, $i, 1) === 'B' ) { |
|
| 479 | 467 | $binCode .= $this->setB[substr($code, $i, 1)]; |
| 480 | 468 | } |
| 481 | 469 | } |
@@ -212,6 +212,10 @@ discard block |
||
| 212 | 212 | // Note that no real action is taken, if the archive does not exist it is not |
| 213 | 213 | // created. Use create() for that. |
| 214 | 214 | // -------------------------------------------------------------------------------- |
| 215 | + |
|
| 216 | + /** |
|
| 217 | + * @param string $p_zipname |
|
| 218 | + */ |
|
| 215 | 219 | function PclZip($p_zipname) |
| 216 | 220 | { |
| 217 | 221 | |
@@ -220,6 +224,10 @@ discard block |
||
| 220 | 224 | { |
| 221 | 225 | if (!function_exists('gzopen') |
| 222 | 226 | && function_exists('gzopen64')) { |
| 227 | + |
|
| 228 | + /** |
|
| 229 | + * @param string $filename |
|
| 230 | + */ |
|
| 223 | 231 | function gzopen($filename , $mode = 'r', $use_include_path = 0 ) |
| 224 | 232 | { |
| 225 | 233 | return gzopen64($filename , $mode, $use_include_path); |
@@ -457,6 +465,10 @@ discard block |
||
| 457 | 465 | // The list of the added files, with a status of the add action. |
| 458 | 466 | // (see PclZip::listContent() for list entry format) |
| 459 | 467 | // -------------------------------------------------------------------------------- |
| 468 | + |
|
| 469 | + /** |
|
| 470 | + * @param string $p_filelist |
|
| 471 | + */ |
|
| 460 | 472 | function add($p_filelist) |
| 461 | 473 | { |
| 462 | 474 | $v_result=1; |
@@ -2341,6 +2353,10 @@ discard block |
||
| 2341 | 2353 | // Description : |
| 2342 | 2354 | // Parameters : |
| 2343 | 2355 | // -------------------------------------------------------------------------------- |
| 2356 | + |
|
| 2357 | + /** |
|
| 2358 | + * @param string $p_mode |
|
| 2359 | + */ |
|
| 2344 | 2360 | function privOpenFd($p_mode) |
| 2345 | 2361 | { |
| 2346 | 2362 | $v_result=1; |
@@ -4157,6 +4173,10 @@ discard block |
||
| 4157 | 4173 | // Parameters : |
| 4158 | 4174 | // Return Values : |
| 4159 | 4175 | // -------------------------------------------------------------------------------- |
| 4176 | + |
|
| 4177 | + /** |
|
| 4178 | + * @param string $p_string |
|
| 4179 | + */ |
|
| 4160 | 4180 | function privExtractFileAsString(&$p_entry, &$p_string, &$p_options) |
| 4161 | 4181 | { |
| 4162 | 4182 | $v_result=1; |
@@ -5050,6 +5070,10 @@ discard block |
||
| 5050 | 5070 | // Parameters : |
| 5051 | 5071 | // Return Values : |
| 5052 | 5072 | // -------------------------------------------------------------------------------- |
| 5073 | + |
|
| 5074 | + /** |
|
| 5075 | + * @param PclZip $p_archive_to_add |
|
| 5076 | + */ |
|
| 5053 | 5077 | function privMerge(&$p_archive_to_add) |
| 5054 | 5078 | { |
| 5055 | 5079 | $v_result=1; |
@@ -5557,6 +5581,11 @@ discard block |
||
| 5557 | 5581 | // 3 : src & dest gzip |
| 5558 | 5582 | // Return Values : |
| 5559 | 5583 | // -------------------------------------------------------------------------------- |
| 5584 | + |
|
| 5585 | + /** |
|
| 5586 | + * @param integer $p_src |
|
| 5587 | + * @param integer $p_dest |
|
| 5588 | + */ |
|
| 5560 | 5589 | function PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode=0) |
| 5561 | 5590 | { |
| 5562 | 5591 | $v_result = 1; |
@@ -5619,6 +5648,11 @@ discard block |
||
| 5619 | 5648 | // Return Values : |
| 5620 | 5649 | // 1 on success, 0 on failure. |
| 5621 | 5650 | // -------------------------------------------------------------------------------- |
| 5651 | + |
|
| 5652 | + /** |
|
| 5653 | + * @param string $p_src |
|
| 5654 | + * @param string $p_dest |
|
| 5655 | + */ |
|
| 5622 | 5656 | function PclZipUtilRename($p_src, $p_dest) |
| 5623 | 5657 | { |
| 5624 | 5658 | $v_result = 1; |
@@ -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,25 +215,25 @@ discard block |
||
| 215 | 215 | function PclZip($p_zipname) |
| 216 | 216 | { |
| 217 | 217 | |
| 218 | - // ----- Tests the zlib |
|
| 219 | - if (!function_exists('gzopen')) |
|
| 220 | - { |
|
| 221 | - if (!function_exists('gzopen') |
|
| 222 | - && function_exists('gzopen64')) { |
|
| 223 | - function gzopen($filename , $mode = 'r', $use_include_path = 0 ) |
|
| 224 | - { |
|
| 225 | - return gzopen64($filename , $mode, $use_include_path); |
|
| 226 | - } |
|
| 227 | - } |
|
| 228 | - } |
|
| 218 | + // ----- Tests the zlib |
|
| 219 | + if (!function_exists('gzopen')) |
|
| 220 | + { |
|
| 221 | + if (!function_exists('gzopen') |
|
| 222 | + && function_exists('gzopen64')) { |
|
| 223 | + function gzopen($filename , $mode = 'r', $use_include_path = 0 ) |
|
| 224 | + { |
|
| 225 | + return gzopen64($filename , $mode, $use_include_path); |
|
| 226 | + } |
|
| 227 | + } |
|
| 228 | + } |
|
| 229 | 229 | |
| 230 | - // ----- Set the attributes |
|
| 231 | - $this->zipname = $p_zipname; |
|
| 232 | - $this->zip_fd = 0; |
|
| 233 | - $this->magic_quotes_status = -1; |
|
| 230 | + // ----- Set the attributes |
|
| 231 | + $this->zipname = $p_zipname; |
|
| 232 | + $this->zip_fd = 0; |
|
| 233 | + $this->magic_quotes_status = -1; |
|
| 234 | 234 | |
| 235 | - // ----- Return |
|
| 236 | - return; |
|
| 235 | + // ----- Return |
|
| 236 | + return; |
|
| 237 | 237 | } |
| 238 | 238 | // -------------------------------------------------------------------------------- |
| 239 | 239 | |
@@ -276,149 +276,149 @@ discard block |
||
| 276 | 276 | // -------------------------------------------------------------------------------- |
| 277 | 277 | function create($p_filelist) |
| 278 | 278 | { |
| 279 | - $v_result=1; |
|
| 280 | - |
|
| 281 | - // ----- Reset the error handler |
|
| 282 | - $this->privErrorReset(); |
|
| 283 | - |
|
| 284 | - // ----- Set default values |
|
| 285 | - $v_options = array(); |
|
| 286 | - $v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE; |
|
| 287 | - |
|
| 288 | - // ----- Look for variable options arguments |
|
| 289 | - $v_size = func_num_args(); |
|
| 290 | - |
|
| 291 | - // ----- Look for arguments |
|
| 292 | - if ($v_size > 1) { |
|
| 293 | - // ----- Get the arguments |
|
| 294 | - $v_arg_list = func_get_args(); |
|
| 295 | - |
|
| 296 | - // ----- Remove from the options list the first argument |
|
| 297 | - array_shift($v_arg_list); |
|
| 298 | - $v_size--; |
|
| 299 | - |
|
| 300 | - // ----- Look for first arg |
|
| 301 | - if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) { |
|
| 302 | - |
|
| 303 | - // ----- Parse the options |
|
| 304 | - $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, |
|
| 305 | - array (PCLZIP_OPT_REMOVE_PATH => 'optional', |
|
| 306 | - PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', |
|
| 307 | - PCLZIP_OPT_ADD_PATH => 'optional', |
|
| 308 | - PCLZIP_CB_PRE_ADD => 'optional', |
|
| 309 | - PCLZIP_CB_POST_ADD => 'optional', |
|
| 310 | - PCLZIP_OPT_NO_COMPRESSION => 'optional', |
|
| 311 | - PCLZIP_OPT_COMMENT => 'optional', |
|
| 312 | - PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional', |
|
| 313 | - PCLZIP_OPT_TEMP_FILE_ON => 'optional', |
|
| 314 | - PCLZIP_OPT_TEMP_FILE_OFF => 'optional' |
|
| 315 | - //, PCLZIP_OPT_CRYPT => 'optional' |
|
| 316 | - )); |
|
| 317 | - if ($v_result != 1) { |
|
| 318 | - return 0; |
|
| 319 | - } |
|
| 320 | - } |
|
| 279 | + $v_result=1; |
|
| 280 | + |
|
| 281 | + // ----- Reset the error handler |
|
| 282 | + $this->privErrorReset(); |
|
| 283 | + |
|
| 284 | + // ----- Set default values |
|
| 285 | + $v_options = array(); |
|
| 286 | + $v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE; |
|
| 287 | + |
|
| 288 | + // ----- Look for variable options arguments |
|
| 289 | + $v_size = func_num_args(); |
|
| 290 | + |
|
| 291 | + // ----- Look for arguments |
|
| 292 | + if ($v_size > 1) { |
|
| 293 | + // ----- Get the arguments |
|
| 294 | + $v_arg_list = func_get_args(); |
|
| 295 | + |
|
| 296 | + // ----- Remove from the options list the first argument |
|
| 297 | + array_shift($v_arg_list); |
|
| 298 | + $v_size--; |
|
| 299 | + |
|
| 300 | + // ----- Look for first arg |
|
| 301 | + if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) { |
|
| 302 | + |
|
| 303 | + // ----- Parse the options |
|
| 304 | + $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, |
|
| 305 | + array (PCLZIP_OPT_REMOVE_PATH => 'optional', |
|
| 306 | + PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', |
|
| 307 | + PCLZIP_OPT_ADD_PATH => 'optional', |
|
| 308 | + PCLZIP_CB_PRE_ADD => 'optional', |
|
| 309 | + PCLZIP_CB_POST_ADD => 'optional', |
|
| 310 | + PCLZIP_OPT_NO_COMPRESSION => 'optional', |
|
| 311 | + PCLZIP_OPT_COMMENT => 'optional', |
|
| 312 | + PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional', |
|
| 313 | + PCLZIP_OPT_TEMP_FILE_ON => 'optional', |
|
| 314 | + PCLZIP_OPT_TEMP_FILE_OFF => 'optional' |
|
| 315 | + //, PCLZIP_OPT_CRYPT => 'optional' |
|
| 316 | + )); |
|
| 317 | + if ($v_result != 1) { |
|
| 318 | + return 0; |
|
| 319 | + } |
|
| 320 | + } |
|
| 321 | 321 | |
| 322 | - // ----- Look for 2 args |
|
| 323 | - // Here we need to support the first historic synopsis of the |
|
| 324 | - // method. |
|
| 325 | - else { |
|
| 326 | - |
|
| 327 | - // ----- Get the first argument |
|
| 328 | - $v_options[PCLZIP_OPT_ADD_PATH] = $v_arg_list[0]; |
|
| 329 | - |
|
| 330 | - // ----- Look for the optional second argument |
|
| 331 | - if ($v_size == 2) { |
|
| 332 | - $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1]; |
|
| 333 | - } |
|
| 334 | - else if ($v_size > 2) { |
|
| 335 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, |
|
| 336 | - "Invalid number / type of arguments"); |
|
| 337 | - return 0; |
|
| 338 | - } |
|
| 339 | - } |
|
| 340 | - } |
|
| 322 | + // ----- Look for 2 args |
|
| 323 | + // Here we need to support the first historic synopsis of the |
|
| 324 | + // method. |
|
| 325 | + else { |
|
| 326 | + |
|
| 327 | + // ----- Get the first argument |
|
| 328 | + $v_options[PCLZIP_OPT_ADD_PATH] = $v_arg_list[0]; |
|
| 329 | + |
|
| 330 | + // ----- Look for the optional second argument |
|
| 331 | + if ($v_size == 2) { |
|
| 332 | + $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1]; |
|
| 333 | + } |
|
| 334 | + else if ($v_size > 2) { |
|
| 335 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, |
|
| 336 | + "Invalid number / type of arguments"); |
|
| 337 | + return 0; |
|
| 338 | + } |
|
| 339 | + } |
|
| 340 | + } |
|
| 341 | 341 | |
| 342 | - // ----- Look for default option values |
|
| 343 | - $this->privOptionDefaultThreshold($v_options); |
|
| 344 | - |
|
| 345 | - // ----- Init |
|
| 346 | - $v_string_list = array(); |
|
| 347 | - $v_att_list = array(); |
|
| 348 | - $v_filedescr_list = array(); |
|
| 349 | - $p_result_list = array(); |
|
| 342 | + // ----- Look for default option values |
|
| 343 | + $this->privOptionDefaultThreshold($v_options); |
|
| 344 | + |
|
| 345 | + // ----- Init |
|
| 346 | + $v_string_list = array(); |
|
| 347 | + $v_att_list = array(); |
|
| 348 | + $v_filedescr_list = array(); |
|
| 349 | + $p_result_list = array(); |
|
| 350 | 350 | |
| 351 | - // ----- Look if the $p_filelist is really an array |
|
| 352 | - if (is_array($p_filelist)) { |
|
| 351 | + // ----- Look if the $p_filelist is really an array |
|
| 352 | + if (is_array($p_filelist)) { |
|
| 353 | 353 | |
| 354 | - // ----- Look if the first element is also an array |
|
| 355 | - // This will mean that this is a file description entry |
|
| 356 | - if (isset($p_filelist[0]) && is_array($p_filelist[0])) { |
|
| 357 | - $v_att_list = $p_filelist; |
|
| 358 | - } |
|
| 354 | + // ----- Look if the first element is also an array |
|
| 355 | + // This will mean that this is a file description entry |
|
| 356 | + if (isset($p_filelist[0]) && is_array($p_filelist[0])) { |
|
| 357 | + $v_att_list = $p_filelist; |
|
| 358 | + } |
|
| 359 | 359 | |
| 360 | - // ----- The list is a list of string names |
|
| 361 | - else { |
|
| 362 | - $v_string_list = $p_filelist; |
|
| 363 | - } |
|
| 364 | - } |
|
| 360 | + // ----- The list is a list of string names |
|
| 361 | + else { |
|
| 362 | + $v_string_list = $p_filelist; |
|
| 363 | + } |
|
| 364 | + } |
|
| 365 | 365 | |
| 366 | - // ----- Look if the $p_filelist is a string |
|
| 367 | - else if (is_string($p_filelist)) { |
|
| 368 | - // ----- Create a list from the string |
|
| 369 | - $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist); |
|
| 370 | - } |
|
| 366 | + // ----- Look if the $p_filelist is a string |
|
| 367 | + else if (is_string($p_filelist)) { |
|
| 368 | + // ----- Create a list from the string |
|
| 369 | + $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist); |
|
| 370 | + } |
|
| 371 | 371 | |
| 372 | - // ----- Invalid variable type for $p_filelist |
|
| 373 | - else { |
|
| 374 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_filelist"); |
|
| 375 | - return 0; |
|
| 376 | - } |
|
| 372 | + // ----- Invalid variable type for $p_filelist |
|
| 373 | + else { |
|
| 374 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_filelist"); |
|
| 375 | + return 0; |
|
| 376 | + } |
|
| 377 | 377 | |
| 378 | - // ----- Reformat the string list |
|
| 379 | - if (sizeof($v_string_list) != 0) { |
|
| 380 | - foreach ($v_string_list as $v_string) { |
|
| 381 | - if ($v_string != '') { |
|
| 382 | - $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string; |
|
| 383 | - } |
|
| 384 | - else { |
|
| 385 | - } |
|
| 386 | - } |
|
| 387 | - } |
|
| 378 | + // ----- Reformat the string list |
|
| 379 | + if (sizeof($v_string_list) != 0) { |
|
| 380 | + foreach ($v_string_list as $v_string) { |
|
| 381 | + if ($v_string != '') { |
|
| 382 | + $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string; |
|
| 383 | + } |
|
| 384 | + else { |
|
| 385 | + } |
|
| 386 | + } |
|
| 387 | + } |
|
| 388 | 388 | |
| 389 | - // ----- For each file in the list check the attributes |
|
| 390 | - $v_supported_attributes |
|
| 391 | - = array ( PCLZIP_ATT_FILE_NAME => 'mandatory' |
|
| 392 | - ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional' |
|
| 393 | - ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional' |
|
| 394 | - ,PCLZIP_ATT_FILE_MTIME => 'optional' |
|
| 395 | - ,PCLZIP_ATT_FILE_CONTENT => 'optional' |
|
| 396 | - ,PCLZIP_ATT_FILE_COMMENT => 'optional' |
|
| 389 | + // ----- For each file in the list check the attributes |
|
| 390 | + $v_supported_attributes |
|
| 391 | + = array ( PCLZIP_ATT_FILE_NAME => 'mandatory' |
|
| 392 | + ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional' |
|
| 393 | + ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional' |
|
| 394 | + ,PCLZIP_ATT_FILE_MTIME => 'optional' |
|
| 395 | + ,PCLZIP_ATT_FILE_CONTENT => 'optional' |
|
| 396 | + ,PCLZIP_ATT_FILE_COMMENT => 'optional' |
|
| 397 | 397 | ); |
| 398 | - foreach ($v_att_list as $v_entry) { |
|
| 399 | - $v_result = $this->privFileDescrParseAtt($v_entry, |
|
| 400 | - $v_filedescr_list[], |
|
| 401 | - $v_options, |
|
| 402 | - $v_supported_attributes); |
|
| 403 | - if ($v_result != 1) { |
|
| 404 | - return 0; |
|
| 405 | - } |
|
| 406 | - } |
|
| 398 | + foreach ($v_att_list as $v_entry) { |
|
| 399 | + $v_result = $this->privFileDescrParseAtt($v_entry, |
|
| 400 | + $v_filedescr_list[], |
|
| 401 | + $v_options, |
|
| 402 | + $v_supported_attributes); |
|
| 403 | + if ($v_result != 1) { |
|
| 404 | + return 0; |
|
| 405 | + } |
|
| 406 | + } |
|
| 407 | 407 | |
| 408 | - // ----- Expand the filelist (expand directories) |
|
| 409 | - $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options); |
|
| 410 | - if ($v_result != 1) { |
|
| 411 | - return 0; |
|
| 412 | - } |
|
| 408 | + // ----- Expand the filelist (expand directories) |
|
| 409 | + $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options); |
|
| 410 | + if ($v_result != 1) { |
|
| 411 | + return 0; |
|
| 412 | + } |
|
| 413 | 413 | |
| 414 | - // ----- Call the create fct |
|
| 415 | - $v_result = $this->privCreate($v_filedescr_list, $p_result_list, $v_options); |
|
| 416 | - if ($v_result != 1) { |
|
| 417 | - return 0; |
|
| 418 | - } |
|
| 414 | + // ----- Call the create fct |
|
| 415 | + $v_result = $this->privCreate($v_filedescr_list, $p_result_list, $v_options); |
|
| 416 | + if ($v_result != 1) { |
|
| 417 | + return 0; |
|
| 418 | + } |
|
| 419 | 419 | |
| 420 | - // ----- Return |
|
| 421 | - return $p_result_list; |
|
| 420 | + // ----- Return |
|
| 421 | + return $p_result_list; |
|
| 422 | 422 | } |
| 423 | 423 | // -------------------------------------------------------------------------------- |
| 424 | 424 | |
@@ -459,149 +459,149 @@ discard block |
||
| 459 | 459 | // -------------------------------------------------------------------------------- |
| 460 | 460 | function add($p_filelist) |
| 461 | 461 | { |
| 462 | - $v_result=1; |
|
| 463 | - |
|
| 464 | - // ----- Reset the error handler |
|
| 465 | - $this->privErrorReset(); |
|
| 466 | - |
|
| 467 | - // ----- Set default values |
|
| 468 | - $v_options = array(); |
|
| 469 | - $v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE; |
|
| 470 | - |
|
| 471 | - // ----- Look for variable options arguments |
|
| 472 | - $v_size = func_num_args(); |
|
| 473 | - |
|
| 474 | - // ----- Look for arguments |
|
| 475 | - if ($v_size > 1) { |
|
| 476 | - // ----- Get the arguments |
|
| 477 | - $v_arg_list = func_get_args(); |
|
| 478 | - |
|
| 479 | - // ----- Remove form the options list the first argument |
|
| 480 | - array_shift($v_arg_list); |
|
| 481 | - $v_size--; |
|
| 482 | - |
|
| 483 | - // ----- Look for first arg |
|
| 484 | - if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) { |
|
| 485 | - |
|
| 486 | - // ----- Parse the options |
|
| 487 | - $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, |
|
| 488 | - array (PCLZIP_OPT_REMOVE_PATH => 'optional', |
|
| 489 | - PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', |
|
| 490 | - PCLZIP_OPT_ADD_PATH => 'optional', |
|
| 491 | - PCLZIP_CB_PRE_ADD => 'optional', |
|
| 492 | - PCLZIP_CB_POST_ADD => 'optional', |
|
| 493 | - PCLZIP_OPT_NO_COMPRESSION => 'optional', |
|
| 494 | - PCLZIP_OPT_COMMENT => 'optional', |
|
| 495 | - PCLZIP_OPT_ADD_COMMENT => 'optional', |
|
| 496 | - PCLZIP_OPT_PREPEND_COMMENT => 'optional', |
|
| 497 | - PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional', |
|
| 498 | - PCLZIP_OPT_TEMP_FILE_ON => 'optional', |
|
| 499 | - PCLZIP_OPT_TEMP_FILE_OFF => 'optional' |
|
| 500 | - //, PCLZIP_OPT_CRYPT => 'optional' |
|
| 462 | + $v_result=1; |
|
| 463 | + |
|
| 464 | + // ----- Reset the error handler |
|
| 465 | + $this->privErrorReset(); |
|
| 466 | + |
|
| 467 | + // ----- Set default values |
|
| 468 | + $v_options = array(); |
|
| 469 | + $v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE; |
|
| 470 | + |
|
| 471 | + // ----- Look for variable options arguments |
|
| 472 | + $v_size = func_num_args(); |
|
| 473 | + |
|
| 474 | + // ----- Look for arguments |
|
| 475 | + if ($v_size > 1) { |
|
| 476 | + // ----- Get the arguments |
|
| 477 | + $v_arg_list = func_get_args(); |
|
| 478 | + |
|
| 479 | + // ----- Remove form the options list the first argument |
|
| 480 | + array_shift($v_arg_list); |
|
| 481 | + $v_size--; |
|
| 482 | + |
|
| 483 | + // ----- Look for first arg |
|
| 484 | + if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) { |
|
| 485 | + |
|
| 486 | + // ----- Parse the options |
|
| 487 | + $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, |
|
| 488 | + array (PCLZIP_OPT_REMOVE_PATH => 'optional', |
|
| 489 | + PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', |
|
| 490 | + PCLZIP_OPT_ADD_PATH => 'optional', |
|
| 491 | + PCLZIP_CB_PRE_ADD => 'optional', |
|
| 492 | + PCLZIP_CB_POST_ADD => 'optional', |
|
| 493 | + PCLZIP_OPT_NO_COMPRESSION => 'optional', |
|
| 494 | + PCLZIP_OPT_COMMENT => 'optional', |
|
| 495 | + PCLZIP_OPT_ADD_COMMENT => 'optional', |
|
| 496 | + PCLZIP_OPT_PREPEND_COMMENT => 'optional', |
|
| 497 | + PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional', |
|
| 498 | + PCLZIP_OPT_TEMP_FILE_ON => 'optional', |
|
| 499 | + PCLZIP_OPT_TEMP_FILE_OFF => 'optional' |
|
| 500 | + //, PCLZIP_OPT_CRYPT => 'optional' |
|
| 501 | 501 | )); |
| 502 | - if ($v_result != 1) { |
|
| 503 | - return 0; |
|
| 504 | - } |
|
| 505 | - } |
|
| 502 | + if ($v_result != 1) { |
|
| 503 | + return 0; |
|
| 504 | + } |
|
| 505 | + } |
|
| 506 | 506 | |
| 507 | - // ----- Look for 2 args |
|
| 508 | - // Here we need to support the first historic synopsis of the |
|
| 509 | - // method. |
|
| 510 | - else { |
|
| 511 | - |
|
| 512 | - // ----- Get the first argument |
|
| 513 | - $v_options[PCLZIP_OPT_ADD_PATH] = $v_add_path = $v_arg_list[0]; |
|
| 514 | - |
|
| 515 | - // ----- Look for the optional second argument |
|
| 516 | - if ($v_size == 2) { |
|
| 517 | - $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1]; |
|
| 518 | - } |
|
| 519 | - else if ($v_size > 2) { |
|
| 520 | - // ----- Error log |
|
| 521 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments"); |
|
| 522 | - |
|
| 523 | - // ----- Return |
|
| 524 | - return 0; |
|
| 525 | - } |
|
| 526 | - } |
|
| 527 | - } |
|
| 507 | + // ----- Look for 2 args |
|
| 508 | + // Here we need to support the first historic synopsis of the |
|
| 509 | + // method. |
|
| 510 | + else { |
|
| 511 | + |
|
| 512 | + // ----- Get the first argument |
|
| 513 | + $v_options[PCLZIP_OPT_ADD_PATH] = $v_add_path = $v_arg_list[0]; |
|
| 514 | + |
|
| 515 | + // ----- Look for the optional second argument |
|
| 516 | + if ($v_size == 2) { |
|
| 517 | + $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1]; |
|
| 518 | + } |
|
| 519 | + else if ($v_size > 2) { |
|
| 520 | + // ----- Error log |
|
| 521 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments"); |
|
| 522 | + |
|
| 523 | + // ----- Return |
|
| 524 | + return 0; |
|
| 525 | + } |
|
| 526 | + } |
|
| 527 | + } |
|
| 528 | 528 | |
| 529 | - // ----- Look for default option values |
|
| 530 | - $this->privOptionDefaultThreshold($v_options); |
|
| 529 | + // ----- Look for default option values |
|
| 530 | + $this->privOptionDefaultThreshold($v_options); |
|
| 531 | 531 | |
| 532 | - // ----- Init |
|
| 533 | - $v_string_list = array(); |
|
| 534 | - $v_att_list = array(); |
|
| 535 | - $v_filedescr_list = array(); |
|
| 536 | - $p_result_list = array(); |
|
| 532 | + // ----- Init |
|
| 533 | + $v_string_list = array(); |
|
| 534 | + $v_att_list = array(); |
|
| 535 | + $v_filedescr_list = array(); |
|
| 536 | + $p_result_list = array(); |
|
| 537 | 537 | |
| 538 | - // ----- Look if the $p_filelist is really an array |
|
| 539 | - if (is_array($p_filelist)) { |
|
| 538 | + // ----- Look if the $p_filelist is really an array |
|
| 539 | + if (is_array($p_filelist)) { |
|
| 540 | 540 | |
| 541 | - // ----- Look if the first element is also an array |
|
| 542 | - // This will mean that this is a file description entry |
|
| 543 | - if (isset($p_filelist[0]) && is_array($p_filelist[0])) { |
|
| 544 | - $v_att_list = $p_filelist; |
|
| 545 | - } |
|
| 541 | + // ----- Look if the first element is also an array |
|
| 542 | + // This will mean that this is a file description entry |
|
| 543 | + if (isset($p_filelist[0]) && is_array($p_filelist[0])) { |
|
| 544 | + $v_att_list = $p_filelist; |
|
| 545 | + } |
|
| 546 | 546 | |
| 547 | - // ----- The list is a list of string names |
|
| 548 | - else { |
|
| 549 | - $v_string_list = $p_filelist; |
|
| 550 | - } |
|
| 551 | - } |
|
| 547 | + // ----- The list is a list of string names |
|
| 548 | + else { |
|
| 549 | + $v_string_list = $p_filelist; |
|
| 550 | + } |
|
| 551 | + } |
|
| 552 | 552 | |
| 553 | - // ----- Look if the $p_filelist is a string |
|
| 554 | - else if (is_string($p_filelist)) { |
|
| 555 | - // ----- Create a list from the string |
|
| 556 | - $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist); |
|
| 557 | - } |
|
| 553 | + // ----- Look if the $p_filelist is a string |
|
| 554 | + else if (is_string($p_filelist)) { |
|
| 555 | + // ----- Create a list from the string |
|
| 556 | + $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist); |
|
| 557 | + } |
|
| 558 | 558 | |
| 559 | - // ----- Invalid variable type for $p_filelist |
|
| 560 | - else { |
|
| 561 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type '".gettype($p_filelist)."' for p_filelist"); |
|
| 562 | - return 0; |
|
| 563 | - } |
|
| 559 | + // ----- Invalid variable type for $p_filelist |
|
| 560 | + else { |
|
| 561 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type '".gettype($p_filelist)."' for p_filelist"); |
|
| 562 | + return 0; |
|
| 563 | + } |
|
| 564 | 564 | |
| 565 | - // ----- Reformat the string list |
|
| 566 | - if (sizeof($v_string_list) != 0) { |
|
| 567 | - foreach ($v_string_list as $v_string) { |
|
| 568 | - $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string; |
|
| 569 | - } |
|
| 570 | - } |
|
| 565 | + // ----- Reformat the string list |
|
| 566 | + if (sizeof($v_string_list) != 0) { |
|
| 567 | + foreach ($v_string_list as $v_string) { |
|
| 568 | + $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string; |
|
| 569 | + } |
|
| 570 | + } |
|
| 571 | 571 | |
| 572 | - // ----- For each file in the list check the attributes |
|
| 573 | - $v_supported_attributes |
|
| 574 | - = array ( PCLZIP_ATT_FILE_NAME => 'mandatory' |
|
| 575 | - ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional' |
|
| 576 | - ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional' |
|
| 577 | - ,PCLZIP_ATT_FILE_MTIME => 'optional' |
|
| 578 | - ,PCLZIP_ATT_FILE_CONTENT => 'optional' |
|
| 579 | - ,PCLZIP_ATT_FILE_COMMENT => 'optional' |
|
| 572 | + // ----- For each file in the list check the attributes |
|
| 573 | + $v_supported_attributes |
|
| 574 | + = array ( PCLZIP_ATT_FILE_NAME => 'mandatory' |
|
| 575 | + ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional' |
|
| 576 | + ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional' |
|
| 577 | + ,PCLZIP_ATT_FILE_MTIME => 'optional' |
|
| 578 | + ,PCLZIP_ATT_FILE_CONTENT => 'optional' |
|
| 579 | + ,PCLZIP_ATT_FILE_COMMENT => 'optional' |
|
| 580 | 580 | ); |
| 581 | - foreach ($v_att_list as $v_entry) { |
|
| 582 | - $v_result = $this->privFileDescrParseAtt($v_entry, |
|
| 583 | - $v_filedescr_list[], |
|
| 584 | - $v_options, |
|
| 585 | - $v_supported_attributes); |
|
| 586 | - if ($v_result != 1) { |
|
| 587 | - return 0; |
|
| 588 | - } |
|
| 589 | - } |
|
| 581 | + foreach ($v_att_list as $v_entry) { |
|
| 582 | + $v_result = $this->privFileDescrParseAtt($v_entry, |
|
| 583 | + $v_filedescr_list[], |
|
| 584 | + $v_options, |
|
| 585 | + $v_supported_attributes); |
|
| 586 | + if ($v_result != 1) { |
|
| 587 | + return 0; |
|
| 588 | + } |
|
| 589 | + } |
|
| 590 | 590 | |
| 591 | - // ----- Expand the filelist (expand directories) |
|
| 592 | - $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options); |
|
| 593 | - if ($v_result != 1) { |
|
| 594 | - return 0; |
|
| 595 | - } |
|
| 591 | + // ----- Expand the filelist (expand directories) |
|
| 592 | + $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options); |
|
| 593 | + if ($v_result != 1) { |
|
| 594 | + return 0; |
|
| 595 | + } |
|
| 596 | 596 | |
| 597 | - // ----- Call the create fct |
|
| 598 | - $v_result = $this->privAdd($v_filedescr_list, $p_result_list, $v_options); |
|
| 599 | - if ($v_result != 1) { |
|
| 600 | - return 0; |
|
| 601 | - } |
|
| 597 | + // ----- Call the create fct |
|
| 598 | + $v_result = $this->privAdd($v_filedescr_list, $p_result_list, $v_options); |
|
| 599 | + if ($v_result != 1) { |
|
| 600 | + return 0; |
|
| 601 | + } |
|
| 602 | 602 | |
| 603 | - // ----- Return |
|
| 604 | - return $p_result_list; |
|
| 603 | + // ----- Return |
|
| 604 | + return $p_result_list; |
|
| 605 | 605 | } |
| 606 | 606 | // -------------------------------------------------------------------------------- |
| 607 | 607 | |
@@ -648,26 +648,26 @@ discard block |
||
| 648 | 648 | // -------------------------------------------------------------------------------- |
| 649 | 649 | function listContent() |
| 650 | 650 | { |
| 651 | - $v_result=1; |
|
| 651 | + $v_result=1; |
|
| 652 | 652 | |
| 653 | - // ----- Reset the error handler |
|
| 654 | - $this->privErrorReset(); |
|
| 653 | + // ----- Reset the error handler |
|
| 654 | + $this->privErrorReset(); |
|
| 655 | 655 | |
| 656 | - // ----- Check archive |
|
| 657 | - if (!$this->privCheckFormat()) { |
|
| 658 | - return(0); |
|
| 659 | - } |
|
| 656 | + // ----- Check archive |
|
| 657 | + if (!$this->privCheckFormat()) { |
|
| 658 | + return(0); |
|
| 659 | + } |
|
| 660 | 660 | |
| 661 | - // ----- Call the extracting fct |
|
| 662 | - $p_list = array(); |
|
| 663 | - if (($v_result = $this->privList($p_list)) != 1) |
|
| 664 | - { |
|
| 665 | - unset($p_list); |
|
| 666 | - return(0); |
|
| 667 | - } |
|
| 661 | + // ----- Call the extracting fct |
|
| 662 | + $p_list = array(); |
|
| 663 | + if (($v_result = $this->privList($p_list)) != 1) |
|
| 664 | + { |
|
| 665 | + unset($p_list); |
|
| 666 | + return(0); |
|
| 667 | + } |
|
| 668 | 668 | |
| 669 | - // ----- Return |
|
| 670 | - return $p_list; |
|
| 669 | + // ----- Return |
|
| 670 | + return $p_list; |
|
| 671 | 671 | } |
| 672 | 672 | // -------------------------------------------------------------------------------- |
| 673 | 673 | |
@@ -705,120 +705,120 @@ discard block |
||
| 705 | 705 | // -------------------------------------------------------------------------------- |
| 706 | 706 | function extract() |
| 707 | 707 | { |
| 708 | - $v_result=1; |
|
| 708 | + $v_result=1; |
|
| 709 | 709 | |
| 710 | - // ----- Reset the error handler |
|
| 711 | - $this->privErrorReset(); |
|
| 710 | + // ----- Reset the error handler |
|
| 711 | + $this->privErrorReset(); |
|
| 712 | 712 | |
| 713 | - // ----- Check archive |
|
| 714 | - if (!$this->privCheckFormat()) { |
|
| 715 | - return(0); |
|
| 716 | - } |
|
| 713 | + // ----- Check archive |
|
| 714 | + if (!$this->privCheckFormat()) { |
|
| 715 | + return(0); |
|
| 716 | + } |
|
| 717 | 717 | |
| 718 | - // ----- Set default values |
|
| 719 | - $v_options = array(); |
|
| 718 | + // ----- Set default values |
|
| 719 | + $v_options = array(); |
|
| 720 | 720 | // $v_path = "./"; |
| 721 | - $v_path = ''; |
|
| 722 | - $v_remove_path = ""; |
|
| 723 | - $v_remove_all_path = false; |
|
| 724 | - |
|
| 725 | - // ----- Look for variable options arguments |
|
| 726 | - $v_size = func_num_args(); |
|
| 727 | - |
|
| 728 | - // ----- Default values for option |
|
| 729 | - $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE; |
|
| 730 | - |
|
| 731 | - // ----- Look for arguments |
|
| 732 | - if ($v_size > 0) { |
|
| 733 | - // ----- Get the arguments |
|
| 734 | - $v_arg_list = func_get_args(); |
|
| 735 | - |
|
| 736 | - // ----- Look for first arg |
|
| 737 | - if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) { |
|
| 738 | - |
|
| 739 | - // ----- Parse the options |
|
| 740 | - $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, |
|
| 741 | - array (PCLZIP_OPT_PATH => 'optional', |
|
| 742 | - PCLZIP_OPT_REMOVE_PATH => 'optional', |
|
| 743 | - PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', |
|
| 744 | - PCLZIP_OPT_ADD_PATH => 'optional', |
|
| 745 | - PCLZIP_CB_PRE_EXTRACT => 'optional', |
|
| 746 | - PCLZIP_CB_POST_EXTRACT => 'optional', |
|
| 747 | - PCLZIP_OPT_SET_CHMOD => 'optional', |
|
| 748 | - PCLZIP_OPT_BY_NAME => 'optional', |
|
| 749 | - PCLZIP_OPT_BY_EREG => 'optional', |
|
| 750 | - PCLZIP_OPT_BY_PREG => 'optional', |
|
| 751 | - PCLZIP_OPT_BY_INDEX => 'optional', |
|
| 752 | - PCLZIP_OPT_EXTRACT_AS_STRING => 'optional', |
|
| 753 | - PCLZIP_OPT_EXTRACT_IN_OUTPUT => 'optional', |
|
| 754 | - PCLZIP_OPT_REPLACE_NEWER => 'optional' |
|
| 755 | - ,PCLZIP_OPT_STOP_ON_ERROR => 'optional' |
|
| 756 | - ,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional', |
|
| 757 | - PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional', |
|
| 758 | - PCLZIP_OPT_TEMP_FILE_ON => 'optional', |
|
| 759 | - PCLZIP_OPT_TEMP_FILE_OFF => 'optional' |
|
| 760 | - )); |
|
| 761 | - if ($v_result != 1) { |
|
| 762 | - return 0; |
|
| 763 | - } |
|
| 764 | - |
|
| 765 | - // ----- Set the arguments |
|
| 766 | - if (isset($v_options[PCLZIP_OPT_PATH])) { |
|
| 767 | - $v_path = $v_options[PCLZIP_OPT_PATH]; |
|
| 768 | - } |
|
| 769 | - if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) { |
|
| 770 | - $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH]; |
|
| 771 | - } |
|
| 772 | - if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) { |
|
| 773 | - $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH]; |
|
| 774 | - } |
|
| 775 | - if (isset($v_options[PCLZIP_OPT_ADD_PATH])) { |
|
| 776 | - // ----- Check for '/' in last path char |
|
| 777 | - if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) { |
|
| 778 | - $v_path .= '/'; |
|
| 779 | - } |
|
| 780 | - $v_path .= $v_options[PCLZIP_OPT_ADD_PATH]; |
|
| 781 | - } |
|
| 782 | - } |
|
| 721 | + $v_path = ''; |
|
| 722 | + $v_remove_path = ""; |
|
| 723 | + $v_remove_all_path = false; |
|
| 724 | + |
|
| 725 | + // ----- Look for variable options arguments |
|
| 726 | + $v_size = func_num_args(); |
|
| 727 | + |
|
| 728 | + // ----- Default values for option |
|
| 729 | + $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE; |
|
| 730 | + |
|
| 731 | + // ----- Look for arguments |
|
| 732 | + if ($v_size > 0) { |
|
| 733 | + // ----- Get the arguments |
|
| 734 | + $v_arg_list = func_get_args(); |
|
| 735 | + |
|
| 736 | + // ----- Look for first arg |
|
| 737 | + if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) { |
|
| 738 | + |
|
| 739 | + // ----- Parse the options |
|
| 740 | + $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, |
|
| 741 | + array (PCLZIP_OPT_PATH => 'optional', |
|
| 742 | + PCLZIP_OPT_REMOVE_PATH => 'optional', |
|
| 743 | + PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', |
|
| 744 | + PCLZIP_OPT_ADD_PATH => 'optional', |
|
| 745 | + PCLZIP_CB_PRE_EXTRACT => 'optional', |
|
| 746 | + PCLZIP_CB_POST_EXTRACT => 'optional', |
|
| 747 | + PCLZIP_OPT_SET_CHMOD => 'optional', |
|
| 748 | + PCLZIP_OPT_BY_NAME => 'optional', |
|
| 749 | + PCLZIP_OPT_BY_EREG => 'optional', |
|
| 750 | + PCLZIP_OPT_BY_PREG => 'optional', |
|
| 751 | + PCLZIP_OPT_BY_INDEX => 'optional', |
|
| 752 | + PCLZIP_OPT_EXTRACT_AS_STRING => 'optional', |
|
| 753 | + PCLZIP_OPT_EXTRACT_IN_OUTPUT => 'optional', |
|
| 754 | + PCLZIP_OPT_REPLACE_NEWER => 'optional' |
|
| 755 | + ,PCLZIP_OPT_STOP_ON_ERROR => 'optional' |
|
| 756 | + ,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional', |
|
| 757 | + PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional', |
|
| 758 | + PCLZIP_OPT_TEMP_FILE_ON => 'optional', |
|
| 759 | + PCLZIP_OPT_TEMP_FILE_OFF => 'optional' |
|
| 760 | + )); |
|
| 761 | + if ($v_result != 1) { |
|
| 762 | + return 0; |
|
| 763 | + } |
|
| 764 | + |
|
| 765 | + // ----- Set the arguments |
|
| 766 | + if (isset($v_options[PCLZIP_OPT_PATH])) { |
|
| 767 | + $v_path = $v_options[PCLZIP_OPT_PATH]; |
|
| 768 | + } |
|
| 769 | + if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) { |
|
| 770 | + $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH]; |
|
| 771 | + } |
|
| 772 | + if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) { |
|
| 773 | + $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH]; |
|
| 774 | + } |
|
| 775 | + if (isset($v_options[PCLZIP_OPT_ADD_PATH])) { |
|
| 776 | + // ----- Check for '/' in last path char |
|
| 777 | + if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) { |
|
| 778 | + $v_path .= '/'; |
|
| 779 | + } |
|
| 780 | + $v_path .= $v_options[PCLZIP_OPT_ADD_PATH]; |
|
| 781 | + } |
|
| 782 | + } |
|
| 783 | 783 | |
| 784 | - // ----- Look for 2 args |
|
| 785 | - // Here we need to support the first historic synopsis of the |
|
| 786 | - // method. |
|
| 787 | - else { |
|
| 788 | - |
|
| 789 | - // ----- Get the first argument |
|
| 790 | - $v_path = $v_arg_list[0]; |
|
| 791 | - |
|
| 792 | - // ----- Look for the optional second argument |
|
| 793 | - if ($v_size == 2) { |
|
| 794 | - $v_remove_path = $v_arg_list[1]; |
|
| 795 | - } |
|
| 796 | - else if ($v_size > 2) { |
|
| 797 | - // ----- Error log |
|
| 798 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments"); |
|
| 799 | - |
|
| 800 | - // ----- Return |
|
| 801 | - return 0; |
|
| 802 | - } |
|
| 803 | - } |
|
| 804 | - } |
|
| 784 | + // ----- Look for 2 args |
|
| 785 | + // Here we need to support the first historic synopsis of the |
|
| 786 | + // method. |
|
| 787 | + else { |
|
| 788 | + |
|
| 789 | + // ----- Get the first argument |
|
| 790 | + $v_path = $v_arg_list[0]; |
|
| 791 | + |
|
| 792 | + // ----- Look for the optional second argument |
|
| 793 | + if ($v_size == 2) { |
|
| 794 | + $v_remove_path = $v_arg_list[1]; |
|
| 795 | + } |
|
| 796 | + else if ($v_size > 2) { |
|
| 797 | + // ----- Error log |
|
| 798 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments"); |
|
| 799 | + |
|
| 800 | + // ----- Return |
|
| 801 | + return 0; |
|
| 802 | + } |
|
| 803 | + } |
|
| 804 | + } |
|
| 805 | 805 | |
| 806 | - // ----- Look for default option values |
|
| 807 | - $this->privOptionDefaultThreshold($v_options); |
|
| 806 | + // ----- Look for default option values |
|
| 807 | + $this->privOptionDefaultThreshold($v_options); |
|
| 808 | 808 | |
| 809 | - // ----- Trace |
|
| 809 | + // ----- Trace |
|
| 810 | 810 | |
| 811 | - // ----- Call the extracting fct |
|
| 812 | - $p_list = array(); |
|
| 813 | - $v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path, |
|
| 814 | - $v_remove_all_path, $v_options); |
|
| 815 | - if ($v_result < 1) { |
|
| 816 | - unset($p_list); |
|
| 817 | - return(0); |
|
| 818 | - } |
|
| 811 | + // ----- Call the extracting fct |
|
| 812 | + $p_list = array(); |
|
| 813 | + $v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path, |
|
| 814 | + $v_remove_all_path, $v_options); |
|
| 815 | + if ($v_result < 1) { |
|
| 816 | + unset($p_list); |
|
| 817 | + return(0); |
|
| 818 | + } |
|
| 819 | 819 | |
| 820 | - // ----- Return |
|
| 821 | - return $p_list; |
|
| 820 | + // ----- Return |
|
| 821 | + return $p_list; |
|
| 822 | 822 | } |
| 823 | 823 | // -------------------------------------------------------------------------------- |
| 824 | 824 | |
@@ -862,132 +862,132 @@ discard block |
||
| 862 | 862 | //function extractByIndex($p_index, options...) |
| 863 | 863 | function extractByIndex($p_index) |
| 864 | 864 | { |
| 865 | - $v_result=1; |
|
| 865 | + $v_result=1; |
|
| 866 | 866 | |
| 867 | - // ----- Reset the error handler |
|
| 868 | - $this->privErrorReset(); |
|
| 867 | + // ----- Reset the error handler |
|
| 868 | + $this->privErrorReset(); |
|
| 869 | 869 | |
| 870 | - // ----- Check archive |
|
| 871 | - if (!$this->privCheckFormat()) { |
|
| 872 | - return(0); |
|
| 873 | - } |
|
| 870 | + // ----- Check archive |
|
| 871 | + if (!$this->privCheckFormat()) { |
|
| 872 | + return(0); |
|
| 873 | + } |
|
| 874 | 874 | |
| 875 | - // ----- Set default values |
|
| 876 | - $v_options = array(); |
|
| 875 | + // ----- Set default values |
|
| 876 | + $v_options = array(); |
|
| 877 | 877 | // $v_path = "./"; |
| 878 | - $v_path = ''; |
|
| 879 | - $v_remove_path = ""; |
|
| 880 | - $v_remove_all_path = false; |
|
| 881 | - |
|
| 882 | - // ----- Look for variable options arguments |
|
| 883 | - $v_size = func_num_args(); |
|
| 884 | - |
|
| 885 | - // ----- Default values for option |
|
| 886 | - $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE; |
|
| 887 | - |
|
| 888 | - // ----- Look for arguments |
|
| 889 | - if ($v_size > 1) { |
|
| 890 | - // ----- Get the arguments |
|
| 891 | - $v_arg_list = func_get_args(); |
|
| 892 | - |
|
| 893 | - // ----- Remove form the options list the first argument |
|
| 894 | - array_shift($v_arg_list); |
|
| 895 | - $v_size--; |
|
| 896 | - |
|
| 897 | - // ----- Look for first arg |
|
| 898 | - if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) { |
|
| 899 | - |
|
| 900 | - // ----- Parse the options |
|
| 901 | - $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, |
|
| 902 | - array (PCLZIP_OPT_PATH => 'optional', |
|
| 903 | - PCLZIP_OPT_REMOVE_PATH => 'optional', |
|
| 904 | - PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', |
|
| 905 | - PCLZIP_OPT_EXTRACT_AS_STRING => 'optional', |
|
| 906 | - PCLZIP_OPT_ADD_PATH => 'optional', |
|
| 907 | - PCLZIP_CB_PRE_EXTRACT => 'optional', |
|
| 908 | - PCLZIP_CB_POST_EXTRACT => 'optional', |
|
| 909 | - PCLZIP_OPT_SET_CHMOD => 'optional', |
|
| 910 | - PCLZIP_OPT_REPLACE_NEWER => 'optional' |
|
| 911 | - ,PCLZIP_OPT_STOP_ON_ERROR => 'optional' |
|
| 912 | - ,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional', |
|
| 913 | - PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional', |
|
| 914 | - PCLZIP_OPT_TEMP_FILE_ON => 'optional', |
|
| 915 | - PCLZIP_OPT_TEMP_FILE_OFF => 'optional' |
|
| 878 | + $v_path = ''; |
|
| 879 | + $v_remove_path = ""; |
|
| 880 | + $v_remove_all_path = false; |
|
| 881 | + |
|
| 882 | + // ----- Look for variable options arguments |
|
| 883 | + $v_size = func_num_args(); |
|
| 884 | + |
|
| 885 | + // ----- Default values for option |
|
| 886 | + $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE; |
|
| 887 | + |
|
| 888 | + // ----- Look for arguments |
|
| 889 | + if ($v_size > 1) { |
|
| 890 | + // ----- Get the arguments |
|
| 891 | + $v_arg_list = func_get_args(); |
|
| 892 | + |
|
| 893 | + // ----- Remove form the options list the first argument |
|
| 894 | + array_shift($v_arg_list); |
|
| 895 | + $v_size--; |
|
| 896 | + |
|
| 897 | + // ----- Look for first arg |
|
| 898 | + if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) { |
|
| 899 | + |
|
| 900 | + // ----- Parse the options |
|
| 901 | + $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, |
|
| 902 | + array (PCLZIP_OPT_PATH => 'optional', |
|
| 903 | + PCLZIP_OPT_REMOVE_PATH => 'optional', |
|
| 904 | + PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', |
|
| 905 | + PCLZIP_OPT_EXTRACT_AS_STRING => 'optional', |
|
| 906 | + PCLZIP_OPT_ADD_PATH => 'optional', |
|
| 907 | + PCLZIP_CB_PRE_EXTRACT => 'optional', |
|
| 908 | + PCLZIP_CB_POST_EXTRACT => 'optional', |
|
| 909 | + PCLZIP_OPT_SET_CHMOD => 'optional', |
|
| 910 | + PCLZIP_OPT_REPLACE_NEWER => 'optional' |
|
| 911 | + ,PCLZIP_OPT_STOP_ON_ERROR => 'optional' |
|
| 912 | + ,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional', |
|
| 913 | + PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional', |
|
| 914 | + PCLZIP_OPT_TEMP_FILE_ON => 'optional', |
|
| 915 | + PCLZIP_OPT_TEMP_FILE_OFF => 'optional' |
|
| 916 | 916 | )); |
| 917 | - if ($v_result != 1) { |
|
| 918 | - return 0; |
|
| 919 | - } |
|
| 920 | - |
|
| 921 | - // ----- Set the arguments |
|
| 922 | - if (isset($v_options[PCLZIP_OPT_PATH])) { |
|
| 923 | - $v_path = $v_options[PCLZIP_OPT_PATH]; |
|
| 924 | - } |
|
| 925 | - if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) { |
|
| 926 | - $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH]; |
|
| 927 | - } |
|
| 928 | - if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) { |
|
| 929 | - $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH]; |
|
| 930 | - } |
|
| 931 | - if (isset($v_options[PCLZIP_OPT_ADD_PATH])) { |
|
| 932 | - // ----- Check for '/' in last path char |
|
| 933 | - if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) { |
|
| 934 | - $v_path .= '/'; |
|
| 935 | - } |
|
| 936 | - $v_path .= $v_options[PCLZIP_OPT_ADD_PATH]; |
|
| 937 | - } |
|
| 938 | - if (!isset($v_options[PCLZIP_OPT_EXTRACT_AS_STRING])) { |
|
| 939 | - $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE; |
|
| 940 | - } |
|
| 941 | - else { |
|
| 942 | - } |
|
| 943 | - } |
|
| 917 | + if ($v_result != 1) { |
|
| 918 | + return 0; |
|
| 919 | + } |
|
| 920 | + |
|
| 921 | + // ----- Set the arguments |
|
| 922 | + if (isset($v_options[PCLZIP_OPT_PATH])) { |
|
| 923 | + $v_path = $v_options[PCLZIP_OPT_PATH]; |
|
| 924 | + } |
|
| 925 | + if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) { |
|
| 926 | + $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH]; |
|
| 927 | + } |
|
| 928 | + if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) { |
|
| 929 | + $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH]; |
|
| 930 | + } |
|
| 931 | + if (isset($v_options[PCLZIP_OPT_ADD_PATH])) { |
|
| 932 | + // ----- Check for '/' in last path char |
|
| 933 | + if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) { |
|
| 934 | + $v_path .= '/'; |
|
| 935 | + } |
|
| 936 | + $v_path .= $v_options[PCLZIP_OPT_ADD_PATH]; |
|
| 937 | + } |
|
| 938 | + if (!isset($v_options[PCLZIP_OPT_EXTRACT_AS_STRING])) { |
|
| 939 | + $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE; |
|
| 940 | + } |
|
| 941 | + else { |
|
| 942 | + } |
|
| 943 | + } |
|
| 944 | 944 | |
| 945 | - // ----- Look for 2 args |
|
| 946 | - // Here we need to support the first historic synopsis of the |
|
| 947 | - // method. |
|
| 948 | - else { |
|
| 949 | - |
|
| 950 | - // ----- Get the first argument |
|
| 951 | - $v_path = $v_arg_list[0]; |
|
| 952 | - |
|
| 953 | - // ----- Look for the optional second argument |
|
| 954 | - if ($v_size == 2) { |
|
| 955 | - $v_remove_path = $v_arg_list[1]; |
|
| 956 | - } |
|
| 957 | - else if ($v_size > 2) { |
|
| 958 | - // ----- Error log |
|
| 959 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments"); |
|
| 960 | - |
|
| 961 | - // ----- Return |
|
| 962 | - return 0; |
|
| 963 | - } |
|
| 964 | - } |
|
| 965 | - } |
|
| 945 | + // ----- Look for 2 args |
|
| 946 | + // Here we need to support the first historic synopsis of the |
|
| 947 | + // method. |
|
| 948 | + else { |
|
| 949 | + |
|
| 950 | + // ----- Get the first argument |
|
| 951 | + $v_path = $v_arg_list[0]; |
|
| 952 | + |
|
| 953 | + // ----- Look for the optional second argument |
|
| 954 | + if ($v_size == 2) { |
|
| 955 | + $v_remove_path = $v_arg_list[1]; |
|
| 956 | + } |
|
| 957 | + else if ($v_size > 2) { |
|
| 958 | + // ----- Error log |
|
| 959 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments"); |
|
| 960 | + |
|
| 961 | + // ----- Return |
|
| 962 | + return 0; |
|
| 963 | + } |
|
| 964 | + } |
|
| 965 | + } |
|
| 966 | 966 | |
| 967 | - // ----- Trace |
|
| 968 | - |
|
| 969 | - // ----- Trick |
|
| 970 | - // Here I want to reuse extractByRule(), so I need to parse the $p_index |
|
| 971 | - // with privParseOptions() |
|
| 972 | - $v_arg_trick = array (PCLZIP_OPT_BY_INDEX, $p_index); |
|
| 973 | - $v_options_trick = array(); |
|
| 974 | - $v_result = $this->privParseOptions($v_arg_trick, sizeof($v_arg_trick), $v_options_trick, |
|
| 975 | - array (PCLZIP_OPT_BY_INDEX => 'optional' )); |
|
| 976 | - if ($v_result != 1) { |
|
| 977 | - return 0; |
|
| 978 | - } |
|
| 979 | - $v_options[PCLZIP_OPT_BY_INDEX] = $v_options_trick[PCLZIP_OPT_BY_INDEX]; |
|
| 967 | + // ----- Trace |
|
| 968 | + |
|
| 969 | + // ----- Trick |
|
| 970 | + // Here I want to reuse extractByRule(), so I need to parse the $p_index |
|
| 971 | + // with privParseOptions() |
|
| 972 | + $v_arg_trick = array (PCLZIP_OPT_BY_INDEX, $p_index); |
|
| 973 | + $v_options_trick = array(); |
|
| 974 | + $v_result = $this->privParseOptions($v_arg_trick, sizeof($v_arg_trick), $v_options_trick, |
|
| 975 | + array (PCLZIP_OPT_BY_INDEX => 'optional' )); |
|
| 976 | + if ($v_result != 1) { |
|
| 977 | + return 0; |
|
| 978 | + } |
|
| 979 | + $v_options[PCLZIP_OPT_BY_INDEX] = $v_options_trick[PCLZIP_OPT_BY_INDEX]; |
|
| 980 | 980 | |
| 981 | - // ----- Look for default option values |
|
| 982 | - $this->privOptionDefaultThreshold($v_options); |
|
| 981 | + // ----- Look for default option values |
|
| 982 | + $this->privOptionDefaultThreshold($v_options); |
|
| 983 | 983 | |
| 984 | - // ----- Call the extracting fct |
|
| 985 | - if (($v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path, $v_remove_all_path, $v_options)) < 1) { |
|
| 986 | - return(0); |
|
| 987 | - } |
|
| 984 | + // ----- Call the extracting fct |
|
| 985 | + if (($v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path, $v_remove_all_path, $v_options)) < 1) { |
|
| 986 | + return(0); |
|
| 987 | + } |
|
| 988 | 988 | |
| 989 | - // ----- Return |
|
| 990 | - return $p_list; |
|
| 989 | + // ----- Return |
|
| 990 | + return $p_list; |
|
| 991 | 991 | } |
| 992 | 992 | // -------------------------------------------------------------------------------- |
| 993 | 993 | |
@@ -1011,54 +1011,54 @@ discard block |
||
| 1011 | 1011 | // -------------------------------------------------------------------------------- |
| 1012 | 1012 | function delete() |
| 1013 | 1013 | { |
| 1014 | - $v_result=1; |
|
| 1014 | + $v_result=1; |
|
| 1015 | 1015 | |
| 1016 | - // ----- Reset the error handler |
|
| 1017 | - $this->privErrorReset(); |
|
| 1016 | + // ----- Reset the error handler |
|
| 1017 | + $this->privErrorReset(); |
|
| 1018 | 1018 | |
| 1019 | - // ----- Check archive |
|
| 1020 | - if (!$this->privCheckFormat()) { |
|
| 1021 | - return(0); |
|
| 1022 | - } |
|
| 1019 | + // ----- Check archive |
|
| 1020 | + if (!$this->privCheckFormat()) { |
|
| 1021 | + return(0); |
|
| 1022 | + } |
|
| 1023 | 1023 | |
| 1024 | - // ----- Set default values |
|
| 1025 | - $v_options = array(); |
|
| 1026 | - |
|
| 1027 | - // ----- Look for variable options arguments |
|
| 1028 | - $v_size = func_num_args(); |
|
| 1029 | - |
|
| 1030 | - // ----- Look for arguments |
|
| 1031 | - if ($v_size > 0) { |
|
| 1032 | - // ----- Get the arguments |
|
| 1033 | - $v_arg_list = func_get_args(); |
|
| 1034 | - |
|
| 1035 | - // ----- Parse the options |
|
| 1036 | - $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, |
|
| 1037 | - array (PCLZIP_OPT_BY_NAME => 'optional', |
|
| 1038 | - PCLZIP_OPT_BY_EREG => 'optional', |
|
| 1039 | - PCLZIP_OPT_BY_PREG => 'optional', |
|
| 1040 | - PCLZIP_OPT_BY_INDEX => 'optional' )); |
|
| 1041 | - if ($v_result != 1) { |
|
| 1042 | - return 0; |
|
| 1043 | - } |
|
| 1044 | - } |
|
| 1024 | + // ----- Set default values |
|
| 1025 | + $v_options = array(); |
|
| 1026 | + |
|
| 1027 | + // ----- Look for variable options arguments |
|
| 1028 | + $v_size = func_num_args(); |
|
| 1029 | + |
|
| 1030 | + // ----- Look for arguments |
|
| 1031 | + if ($v_size > 0) { |
|
| 1032 | + // ----- Get the arguments |
|
| 1033 | + $v_arg_list = func_get_args(); |
|
| 1034 | + |
|
| 1035 | + // ----- Parse the options |
|
| 1036 | + $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, |
|
| 1037 | + array (PCLZIP_OPT_BY_NAME => 'optional', |
|
| 1038 | + PCLZIP_OPT_BY_EREG => 'optional', |
|
| 1039 | + PCLZIP_OPT_BY_PREG => 'optional', |
|
| 1040 | + PCLZIP_OPT_BY_INDEX => 'optional' )); |
|
| 1041 | + if ($v_result != 1) { |
|
| 1042 | + return 0; |
|
| 1043 | + } |
|
| 1044 | + } |
|
| 1045 | 1045 | |
| 1046 | - // ----- Magic quotes trick |
|
| 1047 | - $this->privDisableMagicQuotes(); |
|
| 1046 | + // ----- Magic quotes trick |
|
| 1047 | + $this->privDisableMagicQuotes(); |
|
| 1048 | 1048 | |
| 1049 | - // ----- Call the delete fct |
|
| 1050 | - $v_list = array(); |
|
| 1051 | - if (($v_result = $this->privDeleteByRule($v_list, $v_options)) != 1) { |
|
| 1052 | - $this->privSwapBackMagicQuotes(); |
|
| 1053 | - unset($v_list); |
|
| 1054 | - return(0); |
|
| 1055 | - } |
|
| 1049 | + // ----- Call the delete fct |
|
| 1050 | + $v_list = array(); |
|
| 1051 | + if (($v_result = $this->privDeleteByRule($v_list, $v_options)) != 1) { |
|
| 1052 | + $this->privSwapBackMagicQuotes(); |
|
| 1053 | + unset($v_list); |
|
| 1054 | + return(0); |
|
| 1055 | + } |
|
| 1056 | 1056 | |
| 1057 | - // ----- Magic quotes trick |
|
| 1058 | - $this->privSwapBackMagicQuotes(); |
|
| 1057 | + // ----- Magic quotes trick |
|
| 1058 | + $this->privSwapBackMagicQuotes(); |
|
| 1059 | 1059 | |
| 1060 | - // ----- Return |
|
| 1061 | - return $v_list; |
|
| 1060 | + // ----- Return |
|
| 1061 | + return $v_list; |
|
| 1062 | 1062 | } |
| 1063 | 1063 | // -------------------------------------------------------------------------------- |
| 1064 | 1064 | |
@@ -1071,10 +1071,10 @@ discard block |
||
| 1071 | 1071 | function deleteByIndex($p_index) |
| 1072 | 1072 | { |
| 1073 | 1073 | |
| 1074 | - $p_list = $this->delete(PCLZIP_OPT_BY_INDEX, $p_index); |
|
| 1074 | + $p_list = $this->delete(PCLZIP_OPT_BY_INDEX, $p_index); |
|
| 1075 | 1075 | |
| 1076 | - // ----- Return |
|
| 1077 | - return $p_list; |
|
| 1076 | + // ----- Return |
|
| 1077 | + return $p_list; |
|
| 1078 | 1078 | } |
| 1079 | 1079 | // -------------------------------------------------------------------------------- |
| 1080 | 1080 | |
@@ -1095,61 +1095,61 @@ discard block |
||
| 1095 | 1095 | function properties() |
| 1096 | 1096 | { |
| 1097 | 1097 | |
| 1098 | - // ----- Reset the error handler |
|
| 1099 | - $this->privErrorReset(); |
|
| 1098 | + // ----- Reset the error handler |
|
| 1099 | + $this->privErrorReset(); |
|
| 1100 | 1100 | |
| 1101 | - // ----- Magic quotes trick |
|
| 1102 | - $this->privDisableMagicQuotes(); |
|
| 1101 | + // ----- Magic quotes trick |
|
| 1102 | + $this->privDisableMagicQuotes(); |
|
| 1103 | 1103 | |
| 1104 | - // ----- Check archive |
|
| 1105 | - if (!$this->privCheckFormat()) { |
|
| 1106 | - $this->privSwapBackMagicQuotes(); |
|
| 1107 | - return(0); |
|
| 1108 | - } |
|
| 1104 | + // ----- Check archive |
|
| 1105 | + if (!$this->privCheckFormat()) { |
|
| 1106 | + $this->privSwapBackMagicQuotes(); |
|
| 1107 | + return(0); |
|
| 1108 | + } |
|
| 1109 | 1109 | |
| 1110 | - // ----- Default properties |
|
| 1111 | - $v_prop = array(); |
|
| 1112 | - $v_prop['comment'] = ''; |
|
| 1113 | - $v_prop['nb'] = 0; |
|
| 1114 | - $v_prop['status'] = 'not_exist'; |
|
| 1115 | - |
|
| 1116 | - // ----- Look if file exists |
|
| 1117 | - if (@is_file($this->zipname)) |
|
| 1118 | - { |
|
| 1119 | - // ----- Open the zip file |
|
| 1120 | - if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0) |
|
| 1121 | - { |
|
| 1122 | - $this->privSwapBackMagicQuotes(); |
|
| 1110 | + // ----- Default properties |
|
| 1111 | + $v_prop = array(); |
|
| 1112 | + $v_prop['comment'] = ''; |
|
| 1113 | + $v_prop['nb'] = 0; |
|
| 1114 | + $v_prop['status'] = 'not_exist'; |
|
| 1115 | + |
|
| 1116 | + // ----- Look if file exists |
|
| 1117 | + if (@is_file($this->zipname)) |
|
| 1118 | + { |
|
| 1119 | + // ----- Open the zip file |
|
| 1120 | + if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0) |
|
| 1121 | + { |
|
| 1122 | + $this->privSwapBackMagicQuotes(); |
|
| 1123 | 1123 | |
| 1124 | - // ----- Error log |
|
| 1125 | - PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode'); |
|
| 1124 | + // ----- Error log |
|
| 1125 | + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode'); |
|
| 1126 | 1126 | |
| 1127 | - // ----- Return |
|
| 1128 | - return 0; |
|
| 1129 | - } |
|
| 1127 | + // ----- Return |
|
| 1128 | + return 0; |
|
| 1129 | + } |
|
| 1130 | 1130 | |
| 1131 | - // ----- Read the central directory informations |
|
| 1132 | - $v_central_dir = array(); |
|
| 1133 | - if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) |
|
| 1134 | - { |
|
| 1135 | - $this->privSwapBackMagicQuotes(); |
|
| 1136 | - return 0; |
|
| 1137 | - } |
|
| 1131 | + // ----- Read the central directory informations |
|
| 1132 | + $v_central_dir = array(); |
|
| 1133 | + if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) |
|
| 1134 | + { |
|
| 1135 | + $this->privSwapBackMagicQuotes(); |
|
| 1136 | + return 0; |
|
| 1137 | + } |
|
| 1138 | 1138 | |
| 1139 | - // ----- Close the zip file |
|
| 1140 | - $this->privCloseFd(); |
|
| 1139 | + // ----- Close the zip file |
|
| 1140 | + $this->privCloseFd(); |
|
| 1141 | 1141 | |
| 1142 | - // ----- Set the user attributes |
|
| 1143 | - $v_prop['comment'] = $v_central_dir['comment']; |
|
| 1144 | - $v_prop['nb'] = $v_central_dir['entries']; |
|
| 1145 | - $v_prop['status'] = 'ok'; |
|
| 1146 | - } |
|
| 1142 | + // ----- Set the user attributes |
|
| 1143 | + $v_prop['comment'] = $v_central_dir['comment']; |
|
| 1144 | + $v_prop['nb'] = $v_central_dir['entries']; |
|
| 1145 | + $v_prop['status'] = 'ok'; |
|
| 1146 | + } |
|
| 1147 | 1147 | |
| 1148 | - // ----- Magic quotes trick |
|
| 1149 | - $this->privSwapBackMagicQuotes(); |
|
| 1148 | + // ----- Magic quotes trick |
|
| 1149 | + $this->privSwapBackMagicQuotes(); |
|
| 1150 | 1150 | |
| 1151 | - // ----- Return |
|
| 1152 | - return $v_prop; |
|
| 1151 | + // ----- Return |
|
| 1152 | + return $v_prop; |
|
| 1153 | 1153 | } |
| 1154 | 1154 | // -------------------------------------------------------------------------------- |
| 1155 | 1155 | |
@@ -1167,46 +1167,46 @@ discard block |
||
| 1167 | 1167 | // -------------------------------------------------------------------------------- |
| 1168 | 1168 | function duplicate($p_archive) |
| 1169 | 1169 | { |
| 1170 | - $v_result = 1; |
|
| 1170 | + $v_result = 1; |
|
| 1171 | 1171 | |
| 1172 | - // ----- Reset the error handler |
|
| 1173 | - $this->privErrorReset(); |
|
| 1172 | + // ----- Reset the error handler |
|
| 1173 | + $this->privErrorReset(); |
|
| 1174 | 1174 | |
| 1175 | - // ----- Look if the $p_archive is a PclZip object |
|
| 1176 | - if ((is_object($p_archive)) && (get_class($p_archive) == 'pclzip')) |
|
| 1177 | - { |
|
| 1175 | + // ----- Look if the $p_archive is a PclZip object |
|
| 1176 | + if ((is_object($p_archive)) && (get_class($p_archive) == 'pclzip')) |
|
| 1177 | + { |
|
| 1178 | 1178 | |
| 1179 | - // ----- Duplicate the archive |
|
| 1180 | - $v_result = $this->privDuplicate($p_archive->zipname); |
|
| 1181 | - } |
|
| 1179 | + // ----- Duplicate the archive |
|
| 1180 | + $v_result = $this->privDuplicate($p_archive->zipname); |
|
| 1181 | + } |
|
| 1182 | 1182 | |
| 1183 | - // ----- Look if the $p_archive is a string (so a filename) |
|
| 1184 | - else if (is_string($p_archive)) |
|
| 1185 | - { |
|
| 1183 | + // ----- Look if the $p_archive is a string (so a filename) |
|
| 1184 | + else if (is_string($p_archive)) |
|
| 1185 | + { |
|
| 1186 | 1186 | |
| 1187 | - // ----- Check that $p_archive is a valid zip file |
|
| 1188 | - // TBC : Should also check the archive format |
|
| 1189 | - if (!is_file($p_archive)) { |
|
| 1190 | - // ----- Error log |
|
| 1191 | - PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "No file with filename '".$p_archive."'"); |
|
| 1192 | - $v_result = PCLZIP_ERR_MISSING_FILE; |
|
| 1193 | - } |
|
| 1194 | - else { |
|
| 1195 | - // ----- Duplicate the archive |
|
| 1196 | - $v_result = $this->privDuplicate($p_archive); |
|
| 1197 | - } |
|
| 1198 | - } |
|
| 1187 | + // ----- Check that $p_archive is a valid zip file |
|
| 1188 | + // TBC : Should also check the archive format |
|
| 1189 | + if (!is_file($p_archive)) { |
|
| 1190 | + // ----- Error log |
|
| 1191 | + PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "No file with filename '".$p_archive."'"); |
|
| 1192 | + $v_result = PCLZIP_ERR_MISSING_FILE; |
|
| 1193 | + } |
|
| 1194 | + else { |
|
| 1195 | + // ----- Duplicate the archive |
|
| 1196 | + $v_result = $this->privDuplicate($p_archive); |
|
| 1197 | + } |
|
| 1198 | + } |
|
| 1199 | 1199 | |
| 1200 | - // ----- Invalid variable |
|
| 1201 | - else |
|
| 1202 | - { |
|
| 1203 | - // ----- Error log |
|
| 1204 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add"); |
|
| 1205 | - $v_result = PCLZIP_ERR_INVALID_PARAMETER; |
|
| 1206 | - } |
|
| 1200 | + // ----- Invalid variable |
|
| 1201 | + else |
|
| 1202 | + { |
|
| 1203 | + // ----- Error log |
|
| 1204 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add"); |
|
| 1205 | + $v_result = PCLZIP_ERR_INVALID_PARAMETER; |
|
| 1206 | + } |
|
| 1207 | 1207 | |
| 1208 | - // ----- Return |
|
| 1209 | - return $v_result; |
|
| 1208 | + // ----- Return |
|
| 1209 | + return $v_result; |
|
| 1210 | 1210 | } |
| 1211 | 1211 | // -------------------------------------------------------------------------------- |
| 1212 | 1212 | |
@@ -1226,45 +1226,45 @@ discard block |
||
| 1226 | 1226 | // -------------------------------------------------------------------------------- |
| 1227 | 1227 | function merge($p_archive_to_add) |
| 1228 | 1228 | { |
| 1229 | - $v_result = 1; |
|
| 1229 | + $v_result = 1; |
|
| 1230 | 1230 | |
| 1231 | - // ----- Reset the error handler |
|
| 1232 | - $this->privErrorReset(); |
|
| 1231 | + // ----- Reset the error handler |
|
| 1232 | + $this->privErrorReset(); |
|
| 1233 | 1233 | |
| 1234 | - // ----- Check archive |
|
| 1235 | - if (!$this->privCheckFormat()) { |
|
| 1236 | - return(0); |
|
| 1237 | - } |
|
| 1234 | + // ----- Check archive |
|
| 1235 | + if (!$this->privCheckFormat()) { |
|
| 1236 | + return(0); |
|
| 1237 | + } |
|
| 1238 | 1238 | |
| 1239 | - // ----- Look if the $p_archive_to_add is a PclZip object |
|
| 1240 | - if ((is_object($p_archive_to_add)) && (get_class($p_archive_to_add) == 'pclzip')) |
|
| 1241 | - { |
|
| 1239 | + // ----- Look if the $p_archive_to_add is a PclZip object |
|
| 1240 | + if ((is_object($p_archive_to_add)) && (get_class($p_archive_to_add) == 'pclzip')) |
|
| 1241 | + { |
|
| 1242 | 1242 | |
| 1243 | - // ----- Merge the archive |
|
| 1244 | - $v_result = $this->privMerge($p_archive_to_add); |
|
| 1245 | - } |
|
| 1243 | + // ----- Merge the archive |
|
| 1244 | + $v_result = $this->privMerge($p_archive_to_add); |
|
| 1245 | + } |
|
| 1246 | 1246 | |
| 1247 | - // ----- Look if the $p_archive_to_add is a string (so a filename) |
|
| 1248 | - else if (is_string($p_archive_to_add)) |
|
| 1249 | - { |
|
| 1247 | + // ----- Look if the $p_archive_to_add is a string (so a filename) |
|
| 1248 | + else if (is_string($p_archive_to_add)) |
|
| 1249 | + { |
|
| 1250 | 1250 | |
| 1251 | - // ----- Create a temporary archive |
|
| 1252 | - $v_object_archive = new PclZip($p_archive_to_add); |
|
| 1251 | + // ----- Create a temporary archive |
|
| 1252 | + $v_object_archive = new PclZip($p_archive_to_add); |
|
| 1253 | 1253 | |
| 1254 | - // ----- Merge the archive |
|
| 1255 | - $v_result = $this->privMerge($v_object_archive); |
|
| 1256 | - } |
|
| 1254 | + // ----- Merge the archive |
|
| 1255 | + $v_result = $this->privMerge($v_object_archive); |
|
| 1256 | + } |
|
| 1257 | 1257 | |
| 1258 | - // ----- Invalid variable |
|
| 1259 | - else |
|
| 1260 | - { |
|
| 1261 | - // ----- Error log |
|
| 1262 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add"); |
|
| 1263 | - $v_result = PCLZIP_ERR_INVALID_PARAMETER; |
|
| 1264 | - } |
|
| 1258 | + // ----- Invalid variable |
|
| 1259 | + else |
|
| 1260 | + { |
|
| 1261 | + // ----- Error log |
|
| 1262 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add"); |
|
| 1263 | + $v_result = PCLZIP_ERR_INVALID_PARAMETER; |
|
| 1264 | + } |
|
| 1265 | 1265 | |
| 1266 | - // ----- Return |
|
| 1267 | - return $v_result; |
|
| 1266 | + // ----- Return |
|
| 1267 | + return $v_result; |
|
| 1268 | 1268 | } |
| 1269 | 1269 | // -------------------------------------------------------------------------------- |
| 1270 | 1270 | |
@@ -1277,12 +1277,12 @@ discard block |
||
| 1277 | 1277 | // -------------------------------------------------------------------------------- |
| 1278 | 1278 | function errorCode() |
| 1279 | 1279 | { |
| 1280 | - if (PCLZIP_ERROR_EXTERNAL == 1) { |
|
| 1281 | - return(PclErrorCode()); |
|
| 1282 | - } |
|
| 1283 | - else { |
|
| 1284 | - return($this->error_code); |
|
| 1285 | - } |
|
| 1280 | + if (PCLZIP_ERROR_EXTERNAL == 1) { |
|
| 1281 | + return(PclErrorCode()); |
|
| 1282 | + } |
|
| 1283 | + else { |
|
| 1284 | + return($this->error_code); |
|
| 1285 | + } |
|
| 1286 | 1286 | } |
| 1287 | 1287 | // -------------------------------------------------------------------------------- |
| 1288 | 1288 | |
@@ -1293,42 +1293,42 @@ discard block |
||
| 1293 | 1293 | // -------------------------------------------------------------------------------- |
| 1294 | 1294 | function errorName($p_with_code=false) |
| 1295 | 1295 | { |
| 1296 | - $v_name = array ( PCLZIP_ERR_NO_ERROR => 'PCLZIP_ERR_NO_ERROR', |
|
| 1297 | - PCLZIP_ERR_WRITE_OPEN_FAIL => 'PCLZIP_ERR_WRITE_OPEN_FAIL', |
|
| 1298 | - PCLZIP_ERR_READ_OPEN_FAIL => 'PCLZIP_ERR_READ_OPEN_FAIL', |
|
| 1299 | - PCLZIP_ERR_INVALID_PARAMETER => 'PCLZIP_ERR_INVALID_PARAMETER', |
|
| 1300 | - PCLZIP_ERR_MISSING_FILE => 'PCLZIP_ERR_MISSING_FILE', |
|
| 1301 | - PCLZIP_ERR_FILENAME_TOO_LONG => 'PCLZIP_ERR_FILENAME_TOO_LONG', |
|
| 1302 | - PCLZIP_ERR_INVALID_ZIP => 'PCLZIP_ERR_INVALID_ZIP', |
|
| 1303 | - PCLZIP_ERR_BAD_EXTRACTED_FILE => 'PCLZIP_ERR_BAD_EXTRACTED_FILE', |
|
| 1304 | - PCLZIP_ERR_DIR_CREATE_FAIL => 'PCLZIP_ERR_DIR_CREATE_FAIL', |
|
| 1305 | - PCLZIP_ERR_BAD_EXTENSION => 'PCLZIP_ERR_BAD_EXTENSION', |
|
| 1306 | - PCLZIP_ERR_BAD_FORMAT => 'PCLZIP_ERR_BAD_FORMAT', |
|
| 1307 | - PCLZIP_ERR_DELETE_FILE_FAIL => 'PCLZIP_ERR_DELETE_FILE_FAIL', |
|
| 1308 | - PCLZIP_ERR_RENAME_FILE_FAIL => 'PCLZIP_ERR_RENAME_FILE_FAIL', |
|
| 1309 | - PCLZIP_ERR_BAD_CHECKSUM => 'PCLZIP_ERR_BAD_CHECKSUM', |
|
| 1310 | - PCLZIP_ERR_INVALID_ARCHIVE_ZIP => 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP', |
|
| 1311 | - PCLZIP_ERR_MISSING_OPTION_VALUE => 'PCLZIP_ERR_MISSING_OPTION_VALUE', |
|
| 1312 | - PCLZIP_ERR_INVALID_OPTION_VALUE => 'PCLZIP_ERR_INVALID_OPTION_VALUE', |
|
| 1313 | - PCLZIP_ERR_UNSUPPORTED_COMPRESSION => 'PCLZIP_ERR_UNSUPPORTED_COMPRESSION', |
|
| 1314 | - PCLZIP_ERR_UNSUPPORTED_ENCRYPTION => 'PCLZIP_ERR_UNSUPPORTED_ENCRYPTION' |
|
| 1315 | - ,PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE => 'PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE' |
|
| 1316 | - ,PCLZIP_ERR_DIRECTORY_RESTRICTION => 'PCLZIP_ERR_DIRECTORY_RESTRICTION' |
|
| 1317 | - ); |
|
| 1318 | - |
|
| 1319 | - if (isset($v_name[$this->error_code])) { |
|
| 1320 | - $v_value = $v_name[$this->error_code]; |
|
| 1321 | - } |
|
| 1322 | - else { |
|
| 1323 | - $v_value = 'NoName'; |
|
| 1324 | - } |
|
| 1296 | + $v_name = array ( PCLZIP_ERR_NO_ERROR => 'PCLZIP_ERR_NO_ERROR', |
|
| 1297 | + PCLZIP_ERR_WRITE_OPEN_FAIL => 'PCLZIP_ERR_WRITE_OPEN_FAIL', |
|
| 1298 | + PCLZIP_ERR_READ_OPEN_FAIL => 'PCLZIP_ERR_READ_OPEN_FAIL', |
|
| 1299 | + PCLZIP_ERR_INVALID_PARAMETER => 'PCLZIP_ERR_INVALID_PARAMETER', |
|
| 1300 | + PCLZIP_ERR_MISSING_FILE => 'PCLZIP_ERR_MISSING_FILE', |
|
| 1301 | + PCLZIP_ERR_FILENAME_TOO_LONG => 'PCLZIP_ERR_FILENAME_TOO_LONG', |
|
| 1302 | + PCLZIP_ERR_INVALID_ZIP => 'PCLZIP_ERR_INVALID_ZIP', |
|
| 1303 | + PCLZIP_ERR_BAD_EXTRACTED_FILE => 'PCLZIP_ERR_BAD_EXTRACTED_FILE', |
|
| 1304 | + PCLZIP_ERR_DIR_CREATE_FAIL => 'PCLZIP_ERR_DIR_CREATE_FAIL', |
|
| 1305 | + PCLZIP_ERR_BAD_EXTENSION => 'PCLZIP_ERR_BAD_EXTENSION', |
|
| 1306 | + PCLZIP_ERR_BAD_FORMAT => 'PCLZIP_ERR_BAD_FORMAT', |
|
| 1307 | + PCLZIP_ERR_DELETE_FILE_FAIL => 'PCLZIP_ERR_DELETE_FILE_FAIL', |
|
| 1308 | + PCLZIP_ERR_RENAME_FILE_FAIL => 'PCLZIP_ERR_RENAME_FILE_FAIL', |
|
| 1309 | + PCLZIP_ERR_BAD_CHECKSUM => 'PCLZIP_ERR_BAD_CHECKSUM', |
|
| 1310 | + PCLZIP_ERR_INVALID_ARCHIVE_ZIP => 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP', |
|
| 1311 | + PCLZIP_ERR_MISSING_OPTION_VALUE => 'PCLZIP_ERR_MISSING_OPTION_VALUE', |
|
| 1312 | + PCLZIP_ERR_INVALID_OPTION_VALUE => 'PCLZIP_ERR_INVALID_OPTION_VALUE', |
|
| 1313 | + PCLZIP_ERR_UNSUPPORTED_COMPRESSION => 'PCLZIP_ERR_UNSUPPORTED_COMPRESSION', |
|
| 1314 | + PCLZIP_ERR_UNSUPPORTED_ENCRYPTION => 'PCLZIP_ERR_UNSUPPORTED_ENCRYPTION' |
|
| 1315 | + ,PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE => 'PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE' |
|
| 1316 | + ,PCLZIP_ERR_DIRECTORY_RESTRICTION => 'PCLZIP_ERR_DIRECTORY_RESTRICTION' |
|
| 1317 | + ); |
|
| 1318 | + |
|
| 1319 | + if (isset($v_name[$this->error_code])) { |
|
| 1320 | + $v_value = $v_name[$this->error_code]; |
|
| 1321 | + } |
|
| 1322 | + else { |
|
| 1323 | + $v_value = 'NoName'; |
|
| 1324 | + } |
|
| 1325 | 1325 | |
| 1326 | - if ($p_with_code) { |
|
| 1327 | - return($v_value.' ('.$this->error_code.')'); |
|
| 1328 | - } |
|
| 1329 | - else { |
|
| 1330 | - return($v_value); |
|
| 1331 | - } |
|
| 1326 | + if ($p_with_code) { |
|
| 1327 | + return($v_value.' ('.$this->error_code.')'); |
|
| 1328 | + } |
|
| 1329 | + else { |
|
| 1330 | + return($v_value); |
|
| 1331 | + } |
|
| 1332 | 1332 | } |
| 1333 | 1333 | // -------------------------------------------------------------------------------- |
| 1334 | 1334 | |
@@ -1339,17 +1339,17 @@ discard block |
||
| 1339 | 1339 | // -------------------------------------------------------------------------------- |
| 1340 | 1340 | function errorInfo($p_full=false) |
| 1341 | 1341 | { |
| 1342 | - if (PCLZIP_ERROR_EXTERNAL == 1) { |
|
| 1343 | - return(PclErrorString()); |
|
| 1344 | - } |
|
| 1345 | - else { |
|
| 1346 | - if ($p_full) { |
|
| 1347 | - return($this->errorName(true)." : ".$this->error_string); |
|
| 1348 | - } |
|
| 1349 | - else { |
|
| 1350 | - return($this->error_string." [code ".$this->error_code."]"); |
|
| 1351 | - } |
|
| 1352 | - } |
|
| 1342 | + if (PCLZIP_ERROR_EXTERNAL == 1) { |
|
| 1343 | + return(PclErrorString()); |
|
| 1344 | + } |
|
| 1345 | + else { |
|
| 1346 | + if ($p_full) { |
|
| 1347 | + return($this->errorName(true)." : ".$this->error_string); |
|
| 1348 | + } |
|
| 1349 | + else { |
|
| 1350 | + return($this->error_string." [code ".$this->error_code."]"); |
|
| 1351 | + } |
|
| 1352 | + } |
|
| 1353 | 1353 | } |
| 1354 | 1354 | // -------------------------------------------------------------------------------- |
| 1355 | 1355 | |
@@ -1378,39 +1378,39 @@ discard block |
||
| 1378 | 1378 | // -------------------------------------------------------------------------------- |
| 1379 | 1379 | function privCheckFormat($p_level=0) |
| 1380 | 1380 | { |
| 1381 | - $v_result = true; |
|
| 1381 | + $v_result = true; |
|
| 1382 | 1382 | |
| 1383 | 1383 | // ----- Reset the file system cache |
| 1384 | - clearstatcache(); |
|
| 1384 | + clearstatcache(); |
|
| 1385 | 1385 | |
| 1386 | - // ----- Reset the error handler |
|
| 1387 | - $this->privErrorReset(); |
|
| 1386 | + // ----- Reset the error handler |
|
| 1387 | + $this->privErrorReset(); |
|
| 1388 | 1388 | |
| 1389 | - // ----- Look if the file exits |
|
| 1390 | - if (!is_file($this->zipname)) { |
|
| 1391 | - // ----- Error log |
|
| 1392 | - PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "Missing archive file '".$this->zipname."'"); |
|
| 1393 | - return(false); |
|
| 1394 | - } |
|
| 1389 | + // ----- Look if the file exits |
|
| 1390 | + if (!is_file($this->zipname)) { |
|
| 1391 | + // ----- Error log |
|
| 1392 | + PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "Missing archive file '".$this->zipname."'"); |
|
| 1393 | + return(false); |
|
| 1394 | + } |
|
| 1395 | 1395 | |
| 1396 | - // ----- Check that the file is readeable |
|
| 1397 | - if (!is_readable($this->zipname)) { |
|
| 1398 | - // ----- Error log |
|
| 1399 | - PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to read archive '".$this->zipname."'"); |
|
| 1400 | - return(false); |
|
| 1401 | - } |
|
| 1396 | + // ----- Check that the file is readeable |
|
| 1397 | + if (!is_readable($this->zipname)) { |
|
| 1398 | + // ----- Error log |
|
| 1399 | + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to read archive '".$this->zipname."'"); |
|
| 1400 | + return(false); |
|
| 1401 | + } |
|
| 1402 | 1402 | |
| 1403 | - // ----- Check the magic code |
|
| 1404 | - // TBC |
|
| 1403 | + // ----- Check the magic code |
|
| 1404 | + // TBC |
|
| 1405 | 1405 | |
| 1406 | - // ----- Check the central header |
|
| 1407 | - // TBC |
|
| 1406 | + // ----- Check the central header |
|
| 1407 | + // TBC |
|
| 1408 | 1408 | |
| 1409 | - // ----- Check each file header |
|
| 1410 | - // TBC |
|
| 1409 | + // ----- Check each file header |
|
| 1410 | + // TBC |
|
| 1411 | 1411 | |
| 1412 | - // ----- Return |
|
| 1413 | - return $v_result; |
|
| 1412 | + // ----- Return |
|
| 1413 | + return $v_result; |
|
| 1414 | 1414 | } |
| 1415 | 1415 | // -------------------------------------------------------------------------------- |
| 1416 | 1416 | |
@@ -1431,395 +1431,395 @@ discard block |
||
| 1431 | 1431 | // -------------------------------------------------------------------------------- |
| 1432 | 1432 | function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_requested_options=false) |
| 1433 | 1433 | { |
| 1434 | - $v_result=1; |
|
| 1434 | + $v_result=1; |
|
| 1435 | 1435 | |
| 1436 | - // ----- Read the options |
|
| 1437 | - $i=0; |
|
| 1438 | - while ($i<$p_size) { |
|
| 1436 | + // ----- Read the options |
|
| 1437 | + $i=0; |
|
| 1438 | + while ($i<$p_size) { |
|
| 1439 | 1439 | |
| 1440 | - // ----- Check if the option is supported |
|
| 1441 | - if (!isset($v_requested_options[$p_options_list[$i]])) { |
|
| 1442 | - // ----- Error log |
|
| 1443 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid optional parameter '".$p_options_list[$i]."' for this method"); |
|
| 1440 | + // ----- Check if the option is supported |
|
| 1441 | + if (!isset($v_requested_options[$p_options_list[$i]])) { |
|
| 1442 | + // ----- Error log |
|
| 1443 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid optional parameter '".$p_options_list[$i]."' for this method"); |
|
| 1444 | 1444 | |
| 1445 | - // ----- Return |
|
| 1446 | - return PclZip::errorCode(); |
|
| 1447 | - } |
|
| 1445 | + // ----- Return |
|
| 1446 | + return PclZip::errorCode(); |
|
| 1447 | + } |
|
| 1448 | 1448 | |
| 1449 | - // ----- Look for next option |
|
| 1450 | - switch ($p_options_list[$i]) { |
|
| 1451 | - // ----- Look for options that request a path value |
|
| 1452 | - case PCLZIP_OPT_PATH : |
|
| 1453 | - case PCLZIP_OPT_REMOVE_PATH : |
|
| 1454 | - case PCLZIP_OPT_ADD_PATH : |
|
| 1455 | - // ----- Check the number of parameters |
|
| 1456 | - if (($i+1) >= $p_size) { |
|
| 1457 | - // ----- Error log |
|
| 1458 | - PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1459 | - |
|
| 1460 | - // ----- Return |
|
| 1461 | - return PclZip::errorCode(); |
|
| 1462 | - } |
|
| 1449 | + // ----- Look for next option |
|
| 1450 | + switch ($p_options_list[$i]) { |
|
| 1451 | + // ----- Look for options that request a path value |
|
| 1452 | + case PCLZIP_OPT_PATH : |
|
| 1453 | + case PCLZIP_OPT_REMOVE_PATH : |
|
| 1454 | + case PCLZIP_OPT_ADD_PATH : |
|
| 1455 | + // ----- Check the number of parameters |
|
| 1456 | + if (($i+1) >= $p_size) { |
|
| 1457 | + // ----- Error log |
|
| 1458 | + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1459 | + |
|
| 1460 | + // ----- Return |
|
| 1461 | + return PclZip::errorCode(); |
|
| 1462 | + } |
|
| 1463 | 1463 | |
| 1464 | - // ----- Get the value |
|
| 1465 | - $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE); |
|
| 1466 | - $i++; |
|
| 1467 | - break; |
|
| 1464 | + // ----- Get the value |
|
| 1465 | + $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE); |
|
| 1466 | + $i++; |
|
| 1467 | + break; |
|
| 1468 | 1468 | |
| 1469 | - case PCLZIP_OPT_TEMP_FILE_THRESHOLD : |
|
| 1470 | - // ----- Check the number of parameters |
|
| 1471 | - if (($i+1) >= $p_size) { |
|
| 1472 | - PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1473 | - return PclZip::errorCode(); |
|
| 1474 | - } |
|
| 1469 | + case PCLZIP_OPT_TEMP_FILE_THRESHOLD : |
|
| 1470 | + // ----- Check the number of parameters |
|
| 1471 | + if (($i+1) >= $p_size) { |
|
| 1472 | + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1473 | + return PclZip::errorCode(); |
|
| 1474 | + } |
|
| 1475 | 1475 | |
| 1476 | - // ----- Check for incompatible options |
|
| 1477 | - if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) { |
|
| 1478 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'"); |
|
| 1479 | - return PclZip::errorCode(); |
|
| 1480 | - } |
|
| 1476 | + // ----- Check for incompatible options |
|
| 1477 | + if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) { |
|
| 1478 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'"); |
|
| 1479 | + return PclZip::errorCode(); |
|
| 1480 | + } |
|
| 1481 | 1481 | |
| 1482 | - // ----- Check the value |
|
| 1483 | - $v_value = $p_options_list[$i+1]; |
|
| 1484 | - if ((!is_integer($v_value)) || ($v_value<0)) { |
|
| 1485 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Integer expected for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1486 | - return PclZip::errorCode(); |
|
| 1487 | - } |
|
| 1482 | + // ----- Check the value |
|
| 1483 | + $v_value = $p_options_list[$i+1]; |
|
| 1484 | + if ((!is_integer($v_value)) || ($v_value<0)) { |
|
| 1485 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Integer expected for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1486 | + return PclZip::errorCode(); |
|
| 1487 | + } |
|
| 1488 | 1488 | |
| 1489 | - // ----- Get the value (and convert it in bytes) |
|
| 1490 | - $v_result_list[$p_options_list[$i]] = $v_value*1048576; |
|
| 1491 | - $i++; |
|
| 1492 | - break; |
|
| 1489 | + // ----- Get the value (and convert it in bytes) |
|
| 1490 | + $v_result_list[$p_options_list[$i]] = $v_value*1048576; |
|
| 1491 | + $i++; |
|
| 1492 | + break; |
|
| 1493 | 1493 | |
| 1494 | - case PCLZIP_OPT_TEMP_FILE_ON : |
|
| 1495 | - // ----- Check for incompatible options |
|
| 1496 | - if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) { |
|
| 1497 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'"); |
|
| 1498 | - return PclZip::errorCode(); |
|
| 1499 | - } |
|
| 1494 | + case PCLZIP_OPT_TEMP_FILE_ON : |
|
| 1495 | + // ----- Check for incompatible options |
|
| 1496 | + if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) { |
|
| 1497 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'"); |
|
| 1498 | + return PclZip::errorCode(); |
|
| 1499 | + } |
|
| 1500 | 1500 | |
| 1501 | - $v_result_list[$p_options_list[$i]] = true; |
|
| 1502 | - break; |
|
| 1503 | - |
|
| 1504 | - case PCLZIP_OPT_TEMP_FILE_OFF : |
|
| 1505 | - // ----- Check for incompatible options |
|
| 1506 | - if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_ON])) { |
|
| 1507 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_ON'"); |
|
| 1508 | - return PclZip::errorCode(); |
|
| 1509 | - } |
|
| 1510 | - // ----- Check for incompatible options |
|
| 1511 | - if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) { |
|
| 1512 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_THRESHOLD'"); |
|
| 1513 | - return PclZip::errorCode(); |
|
| 1514 | - } |
|
| 1501 | + $v_result_list[$p_options_list[$i]] = true; |
|
| 1502 | + break; |
|
| 1503 | + |
|
| 1504 | + case PCLZIP_OPT_TEMP_FILE_OFF : |
|
| 1505 | + // ----- Check for incompatible options |
|
| 1506 | + if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_ON])) { |
|
| 1507 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_ON'"); |
|
| 1508 | + return PclZip::errorCode(); |
|
| 1509 | + } |
|
| 1510 | + // ----- Check for incompatible options |
|
| 1511 | + if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) { |
|
| 1512 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_THRESHOLD'"); |
|
| 1513 | + return PclZip::errorCode(); |
|
| 1514 | + } |
|
| 1515 | 1515 | |
| 1516 | - $v_result_list[$p_options_list[$i]] = true; |
|
| 1517 | - break; |
|
| 1516 | + $v_result_list[$p_options_list[$i]] = true; |
|
| 1517 | + break; |
|
| 1518 | 1518 | |
| 1519 | - case PCLZIP_OPT_EXTRACT_DIR_RESTRICTION : |
|
| 1520 | - // ----- Check the number of parameters |
|
| 1521 | - if (($i+1) >= $p_size) { |
|
| 1522 | - // ----- Error log |
|
| 1523 | - PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1519 | + case PCLZIP_OPT_EXTRACT_DIR_RESTRICTION : |
|
| 1520 | + // ----- Check the number of parameters |
|
| 1521 | + if (($i+1) >= $p_size) { |
|
| 1522 | + // ----- Error log |
|
| 1523 | + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1524 | 1524 | |
| 1525 | - // ----- Return |
|
| 1526 | - return PclZip::errorCode(); |
|
| 1527 | - } |
|
| 1525 | + // ----- Return |
|
| 1526 | + return PclZip::errorCode(); |
|
| 1527 | + } |
|
| 1528 | 1528 | |
| 1529 | - // ----- Get the value |
|
| 1530 | - if ( is_string($p_options_list[$i+1]) |
|
| 1531 | - && ($p_options_list[$i+1] != '')) { |
|
| 1532 | - $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE); |
|
| 1533 | - $i++; |
|
| 1534 | - } |
|
| 1535 | - else { |
|
| 1536 | - } |
|
| 1537 | - break; |
|
| 1529 | + // ----- Get the value |
|
| 1530 | + if ( is_string($p_options_list[$i+1]) |
|
| 1531 | + && ($p_options_list[$i+1] != '')) { |
|
| 1532 | + $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE); |
|
| 1533 | + $i++; |
|
| 1534 | + } |
|
| 1535 | + else { |
|
| 1536 | + } |
|
| 1537 | + break; |
|
| 1538 | 1538 | |
| 1539 | - // ----- Look for options that request an array of string for value |
|
| 1540 | - case PCLZIP_OPT_BY_NAME : |
|
| 1541 | - // ----- Check the number of parameters |
|
| 1542 | - if (($i+1) >= $p_size) { |
|
| 1543 | - // ----- Error log |
|
| 1544 | - PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1539 | + // ----- Look for options that request an array of string for value |
|
| 1540 | + case PCLZIP_OPT_BY_NAME : |
|
| 1541 | + // ----- Check the number of parameters |
|
| 1542 | + if (($i+1) >= $p_size) { |
|
| 1543 | + // ----- Error log |
|
| 1544 | + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1545 | 1545 | |
| 1546 | - // ----- Return |
|
| 1547 | - return PclZip::errorCode(); |
|
| 1548 | - } |
|
| 1546 | + // ----- Return |
|
| 1547 | + return PclZip::errorCode(); |
|
| 1548 | + } |
|
| 1549 | 1549 | |
| 1550 | - // ----- Get the value |
|
| 1551 | - if (is_string($p_options_list[$i+1])) { |
|
| 1552 | - $v_result_list[$p_options_list[$i]][0] = $p_options_list[$i+1]; |
|
| 1553 | - } |
|
| 1554 | - else if (is_array($p_options_list[$i+1])) { |
|
| 1555 | - $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; |
|
| 1556 | - } |
|
| 1557 | - else { |
|
| 1558 | - // ----- Error log |
|
| 1559 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1550 | + // ----- Get the value |
|
| 1551 | + if (is_string($p_options_list[$i+1])) { |
|
| 1552 | + $v_result_list[$p_options_list[$i]][0] = $p_options_list[$i+1]; |
|
| 1553 | + } |
|
| 1554 | + else if (is_array($p_options_list[$i+1])) { |
|
| 1555 | + $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; |
|
| 1556 | + } |
|
| 1557 | + else { |
|
| 1558 | + // ----- Error log |
|
| 1559 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1560 | 1560 | |
| 1561 | - // ----- Return |
|
| 1562 | - return PclZip::errorCode(); |
|
| 1563 | - } |
|
| 1564 | - $i++; |
|
| 1565 | - break; |
|
| 1566 | - |
|
| 1567 | - // ----- Look for options that request an EREG or PREG expression |
|
| 1568 | - case PCLZIP_OPT_BY_EREG : |
|
| 1569 | - // ereg() is deprecated starting with PHP 5.3. Move PCLZIP_OPT_BY_EREG |
|
| 1570 | - // to PCLZIP_OPT_BY_PREG |
|
| 1571 | - $p_options_list[$i] = PCLZIP_OPT_BY_PREG; |
|
| 1572 | - case PCLZIP_OPT_BY_PREG : |
|
| 1573 | - //case PCLZIP_OPT_CRYPT : |
|
| 1574 | - // ----- Check the number of parameters |
|
| 1575 | - if (($i+1) >= $p_size) { |
|
| 1576 | - // ----- Error log |
|
| 1577 | - PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1578 | - |
|
| 1579 | - // ----- Return |
|
| 1580 | - return PclZip::errorCode(); |
|
| 1581 | - } |
|
| 1561 | + // ----- Return |
|
| 1562 | + return PclZip::errorCode(); |
|
| 1563 | + } |
|
| 1564 | + $i++; |
|
| 1565 | + break; |
|
| 1566 | + |
|
| 1567 | + // ----- Look for options that request an EREG or PREG expression |
|
| 1568 | + case PCLZIP_OPT_BY_EREG : |
|
| 1569 | + // ereg() is deprecated starting with PHP 5.3. Move PCLZIP_OPT_BY_EREG |
|
| 1570 | + // to PCLZIP_OPT_BY_PREG |
|
| 1571 | + $p_options_list[$i] = PCLZIP_OPT_BY_PREG; |
|
| 1572 | + case PCLZIP_OPT_BY_PREG : |
|
| 1573 | + //case PCLZIP_OPT_CRYPT : |
|
| 1574 | + // ----- Check the number of parameters |
|
| 1575 | + if (($i+1) >= $p_size) { |
|
| 1576 | + // ----- Error log |
|
| 1577 | + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1578 | + |
|
| 1579 | + // ----- Return |
|
| 1580 | + return PclZip::errorCode(); |
|
| 1581 | + } |
|
| 1582 | 1582 | |
| 1583 | - // ----- Get the value |
|
| 1584 | - if (is_string($p_options_list[$i+1])) { |
|
| 1585 | - $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; |
|
| 1586 | - } |
|
| 1587 | - else { |
|
| 1588 | - // ----- Error log |
|
| 1589 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1583 | + // ----- Get the value |
|
| 1584 | + if (is_string($p_options_list[$i+1])) { |
|
| 1585 | + $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; |
|
| 1586 | + } |
|
| 1587 | + else { |
|
| 1588 | + // ----- Error log |
|
| 1589 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1590 | 1590 | |
| 1591 | - // ----- Return |
|
| 1592 | - return PclZip::errorCode(); |
|
| 1593 | - } |
|
| 1594 | - $i++; |
|
| 1595 | - break; |
|
| 1596 | - |
|
| 1597 | - // ----- Look for options that takes a string |
|
| 1598 | - case PCLZIP_OPT_COMMENT : |
|
| 1599 | - case PCLZIP_OPT_ADD_COMMENT : |
|
| 1600 | - case PCLZIP_OPT_PREPEND_COMMENT : |
|
| 1601 | - // ----- Check the number of parameters |
|
| 1602 | - if (($i+1) >= $p_size) { |
|
| 1603 | - // ----- Error log |
|
| 1604 | - PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, |
|
| 1605 | - "Missing parameter value for option '" |
|
| 1591 | + // ----- Return |
|
| 1592 | + return PclZip::errorCode(); |
|
| 1593 | + } |
|
| 1594 | + $i++; |
|
| 1595 | + break; |
|
| 1596 | + |
|
| 1597 | + // ----- Look for options that takes a string |
|
| 1598 | + case PCLZIP_OPT_COMMENT : |
|
| 1599 | + case PCLZIP_OPT_ADD_COMMENT : |
|
| 1600 | + case PCLZIP_OPT_PREPEND_COMMENT : |
|
| 1601 | + // ----- Check the number of parameters |
|
| 1602 | + if (($i+1) >= $p_size) { |
|
| 1603 | + // ----- Error log |
|
| 1604 | + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, |
|
| 1605 | + "Missing parameter value for option '" |
|
| 1606 | 1606 | .PclZipUtilOptionText($p_options_list[$i]) |
| 1607 | 1607 | ."'"); |
| 1608 | 1608 | |
| 1609 | - // ----- Return |
|
| 1610 | - return PclZip::errorCode(); |
|
| 1611 | - } |
|
| 1609 | + // ----- Return |
|
| 1610 | + return PclZip::errorCode(); |
|
| 1611 | + } |
|
| 1612 | 1612 | |
| 1613 | - // ----- Get the value |
|
| 1614 | - if (is_string($p_options_list[$i+1])) { |
|
| 1615 | - $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; |
|
| 1616 | - } |
|
| 1617 | - else { |
|
| 1618 | - // ----- Error log |
|
| 1619 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, |
|
| 1620 | - "Wrong parameter value for option '" |
|
| 1613 | + // ----- Get the value |
|
| 1614 | + if (is_string($p_options_list[$i+1])) { |
|
| 1615 | + $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; |
|
| 1616 | + } |
|
| 1617 | + else { |
|
| 1618 | + // ----- Error log |
|
| 1619 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, |
|
| 1620 | + "Wrong parameter value for option '" |
|
| 1621 | 1621 | .PclZipUtilOptionText($p_options_list[$i]) |
| 1622 | 1622 | ."'"); |
| 1623 | 1623 | |
| 1624 | - // ----- Return |
|
| 1625 | - return PclZip::errorCode(); |
|
| 1626 | - } |
|
| 1627 | - $i++; |
|
| 1628 | - break; |
|
| 1629 | - |
|
| 1630 | - // ----- Look for options that request an array of index |
|
| 1631 | - case PCLZIP_OPT_BY_INDEX : |
|
| 1632 | - // ----- Check the number of parameters |
|
| 1633 | - if (($i+1) >= $p_size) { |
|
| 1634 | - // ----- Error log |
|
| 1635 | - PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1636 | - |
|
| 1637 | - // ----- Return |
|
| 1638 | - return PclZip::errorCode(); |
|
| 1639 | - } |
|
| 1624 | + // ----- Return |
|
| 1625 | + return PclZip::errorCode(); |
|
| 1626 | + } |
|
| 1627 | + $i++; |
|
| 1628 | + break; |
|
| 1629 | + |
|
| 1630 | + // ----- Look for options that request an array of index |
|
| 1631 | + case PCLZIP_OPT_BY_INDEX : |
|
| 1632 | + // ----- Check the number of parameters |
|
| 1633 | + if (($i+1) >= $p_size) { |
|
| 1634 | + // ----- Error log |
|
| 1635 | + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1636 | + |
|
| 1637 | + // ----- Return |
|
| 1638 | + return PclZip::errorCode(); |
|
| 1639 | + } |
|
| 1640 | 1640 | |
| 1641 | - // ----- Get the value |
|
| 1642 | - $v_work_list = array(); |
|
| 1643 | - if (is_string($p_options_list[$i+1])) { |
|
| 1641 | + // ----- Get the value |
|
| 1642 | + $v_work_list = array(); |
|
| 1643 | + if (is_string($p_options_list[$i+1])) { |
|
| 1644 | 1644 | |
| 1645 | - // ----- Remove spaces |
|
| 1646 | - $p_options_list[$i+1] = strtr($p_options_list[$i+1], ' ', ''); |
|
| 1645 | + // ----- Remove spaces |
|
| 1646 | + $p_options_list[$i+1] = strtr($p_options_list[$i+1], ' ', ''); |
|
| 1647 | 1647 | |
| 1648 | - // ----- Parse items |
|
| 1649 | - $v_work_list = explode(",", $p_options_list[$i+1]); |
|
| 1650 | - } |
|
| 1651 | - else if (is_integer($p_options_list[$i+1])) { |
|
| 1652 | - $v_work_list[0] = $p_options_list[$i+1].'-'.$p_options_list[$i+1]; |
|
| 1653 | - } |
|
| 1654 | - else if (is_array($p_options_list[$i+1])) { |
|
| 1655 | - $v_work_list = $p_options_list[$i+1]; |
|
| 1656 | - } |
|
| 1657 | - else { |
|
| 1658 | - // ----- Error log |
|
| 1659 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Value must be integer, string or array for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1648 | + // ----- Parse items |
|
| 1649 | + $v_work_list = explode(",", $p_options_list[$i+1]); |
|
| 1650 | + } |
|
| 1651 | + else if (is_integer($p_options_list[$i+1])) { |
|
| 1652 | + $v_work_list[0] = $p_options_list[$i+1].'-'.$p_options_list[$i+1]; |
|
| 1653 | + } |
|
| 1654 | + else if (is_array($p_options_list[$i+1])) { |
|
| 1655 | + $v_work_list = $p_options_list[$i+1]; |
|
| 1656 | + } |
|
| 1657 | + else { |
|
| 1658 | + // ----- Error log |
|
| 1659 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Value must be integer, string or array for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1660 | 1660 | |
| 1661 | - // ----- Return |
|
| 1662 | - return PclZip::errorCode(); |
|
| 1663 | - } |
|
| 1661 | + // ----- Return |
|
| 1662 | + return PclZip::errorCode(); |
|
| 1663 | + } |
|
| 1664 | 1664 | |
| 1665 | - // ----- Reduce the index list |
|
| 1666 | - // each index item in the list must be a couple with a start and |
|
| 1667 | - // an end value : [0,3], [5-5], [8-10], ... |
|
| 1668 | - // ----- Check the format of each item |
|
| 1669 | - $v_sort_flag=false; |
|
| 1670 | - $v_sort_value=0; |
|
| 1671 | - for ($j=0; $j<sizeof($v_work_list); $j++) { |
|
| 1672 | - // ----- Explode the item |
|
| 1673 | - $v_item_list = explode("-", $v_work_list[$j]); |
|
| 1674 | - $v_size_item_list = sizeof($v_item_list); |
|
| 1665 | + // ----- Reduce the index list |
|
| 1666 | + // each index item in the list must be a couple with a start and |
|
| 1667 | + // an end value : [0,3], [5-5], [8-10], ... |
|
| 1668 | + // ----- Check the format of each item |
|
| 1669 | + $v_sort_flag=false; |
|
| 1670 | + $v_sort_value=0; |
|
| 1671 | + for ($j=0; $j<sizeof($v_work_list); $j++) { |
|
| 1672 | + // ----- Explode the item |
|
| 1673 | + $v_item_list = explode("-", $v_work_list[$j]); |
|
| 1674 | + $v_size_item_list = sizeof($v_item_list); |
|
| 1675 | 1675 | |
| 1676 | - // ----- TBC : Here we might check that each item is a |
|
| 1677 | - // real integer ... |
|
| 1676 | + // ----- TBC : Here we might check that each item is a |
|
| 1677 | + // real integer ... |
|
| 1678 | 1678 | |
| 1679 | - // ----- Look for single value |
|
| 1680 | - if ($v_size_item_list == 1) { |
|
| 1681 | - // ----- Set the option value |
|
| 1682 | - $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0]; |
|
| 1683 | - $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[0]; |
|
| 1684 | - } |
|
| 1685 | - elseif ($v_size_item_list == 2) { |
|
| 1686 | - // ----- Set the option value |
|
| 1687 | - $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0]; |
|
| 1688 | - $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[1]; |
|
| 1689 | - } |
|
| 1690 | - else { |
|
| 1691 | - // ----- Error log |
|
| 1692 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Too many values in index range for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1693 | - |
|
| 1694 | - // ----- Return |
|
| 1695 | - return PclZip::errorCode(); |
|
| 1696 | - } |
|
| 1697 | - |
|
| 1698 | - |
|
| 1699 | - // ----- Look for list sort |
|
| 1700 | - if ($v_result_list[$p_options_list[$i]][$j]['start'] < $v_sort_value) { |
|
| 1701 | - $v_sort_flag=true; |
|
| 1702 | - |
|
| 1703 | - // ----- TBC : An automatic sort should be writen ... |
|
| 1704 | - // ----- Error log |
|
| 1705 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Invalid order of index range for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1706 | - |
|
| 1707 | - // ----- Return |
|
| 1708 | - return PclZip::errorCode(); |
|
| 1709 | - } |
|
| 1710 | - $v_sort_value = $v_result_list[$p_options_list[$i]][$j]['start']; |
|
| 1711 | - } |
|
| 1679 | + // ----- Look for single value |
|
| 1680 | + if ($v_size_item_list == 1) { |
|
| 1681 | + // ----- Set the option value |
|
| 1682 | + $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0]; |
|
| 1683 | + $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[0]; |
|
| 1684 | + } |
|
| 1685 | + elseif ($v_size_item_list == 2) { |
|
| 1686 | + // ----- Set the option value |
|
| 1687 | + $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0]; |
|
| 1688 | + $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[1]; |
|
| 1689 | + } |
|
| 1690 | + else { |
|
| 1691 | + // ----- Error log |
|
| 1692 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Too many values in index range for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1693 | + |
|
| 1694 | + // ----- Return |
|
| 1695 | + return PclZip::errorCode(); |
|
| 1696 | + } |
|
| 1697 | + |
|
| 1698 | + |
|
| 1699 | + // ----- Look for list sort |
|
| 1700 | + if ($v_result_list[$p_options_list[$i]][$j]['start'] < $v_sort_value) { |
|
| 1701 | + $v_sort_flag=true; |
|
| 1702 | + |
|
| 1703 | + // ----- TBC : An automatic sort should be writen ... |
|
| 1704 | + // ----- Error log |
|
| 1705 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Invalid order of index range for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1706 | + |
|
| 1707 | + // ----- Return |
|
| 1708 | + return PclZip::errorCode(); |
|
| 1709 | + } |
|
| 1710 | + $v_sort_value = $v_result_list[$p_options_list[$i]][$j]['start']; |
|
| 1711 | + } |
|
| 1712 | 1712 | |
| 1713 | - // ----- Sort the items |
|
| 1714 | - if ($v_sort_flag) { |
|
| 1715 | - // TBC : To Be Completed |
|
| 1716 | - } |
|
| 1713 | + // ----- Sort the items |
|
| 1714 | + if ($v_sort_flag) { |
|
| 1715 | + // TBC : To Be Completed |
|
| 1716 | + } |
|
| 1717 | 1717 | |
| 1718 | - // ----- Next option |
|
| 1719 | - $i++; |
|
| 1720 | - break; |
|
| 1721 | - |
|
| 1722 | - // ----- Look for options that request no value |
|
| 1723 | - case PCLZIP_OPT_REMOVE_ALL_PATH : |
|
| 1724 | - case PCLZIP_OPT_EXTRACT_AS_STRING : |
|
| 1725 | - case PCLZIP_OPT_NO_COMPRESSION : |
|
| 1726 | - case PCLZIP_OPT_EXTRACT_IN_OUTPUT : |
|
| 1727 | - case PCLZIP_OPT_REPLACE_NEWER : |
|
| 1728 | - case PCLZIP_OPT_STOP_ON_ERROR : |
|
| 1729 | - $v_result_list[$p_options_list[$i]] = true; |
|
| 1730 | - break; |
|
| 1731 | - |
|
| 1732 | - // ----- Look for options that request an octal value |
|
| 1733 | - case PCLZIP_OPT_SET_CHMOD : |
|
| 1734 | - // ----- Check the number of parameters |
|
| 1735 | - if (($i+1) >= $p_size) { |
|
| 1736 | - // ----- Error log |
|
| 1737 | - PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1738 | - |
|
| 1739 | - // ----- Return |
|
| 1740 | - return PclZip::errorCode(); |
|
| 1741 | - } |
|
| 1718 | + // ----- Next option |
|
| 1719 | + $i++; |
|
| 1720 | + break; |
|
| 1721 | + |
|
| 1722 | + // ----- Look for options that request no value |
|
| 1723 | + case PCLZIP_OPT_REMOVE_ALL_PATH : |
|
| 1724 | + case PCLZIP_OPT_EXTRACT_AS_STRING : |
|
| 1725 | + case PCLZIP_OPT_NO_COMPRESSION : |
|
| 1726 | + case PCLZIP_OPT_EXTRACT_IN_OUTPUT : |
|
| 1727 | + case PCLZIP_OPT_REPLACE_NEWER : |
|
| 1728 | + case PCLZIP_OPT_STOP_ON_ERROR : |
|
| 1729 | + $v_result_list[$p_options_list[$i]] = true; |
|
| 1730 | + break; |
|
| 1731 | + |
|
| 1732 | + // ----- Look for options that request an octal value |
|
| 1733 | + case PCLZIP_OPT_SET_CHMOD : |
|
| 1734 | + // ----- Check the number of parameters |
|
| 1735 | + if (($i+1) >= $p_size) { |
|
| 1736 | + // ----- Error log |
|
| 1737 | + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1738 | + |
|
| 1739 | + // ----- Return |
|
| 1740 | + return PclZip::errorCode(); |
|
| 1741 | + } |
|
| 1742 | 1742 | |
| 1743 | - // ----- Get the value |
|
| 1744 | - $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; |
|
| 1745 | - $i++; |
|
| 1746 | - break; |
|
| 1747 | - |
|
| 1748 | - // ----- Look for options that request a call-back |
|
| 1749 | - case PCLZIP_CB_PRE_EXTRACT : |
|
| 1750 | - case PCLZIP_CB_POST_EXTRACT : |
|
| 1751 | - case PCLZIP_CB_PRE_ADD : |
|
| 1752 | - case PCLZIP_CB_POST_ADD : |
|
| 1753 | - /* for futur use |
|
| 1743 | + // ----- Get the value |
|
| 1744 | + $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; |
|
| 1745 | + $i++; |
|
| 1746 | + break; |
|
| 1747 | + |
|
| 1748 | + // ----- Look for options that request a call-back |
|
| 1749 | + case PCLZIP_CB_PRE_EXTRACT : |
|
| 1750 | + case PCLZIP_CB_POST_EXTRACT : |
|
| 1751 | + case PCLZIP_CB_PRE_ADD : |
|
| 1752 | + case PCLZIP_CB_POST_ADD : |
|
| 1753 | + /* for futur use |
|
| 1754 | 1754 | case PCLZIP_CB_PRE_DELETE : |
| 1755 | 1755 | case PCLZIP_CB_POST_DELETE : |
| 1756 | 1756 | case PCLZIP_CB_PRE_LIST : |
| 1757 | 1757 | case PCLZIP_CB_POST_LIST : |
| 1758 | 1758 | */ |
| 1759 | - // ----- Check the number of parameters |
|
| 1760 | - if (($i+1) >= $p_size) { |
|
| 1761 | - // ----- Error log |
|
| 1762 | - PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1759 | + // ----- Check the number of parameters |
|
| 1760 | + if (($i+1) >= $p_size) { |
|
| 1761 | + // ----- Error log |
|
| 1762 | + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1763 | 1763 | |
| 1764 | - // ----- Return |
|
| 1765 | - return PclZip::errorCode(); |
|
| 1766 | - } |
|
| 1764 | + // ----- Return |
|
| 1765 | + return PclZip::errorCode(); |
|
| 1766 | + } |
|
| 1767 | 1767 | |
| 1768 | - // ----- Get the value |
|
| 1769 | - $v_function_name = $p_options_list[$i+1]; |
|
| 1768 | + // ----- Get the value |
|
| 1769 | + $v_function_name = $p_options_list[$i+1]; |
|
| 1770 | 1770 | |
| 1771 | - // ----- Check that the value is a valid existing function |
|
| 1772 | - if (!function_exists($v_function_name)) { |
|
| 1773 | - // ----- Error log |
|
| 1774 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Function '".$v_function_name."()' is not an existing function for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1771 | + // ----- Check that the value is a valid existing function |
|
| 1772 | + if (!function_exists($v_function_name)) { |
|
| 1773 | + // ----- Error log |
|
| 1774 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Function '".$v_function_name."()' is not an existing function for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1775 | 1775 | |
| 1776 | - // ----- Return |
|
| 1777 | - return PclZip::errorCode(); |
|
| 1778 | - } |
|
| 1776 | + // ----- Return |
|
| 1777 | + return PclZip::errorCode(); |
|
| 1778 | + } |
|
| 1779 | 1779 | |
| 1780 | - // ----- Set the attribute |
|
| 1781 | - $v_result_list[$p_options_list[$i]] = $v_function_name; |
|
| 1782 | - $i++; |
|
| 1783 | - break; |
|
| 1780 | + // ----- Set the attribute |
|
| 1781 | + $v_result_list[$p_options_list[$i]] = $v_function_name; |
|
| 1782 | + $i++; |
|
| 1783 | + break; |
|
| 1784 | 1784 | |
| 1785 | - default : |
|
| 1786 | - // ----- Error log |
|
| 1787 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, |
|
| 1788 | - "Unknown parameter '" |
|
| 1785 | + default : |
|
| 1786 | + // ----- Error log |
|
| 1787 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, |
|
| 1788 | + "Unknown parameter '" |
|
| 1789 | 1789 | .$p_options_list[$i]."'"); |
| 1790 | 1790 | |
| 1791 | - // ----- Return |
|
| 1792 | - return PclZip::errorCode(); |
|
| 1793 | - } |
|
| 1791 | + // ----- Return |
|
| 1792 | + return PclZip::errorCode(); |
|
| 1793 | + } |
|
| 1794 | 1794 | |
| 1795 | - // ----- Next options |
|
| 1796 | - $i++; |
|
| 1797 | - } |
|
| 1795 | + // ----- Next options |
|
| 1796 | + $i++; |
|
| 1797 | + } |
|
| 1798 | 1798 | |
| 1799 | - // ----- Look for mandatory options |
|
| 1800 | - if ($v_requested_options !== false) { |
|
| 1801 | - for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) { |
|
| 1802 | - // ----- Look for mandatory option |
|
| 1803 | - if ($v_requested_options[$key] == 'mandatory') { |
|
| 1804 | - // ----- Look if present |
|
| 1805 | - if (!isset($v_result_list[$key])) { |
|
| 1806 | - // ----- Error log |
|
| 1807 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")"); |
|
| 1808 | - |
|
| 1809 | - // ----- Return |
|
| 1810 | - return PclZip::errorCode(); |
|
| 1811 | - } |
|
| 1812 | - } |
|
| 1813 | - } |
|
| 1814 | - } |
|
| 1799 | + // ----- Look for mandatory options |
|
| 1800 | + if ($v_requested_options !== false) { |
|
| 1801 | + for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) { |
|
| 1802 | + // ----- Look for mandatory option |
|
| 1803 | + if ($v_requested_options[$key] == 'mandatory') { |
|
| 1804 | + // ----- Look if present |
|
| 1805 | + if (!isset($v_result_list[$key])) { |
|
| 1806 | + // ----- Error log |
|
| 1807 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")"); |
|
| 1808 | + |
|
| 1809 | + // ----- Return |
|
| 1810 | + return PclZip::errorCode(); |
|
| 1811 | + } |
|
| 1812 | + } |
|
| 1813 | + } |
|
| 1814 | + } |
|
| 1815 | 1815 | |
| 1816 | - // ----- Look for default values |
|
| 1817 | - if (!isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) { |
|
| 1816 | + // ----- Look for default values |
|
| 1817 | + if (!isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) { |
|
| 1818 | 1818 | |
| 1819 | - } |
|
| 1819 | + } |
|
| 1820 | 1820 | |
| 1821 | - // ----- Return |
|
| 1822 | - return $v_result; |
|
| 1821 | + // ----- Return |
|
| 1822 | + return $v_result; |
|
| 1823 | 1823 | } |
| 1824 | 1824 | // -------------------------------------------------------------------------------- |
| 1825 | 1825 | |
@@ -1831,37 +1831,37 @@ discard block |
||
| 1831 | 1831 | // -------------------------------------------------------------------------------- |
| 1832 | 1832 | function privOptionDefaultThreshold(&$p_options) |
| 1833 | 1833 | { |
| 1834 | - $v_result=1; |
|
| 1834 | + $v_result=1; |
|
| 1835 | 1835 | |
| 1836 | - if (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]) |
|
| 1837 | - || isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) { |
|
| 1838 | - return $v_result; |
|
| 1839 | - } |
|
| 1836 | + if (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]) |
|
| 1837 | + || isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) { |
|
| 1838 | + return $v_result; |
|
| 1839 | + } |
|
| 1840 | 1840 | |
| 1841 | - // ----- Get 'memory_limit' configuration value |
|
| 1842 | - $v_memory_limit = ini_get('memory_limit'); |
|
| 1843 | - $v_memory_limit = trim($v_memory_limit); |
|
| 1844 | - $last = strtolower(substr($v_memory_limit, -1)); |
|
| 1841 | + // ----- Get 'memory_limit' configuration value |
|
| 1842 | + $v_memory_limit = ini_get('memory_limit'); |
|
| 1843 | + $v_memory_limit = trim($v_memory_limit); |
|
| 1844 | + $last = strtolower(substr($v_memory_limit, -1)); |
|
| 1845 | 1845 | |
| 1846 | - if($last == 'g') |
|
| 1847 | - //$v_memory_limit = $v_memory_limit*1024*1024*1024; |
|
| 1848 | - $v_memory_limit = $v_memory_limit*1073741824; |
|
| 1849 | - if($last == 'm') |
|
| 1850 | - //$v_memory_limit = $v_memory_limit*1024*1024; |
|
| 1851 | - $v_memory_limit = $v_memory_limit*1048576; |
|
| 1852 | - if($last == 'k') |
|
| 1853 | - $v_memory_limit = $v_memory_limit*1024; |
|
| 1846 | + if($last == 'g') |
|
| 1847 | + //$v_memory_limit = $v_memory_limit*1024*1024*1024; |
|
| 1848 | + $v_memory_limit = $v_memory_limit*1073741824; |
|
| 1849 | + if($last == 'm') |
|
| 1850 | + //$v_memory_limit = $v_memory_limit*1024*1024; |
|
| 1851 | + $v_memory_limit = $v_memory_limit*1048576; |
|
| 1852 | + if($last == 'k') |
|
| 1853 | + $v_memory_limit = $v_memory_limit*1024; |
|
| 1854 | 1854 | |
| 1855 | - $p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] = floor($v_memory_limit*PCLZIP_TEMPORARY_FILE_RATIO); |
|
| 1855 | + $p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] = floor($v_memory_limit*PCLZIP_TEMPORARY_FILE_RATIO); |
|
| 1856 | 1856 | |
| 1857 | 1857 | |
| 1858 | - // ----- Sanity check : No threshold if value lower than 1M |
|
| 1859 | - if ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] < 1048576) { |
|
| 1860 | - unset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]); |
|
| 1861 | - } |
|
| 1858 | + // ----- Sanity check : No threshold if value lower than 1M |
|
| 1859 | + if ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] < 1048576) { |
|
| 1860 | + unset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]); |
|
| 1861 | + } |
|
| 1862 | 1862 | |
| 1863 | - // ----- Return |
|
| 1864 | - return $v_result; |
|
| 1863 | + // ----- Return |
|
| 1864 | + return $v_result; |
|
| 1865 | 1865 | } |
| 1866 | 1866 | // -------------------------------------------------------------------------------- |
| 1867 | 1867 | |
@@ -1875,116 +1875,116 @@ discard block |
||
| 1875 | 1875 | // -------------------------------------------------------------------------------- |
| 1876 | 1876 | function privFileDescrParseAtt(&$p_file_list, &$p_filedescr, $v_options, $v_requested_options=false) |
| 1877 | 1877 | { |
| 1878 | - $v_result=1; |
|
| 1878 | + $v_result=1; |
|
| 1879 | 1879 | |
| 1880 | - // ----- For each file in the list check the attributes |
|
| 1881 | - foreach ($p_file_list as $v_key => $v_value) { |
|
| 1880 | + // ----- For each file in the list check the attributes |
|
| 1881 | + foreach ($p_file_list as $v_key => $v_value) { |
|
| 1882 | 1882 | |
| 1883 | - // ----- Check if the option is supported |
|
| 1884 | - if (!isset($v_requested_options[$v_key])) { |
|
| 1885 | - // ----- Error log |
|
| 1886 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file attribute '".$v_key."' for this file"); |
|
| 1883 | + // ----- Check if the option is supported |
|
| 1884 | + if (!isset($v_requested_options[$v_key])) { |
|
| 1885 | + // ----- Error log |
|
| 1886 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file attribute '".$v_key."' for this file"); |
|
| 1887 | 1887 | |
| 1888 | - // ----- Return |
|
| 1889 | - return PclZip::errorCode(); |
|
| 1890 | - } |
|
| 1888 | + // ----- Return |
|
| 1889 | + return PclZip::errorCode(); |
|
| 1890 | + } |
|
| 1891 | 1891 | |
| 1892 | - // ----- Look for attribute |
|
| 1893 | - switch ($v_key) { |
|
| 1894 | - case PCLZIP_ATT_FILE_NAME : |
|
| 1895 | - if (!is_string($v_value)) { |
|
| 1896 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'"); |
|
| 1897 | - return PclZip::errorCode(); |
|
| 1898 | - } |
|
| 1892 | + // ----- Look for attribute |
|
| 1893 | + switch ($v_key) { |
|
| 1894 | + case PCLZIP_ATT_FILE_NAME : |
|
| 1895 | + if (!is_string($v_value)) { |
|
| 1896 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'"); |
|
| 1897 | + return PclZip::errorCode(); |
|
| 1898 | + } |
|
| 1899 | 1899 | |
| 1900 | - $p_filedescr['filename'] = PclZipUtilPathReduction($v_value); |
|
| 1900 | + $p_filedescr['filename'] = PclZipUtilPathReduction($v_value); |
|
| 1901 | 1901 | |
| 1902 | - if ($p_filedescr['filename'] == '') { |
|
| 1903 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty filename for attribute '".PclZipUtilOptionText($v_key)."'"); |
|
| 1904 | - return PclZip::errorCode(); |
|
| 1905 | - } |
|
| 1902 | + if ($p_filedescr['filename'] == '') { |
|
| 1903 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty filename for attribute '".PclZipUtilOptionText($v_key)."'"); |
|
| 1904 | + return PclZip::errorCode(); |
|
| 1905 | + } |
|
| 1906 | 1906 | |
| 1907 | - break; |
|
| 1907 | + break; |
|
| 1908 | 1908 | |
| 1909 | - case PCLZIP_ATT_FILE_NEW_SHORT_NAME : |
|
| 1910 | - if (!is_string($v_value)) { |
|
| 1911 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'"); |
|
| 1912 | - return PclZip::errorCode(); |
|
| 1913 | - } |
|
| 1909 | + case PCLZIP_ATT_FILE_NEW_SHORT_NAME : |
|
| 1910 | + if (!is_string($v_value)) { |
|
| 1911 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'"); |
|
| 1912 | + return PclZip::errorCode(); |
|
| 1913 | + } |
|
| 1914 | 1914 | |
| 1915 | - $p_filedescr['new_short_name'] = PclZipUtilPathReduction($v_value); |
|
| 1915 | + $p_filedescr['new_short_name'] = PclZipUtilPathReduction($v_value); |
|
| 1916 | 1916 | |
| 1917 | - if ($p_filedescr['new_short_name'] == '') { |
|
| 1918 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty short filename for attribute '".PclZipUtilOptionText($v_key)."'"); |
|
| 1919 | - return PclZip::errorCode(); |
|
| 1920 | - } |
|
| 1921 | - break; |
|
| 1917 | + if ($p_filedescr['new_short_name'] == '') { |
|
| 1918 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty short filename for attribute '".PclZipUtilOptionText($v_key)."'"); |
|
| 1919 | + return PclZip::errorCode(); |
|
| 1920 | + } |
|
| 1921 | + break; |
|
| 1922 | 1922 | |
| 1923 | - case PCLZIP_ATT_FILE_NEW_FULL_NAME : |
|
| 1924 | - if (!is_string($v_value)) { |
|
| 1925 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'"); |
|
| 1926 | - return PclZip::errorCode(); |
|
| 1927 | - } |
|
| 1923 | + case PCLZIP_ATT_FILE_NEW_FULL_NAME : |
|
| 1924 | + if (!is_string($v_value)) { |
|
| 1925 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'"); |
|
| 1926 | + return PclZip::errorCode(); |
|
| 1927 | + } |
|
| 1928 | 1928 | |
| 1929 | - $p_filedescr['new_full_name'] = PclZipUtilPathReduction($v_value); |
|
| 1929 | + $p_filedescr['new_full_name'] = PclZipUtilPathReduction($v_value); |
|
| 1930 | 1930 | |
| 1931 | - if ($p_filedescr['new_full_name'] == '') { |
|
| 1932 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty full filename for attribute '".PclZipUtilOptionText($v_key)."'"); |
|
| 1933 | - return PclZip::errorCode(); |
|
| 1934 | - } |
|
| 1935 | - break; |
|
| 1931 | + if ($p_filedescr['new_full_name'] == '') { |
|
| 1932 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty full filename for attribute '".PclZipUtilOptionText($v_key)."'"); |
|
| 1933 | + return PclZip::errorCode(); |
|
| 1934 | + } |
|
| 1935 | + break; |
|
| 1936 | 1936 | |
| 1937 | - // ----- Look for options that takes a string |
|
| 1938 | - case PCLZIP_ATT_FILE_COMMENT : |
|
| 1939 | - if (!is_string($v_value)) { |
|
| 1940 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'"); |
|
| 1941 | - return PclZip::errorCode(); |
|
| 1942 | - } |
|
| 1937 | + // ----- Look for options that takes a string |
|
| 1938 | + case PCLZIP_ATT_FILE_COMMENT : |
|
| 1939 | + if (!is_string($v_value)) { |
|
| 1940 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'"); |
|
| 1941 | + return PclZip::errorCode(); |
|
| 1942 | + } |
|
| 1943 | 1943 | |
| 1944 | - $p_filedescr['comment'] = $v_value; |
|
| 1945 | - break; |
|
| 1944 | + $p_filedescr['comment'] = $v_value; |
|
| 1945 | + break; |
|
| 1946 | 1946 | |
| 1947 | - case PCLZIP_ATT_FILE_MTIME : |
|
| 1948 | - if (!is_integer($v_value)) { |
|
| 1949 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". Integer expected for attribute '".PclZipUtilOptionText($v_key)."'"); |
|
| 1950 | - return PclZip::errorCode(); |
|
| 1951 | - } |
|
| 1947 | + case PCLZIP_ATT_FILE_MTIME : |
|
| 1948 | + if (!is_integer($v_value)) { |
|
| 1949 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". Integer expected for attribute '".PclZipUtilOptionText($v_key)."'"); |
|
| 1950 | + return PclZip::errorCode(); |
|
| 1951 | + } |
|
| 1952 | 1952 | |
| 1953 | - $p_filedescr['mtime'] = $v_value; |
|
| 1954 | - break; |
|
| 1953 | + $p_filedescr['mtime'] = $v_value; |
|
| 1954 | + break; |
|
| 1955 | 1955 | |
| 1956 | - case PCLZIP_ATT_FILE_CONTENT : |
|
| 1957 | - $p_filedescr['content'] = $v_value; |
|
| 1958 | - break; |
|
| 1956 | + case PCLZIP_ATT_FILE_CONTENT : |
|
| 1957 | + $p_filedescr['content'] = $v_value; |
|
| 1958 | + break; |
|
| 1959 | 1959 | |
| 1960 | - default : |
|
| 1961 | - // ----- Error log |
|
| 1962 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, |
|
| 1963 | - "Unknown parameter '".$v_key."'"); |
|
| 1960 | + default : |
|
| 1961 | + // ----- Error log |
|
| 1962 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, |
|
| 1963 | + "Unknown parameter '".$v_key."'"); |
|
| 1964 | 1964 | |
| 1965 | - // ----- Return |
|
| 1966 | - return PclZip::errorCode(); |
|
| 1967 | - } |
|
| 1965 | + // ----- Return |
|
| 1966 | + return PclZip::errorCode(); |
|
| 1967 | + } |
|
| 1968 | 1968 | |
| 1969 | - // ----- Look for mandatory options |
|
| 1970 | - if ($v_requested_options !== false) { |
|
| 1971 | - for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) { |
|
| 1972 | - // ----- Look for mandatory option |
|
| 1973 | - if ($v_requested_options[$key] == 'mandatory') { |
|
| 1974 | - // ----- Look if present |
|
| 1975 | - if (!isset($p_file_list[$key])) { |
|
| 1976 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")"); |
|
| 1977 | - return PclZip::errorCode(); |
|
| 1978 | - } |
|
| 1979 | - } |
|
| 1980 | - } |
|
| 1981 | - } |
|
| 1969 | + // ----- Look for mandatory options |
|
| 1970 | + if ($v_requested_options !== false) { |
|
| 1971 | + for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) { |
|
| 1972 | + // ----- Look for mandatory option |
|
| 1973 | + if ($v_requested_options[$key] == 'mandatory') { |
|
| 1974 | + // ----- Look if present |
|
| 1975 | + if (!isset($p_file_list[$key])) { |
|
| 1976 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")"); |
|
| 1977 | + return PclZip::errorCode(); |
|
| 1978 | + } |
|
| 1979 | + } |
|
| 1980 | + } |
|
| 1981 | + } |
|
| 1982 | 1982 | |
| 1983 | - // end foreach |
|
| 1984 | - } |
|
| 1983 | + // end foreach |
|
| 1984 | + } |
|
| 1985 | 1985 | |
| 1986 | - // ----- Return |
|
| 1987 | - return $v_result; |
|
| 1986 | + // ----- Return |
|
| 1987 | + return $v_result; |
|
| 1988 | 1988 | } |
| 1989 | 1989 | // -------------------------------------------------------------------------------- |
| 1990 | 1990 | |
@@ -2004,120 +2004,120 @@ discard block |
||
| 2004 | 2004 | // -------------------------------------------------------------------------------- |
| 2005 | 2005 | function privFileDescrExpand(&$p_filedescr_list, &$p_options) |
| 2006 | 2006 | { |
| 2007 | - $v_result=1; |
|
| 2007 | + $v_result=1; |
|
| 2008 | 2008 | |
| 2009 | - // ----- Create a result list |
|
| 2010 | - $v_result_list = array(); |
|
| 2009 | + // ----- Create a result list |
|
| 2010 | + $v_result_list = array(); |
|
| 2011 | 2011 | |
| 2012 | - // ----- Look each entry |
|
| 2013 | - for ($i=0; $i<sizeof($p_filedescr_list); $i++) { |
|
| 2012 | + // ----- Look each entry |
|
| 2013 | + for ($i=0; $i<sizeof($p_filedescr_list); $i++) { |
|
| 2014 | 2014 | |
| 2015 | - // ----- Get filedescr |
|
| 2016 | - $v_descr = $p_filedescr_list[$i]; |
|
| 2015 | + // ----- Get filedescr |
|
| 2016 | + $v_descr = $p_filedescr_list[$i]; |
|
| 2017 | 2017 | |
| 2018 | - // ----- Reduce the filename |
|
| 2019 | - $v_descr['filename'] = PclZipUtilTranslateWinPath($v_descr['filename'], false); |
|
| 2020 | - $v_descr['filename'] = PclZipUtilPathReduction($v_descr['filename']); |
|
| 2018 | + // ----- Reduce the filename |
|
| 2019 | + $v_descr['filename'] = PclZipUtilTranslateWinPath($v_descr['filename'], false); |
|
| 2020 | + $v_descr['filename'] = PclZipUtilPathReduction($v_descr['filename']); |
|
| 2021 | 2021 | |
| 2022 | - // ----- Look for real file or folder |
|
| 2023 | - if (file_exists($v_descr['filename'])) { |
|
| 2024 | - if (@is_file($v_descr['filename'])) { |
|
| 2025 | - $v_descr['type'] = 'file'; |
|
| 2026 | - } |
|
| 2027 | - else if (@is_dir($v_descr['filename'])) { |
|
| 2028 | - $v_descr['type'] = 'folder'; |
|
| 2029 | - } |
|
| 2030 | - else if (@is_link($v_descr['filename'])) { |
|
| 2031 | - // skip |
|
| 2032 | - continue; |
|
| 2033 | - } |
|
| 2034 | - else { |
|
| 2035 | - // skip |
|
| 2036 | - continue; |
|
| 2037 | - } |
|
| 2038 | - } |
|
| 2022 | + // ----- Look for real file or folder |
|
| 2023 | + if (file_exists($v_descr['filename'])) { |
|
| 2024 | + if (@is_file($v_descr['filename'])) { |
|
| 2025 | + $v_descr['type'] = 'file'; |
|
| 2026 | + } |
|
| 2027 | + else if (@is_dir($v_descr['filename'])) { |
|
| 2028 | + $v_descr['type'] = 'folder'; |
|
| 2029 | + } |
|
| 2030 | + else if (@is_link($v_descr['filename'])) { |
|
| 2031 | + // skip |
|
| 2032 | + continue; |
|
| 2033 | + } |
|
| 2034 | + else { |
|
| 2035 | + // skip |
|
| 2036 | + continue; |
|
| 2037 | + } |
|
| 2038 | + } |
|
| 2039 | 2039 | |
| 2040 | - // ----- Look for string added as file |
|
| 2041 | - else if (isset($v_descr['content'])) { |
|
| 2042 | - $v_descr['type'] = 'virtual_file'; |
|
| 2043 | - } |
|
| 2040 | + // ----- Look for string added as file |
|
| 2041 | + else if (isset($v_descr['content'])) { |
|
| 2042 | + $v_descr['type'] = 'virtual_file'; |
|
| 2043 | + } |
|
| 2044 | 2044 | |
| 2045 | - // ----- Missing file |
|
| 2046 | - else { |
|
| 2047 | - // ----- Error log |
|
| 2048 | - PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$v_descr['filename']."' does not exist"); |
|
| 2045 | + // ----- Missing file |
|
| 2046 | + else { |
|
| 2047 | + // ----- Error log |
|
| 2048 | + PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$v_descr['filename']."' does not exist"); |
|
| 2049 | 2049 | |
| 2050 | - // ----- Return |
|
| 2051 | - return PclZip::errorCode(); |
|
| 2052 | - } |
|
| 2050 | + // ----- Return |
|
| 2051 | + return PclZip::errorCode(); |
|
| 2052 | + } |
|
| 2053 | 2053 | |
| 2054 | - // ----- Calculate the stored filename |
|
| 2055 | - $this->privCalculateStoredFilename($v_descr, $p_options); |
|
| 2054 | + // ----- Calculate the stored filename |
|
| 2055 | + $this->privCalculateStoredFilename($v_descr, $p_options); |
|
| 2056 | 2056 | |
| 2057 | - // ----- Add the descriptor in result list |
|
| 2058 | - $v_result_list[sizeof($v_result_list)] = $v_descr; |
|
| 2057 | + // ----- Add the descriptor in result list |
|
| 2058 | + $v_result_list[sizeof($v_result_list)] = $v_descr; |
|
| 2059 | 2059 | |
| 2060 | - // ----- Look for folder |
|
| 2061 | - if ($v_descr['type'] == 'folder') { |
|
| 2062 | - // ----- List of items in folder |
|
| 2063 | - $v_dirlist_descr = array(); |
|
| 2064 | - $v_dirlist_nb = 0; |
|
| 2065 | - if ($v_folder_handler = @opendir($v_descr['filename'])) { |
|
| 2066 | - while (($v_item_handler = @readdir($v_folder_handler)) !== false) { |
|
| 2067 | - |
|
| 2068 | - // ----- Skip '.' and '..' |
|
| 2069 | - if (($v_item_handler == '.') || ($v_item_handler == '..')) { |
|
| 2070 | - continue; |
|
| 2071 | - } |
|
| 2060 | + // ----- Look for folder |
|
| 2061 | + if ($v_descr['type'] == 'folder') { |
|
| 2062 | + // ----- List of items in folder |
|
| 2063 | + $v_dirlist_descr = array(); |
|
| 2064 | + $v_dirlist_nb = 0; |
|
| 2065 | + if ($v_folder_handler = @opendir($v_descr['filename'])) { |
|
| 2066 | + while (($v_item_handler = @readdir($v_folder_handler)) !== false) { |
|
| 2067 | + |
|
| 2068 | + // ----- Skip '.' and '..' |
|
| 2069 | + if (($v_item_handler == '.') || ($v_item_handler == '..')) { |
|
| 2070 | + continue; |
|
| 2071 | + } |
|
| 2072 | 2072 | |
| 2073 | - // ----- Compose the full filename |
|
| 2074 | - $v_dirlist_descr[$v_dirlist_nb]['filename'] = $v_descr['filename'].'/'.$v_item_handler; |
|
| 2073 | + // ----- Compose the full filename |
|
| 2074 | + $v_dirlist_descr[$v_dirlist_nb]['filename'] = $v_descr['filename'].'/'.$v_item_handler; |
|
| 2075 | 2075 | |
| 2076 | - // ----- Look for different stored filename |
|
| 2077 | - // Because the name of the folder was changed, the name of the |
|
| 2078 | - // files/sub-folders also change |
|
| 2079 | - if (($v_descr['stored_filename'] != $v_descr['filename']) |
|
| 2080 | - && (!isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))) { |
|
| 2081 | - if ($v_descr['stored_filename'] != '') { |
|
| 2082 | - $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_descr['stored_filename'].'/'.$v_item_handler; |
|
| 2083 | - } |
|
| 2084 | - else { |
|
| 2085 | - $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_item_handler; |
|
| 2086 | - } |
|
| 2087 | - } |
|
| 2076 | + // ----- Look for different stored filename |
|
| 2077 | + // Because the name of the folder was changed, the name of the |
|
| 2078 | + // files/sub-folders also change |
|
| 2079 | + if (($v_descr['stored_filename'] != $v_descr['filename']) |
|
| 2080 | + && (!isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))) { |
|
| 2081 | + if ($v_descr['stored_filename'] != '') { |
|
| 2082 | + $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_descr['stored_filename'].'/'.$v_item_handler; |
|
| 2083 | + } |
|
| 2084 | + else { |
|
| 2085 | + $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_item_handler; |
|
| 2086 | + } |
|
| 2087 | + } |
|
| 2088 | 2088 | |
| 2089 | - $v_dirlist_nb++; |
|
| 2090 | - } |
|
| 2089 | + $v_dirlist_nb++; |
|
| 2090 | + } |
|
| 2091 | 2091 | |
| 2092 | - @closedir($v_folder_handler); |
|
| 2093 | - } |
|
| 2094 | - else { |
|
| 2095 | - // TBC : unable to open folder in read mode |
|
| 2096 | - } |
|
| 2092 | + @closedir($v_folder_handler); |
|
| 2093 | + } |
|
| 2094 | + else { |
|
| 2095 | + // TBC : unable to open folder in read mode |
|
| 2096 | + } |
|
| 2097 | 2097 | |
| 2098 | - // ----- Expand each element of the list |
|
| 2099 | - if ($v_dirlist_nb != 0) { |
|
| 2100 | - // ----- Expand |
|
| 2101 | - if (($v_result = $this->privFileDescrExpand($v_dirlist_descr, $p_options)) != 1) { |
|
| 2102 | - return $v_result; |
|
| 2103 | - } |
|
| 2098 | + // ----- Expand each element of the list |
|
| 2099 | + if ($v_dirlist_nb != 0) { |
|
| 2100 | + // ----- Expand |
|
| 2101 | + if (($v_result = $this->privFileDescrExpand($v_dirlist_descr, $p_options)) != 1) { |
|
| 2102 | + return $v_result; |
|
| 2103 | + } |
|
| 2104 | 2104 | |
| 2105 | - // ----- Concat the resulting list |
|
| 2106 | - $v_result_list = array_merge($v_result_list, $v_dirlist_descr); |
|
| 2107 | - } |
|
| 2108 | - else { |
|
| 2109 | - } |
|
| 2105 | + // ----- Concat the resulting list |
|
| 2106 | + $v_result_list = array_merge($v_result_list, $v_dirlist_descr); |
|
| 2107 | + } |
|
| 2108 | + else { |
|
| 2109 | + } |
|
| 2110 | 2110 | |
| 2111 | - // ----- Free local array |
|
| 2112 | - unset($v_dirlist_descr); |
|
| 2113 | - } |
|
| 2114 | - } |
|
| 2111 | + // ----- Free local array |
|
| 2112 | + unset($v_dirlist_descr); |
|
| 2113 | + } |
|
| 2114 | + } |
|
| 2115 | 2115 | |
| 2116 | - // ----- Get the result list |
|
| 2117 | - $p_filedescr_list = $v_result_list; |
|
| 2116 | + // ----- Get the result list |
|
| 2117 | + $p_filedescr_list = $v_result_list; |
|
| 2118 | 2118 | |
| 2119 | - // ----- Return |
|
| 2120 | - return $v_result; |
|
| 2119 | + // ----- Return |
|
| 2120 | + return $v_result; |
|
| 2121 | 2121 | } |
| 2122 | 2122 | // -------------------------------------------------------------------------------- |
| 2123 | 2123 | |
@@ -2129,30 +2129,30 @@ discard block |
||
| 2129 | 2129 | // -------------------------------------------------------------------------------- |
| 2130 | 2130 | function privCreate($p_filedescr_list, &$p_result_list, &$p_options) |
| 2131 | 2131 | { |
| 2132 | - $v_result=1; |
|
| 2133 | - $v_list_detail = array(); |
|
| 2132 | + $v_result=1; |
|
| 2133 | + $v_list_detail = array(); |
|
| 2134 | 2134 | |
| 2135 | - // ----- Magic quotes trick |
|
| 2136 | - $this->privDisableMagicQuotes(); |
|
| 2137 | - |
|
| 2138 | - // ----- Open the file in write mode |
|
| 2139 | - if (($v_result = $this->privOpenFd('wb')) != 1) |
|
| 2140 | - { |
|
| 2141 | - // ----- Return |
|
| 2142 | - return $v_result; |
|
| 2143 | - } |
|
| 2135 | + // ----- Magic quotes trick |
|
| 2136 | + $this->privDisableMagicQuotes(); |
|
| 2137 | + |
|
| 2138 | + // ----- Open the file in write mode |
|
| 2139 | + if (($v_result = $this->privOpenFd('wb')) != 1) |
|
| 2140 | + { |
|
| 2141 | + // ----- Return |
|
| 2142 | + return $v_result; |
|
| 2143 | + } |
|
| 2144 | 2144 | |
| 2145 | - // ----- Add the list of files |
|
| 2146 | - $v_result = $this->privAddList($p_filedescr_list, $p_result_list, $p_options); |
|
| 2145 | + // ----- Add the list of files |
|
| 2146 | + $v_result = $this->privAddList($p_filedescr_list, $p_result_list, $p_options); |
|
| 2147 | 2147 | |
| 2148 | - // ----- Close |
|
| 2149 | - $this->privCloseFd(); |
|
| 2148 | + // ----- Close |
|
| 2149 | + $this->privCloseFd(); |
|
| 2150 | 2150 | |
| 2151 | - // ----- Magic quotes trick |
|
| 2152 | - $this->privSwapBackMagicQuotes(); |
|
| 2151 | + // ----- Magic quotes trick |
|
| 2152 | + $this->privSwapBackMagicQuotes(); |
|
| 2153 | 2153 | |
| 2154 | - // ----- Return |
|
| 2155 | - return $v_result; |
|
| 2154 | + // ----- Return |
|
| 2155 | + return $v_result; |
|
| 2156 | 2156 | } |
| 2157 | 2157 | // -------------------------------------------------------------------------------- |
| 2158 | 2158 | |
@@ -2164,175 +2164,175 @@ discard block |
||
| 2164 | 2164 | // -------------------------------------------------------------------------------- |
| 2165 | 2165 | function privAdd($p_filedescr_list, &$p_result_list, &$p_options) |
| 2166 | 2166 | { |
| 2167 | - $v_result=1; |
|
| 2168 | - $v_list_detail = array(); |
|
| 2167 | + $v_result=1; |
|
| 2168 | + $v_list_detail = array(); |
|
| 2169 | 2169 | |
| 2170 | - // ----- Look if the archive exists or is empty |
|
| 2171 | - if ((!is_file($this->zipname)) || (filesize($this->zipname) == 0)) |
|
| 2172 | - { |
|
| 2170 | + // ----- Look if the archive exists or is empty |
|
| 2171 | + if ((!is_file($this->zipname)) || (filesize($this->zipname) == 0)) |
|
| 2172 | + { |
|
| 2173 | 2173 | |
| 2174 | - // ----- Do a create |
|
| 2175 | - $v_result = $this->privCreate($p_filedescr_list, $p_result_list, $p_options); |
|
| 2174 | + // ----- Do a create |
|
| 2175 | + $v_result = $this->privCreate($p_filedescr_list, $p_result_list, $p_options); |
|
| 2176 | 2176 | |
| 2177 | - // ----- Return |
|
| 2178 | - return $v_result; |
|
| 2179 | - } |
|
| 2180 | - // ----- Magic quotes trick |
|
| 2181 | - $this->privDisableMagicQuotes(); |
|
| 2177 | + // ----- Return |
|
| 2178 | + return $v_result; |
|
| 2179 | + } |
|
| 2180 | + // ----- Magic quotes trick |
|
| 2181 | + $this->privDisableMagicQuotes(); |
|
| 2182 | 2182 | |
| 2183 | - // ----- Open the zip file |
|
| 2184 | - if (($v_result=$this->privOpenFd('rb')) != 1) |
|
| 2185 | - { |
|
| 2186 | - // ----- Magic quotes trick |
|
| 2187 | - $this->privSwapBackMagicQuotes(); |
|
| 2183 | + // ----- Open the zip file |
|
| 2184 | + if (($v_result=$this->privOpenFd('rb')) != 1) |
|
| 2185 | + { |
|
| 2186 | + // ----- Magic quotes trick |
|
| 2187 | + $this->privSwapBackMagicQuotes(); |
|
| 2188 | 2188 | |
| 2189 | - // ----- Return |
|
| 2190 | - return $v_result; |
|
| 2191 | - } |
|
| 2189 | + // ----- Return |
|
| 2190 | + return $v_result; |
|
| 2191 | + } |
|
| 2192 | 2192 | |
| 2193 | - // ----- Read the central directory informations |
|
| 2194 | - $v_central_dir = array(); |
|
| 2195 | - if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) |
|
| 2196 | - { |
|
| 2197 | - $this->privCloseFd(); |
|
| 2198 | - $this->privSwapBackMagicQuotes(); |
|
| 2199 | - return $v_result; |
|
| 2200 | - } |
|
| 2193 | + // ----- Read the central directory informations |
|
| 2194 | + $v_central_dir = array(); |
|
| 2195 | + if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) |
|
| 2196 | + { |
|
| 2197 | + $this->privCloseFd(); |
|
| 2198 | + $this->privSwapBackMagicQuotes(); |
|
| 2199 | + return $v_result; |
|
| 2200 | + } |
|
| 2201 | 2201 | |
| 2202 | - // ----- Go to beginning of File |
|
| 2203 | - @rewind($this->zip_fd); |
|
| 2202 | + // ----- Go to beginning of File |
|
| 2203 | + @rewind($this->zip_fd); |
|
| 2204 | 2204 | |
| 2205 | - // ----- Creates a temporay file |
|
| 2206 | - $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp'; |
|
| 2205 | + // ----- Creates a temporay file |
|
| 2206 | + $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp'; |
|
| 2207 | 2207 | |
| 2208 | - // ----- Open the temporary file in write mode |
|
| 2209 | - if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0) |
|
| 2210 | - { |
|
| 2211 | - $this->privCloseFd(); |
|
| 2212 | - $this->privSwapBackMagicQuotes(); |
|
| 2208 | + // ----- Open the temporary file in write mode |
|
| 2209 | + if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0) |
|
| 2210 | + { |
|
| 2211 | + $this->privCloseFd(); |
|
| 2212 | + $this->privSwapBackMagicQuotes(); |
|
| 2213 | 2213 | |
| 2214 | - PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode'); |
|
| 2214 | + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode'); |
|
| 2215 | 2215 | |
| 2216 | - // ----- Return |
|
| 2217 | - return PclZip::errorCode(); |
|
| 2218 | - } |
|
| 2216 | + // ----- Return |
|
| 2217 | + return PclZip::errorCode(); |
|
| 2218 | + } |
|
| 2219 | 2219 | |
| 2220 | - // ----- Copy the files from the archive to the temporary file |
|
| 2221 | - // TBC : Here I should better append the file and go back to erase the central dir |
|
| 2222 | - $v_size = $v_central_dir['offset']; |
|
| 2223 | - while ($v_size != 0) |
|
| 2224 | - { |
|
| 2225 | - $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 2226 | - $v_buffer = fread($this->zip_fd, $v_read_size); |
|
| 2227 | - @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); |
|
| 2228 | - $v_size -= $v_read_size; |
|
| 2229 | - } |
|
| 2220 | + // ----- Copy the files from the archive to the temporary file |
|
| 2221 | + // TBC : Here I should better append the file and go back to erase the central dir |
|
| 2222 | + $v_size = $v_central_dir['offset']; |
|
| 2223 | + while ($v_size != 0) |
|
| 2224 | + { |
|
| 2225 | + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 2226 | + $v_buffer = fread($this->zip_fd, $v_read_size); |
|
| 2227 | + @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); |
|
| 2228 | + $v_size -= $v_read_size; |
|
| 2229 | + } |
|
| 2230 | 2230 | |
| 2231 | - // ----- Swap the file descriptor |
|
| 2232 | - // Here is a trick : I swap the temporary fd with the zip fd, in order to use |
|
| 2233 | - // the following methods on the temporary fil and not the real archive |
|
| 2234 | - $v_swap = $this->zip_fd; |
|
| 2235 | - $this->zip_fd = $v_zip_temp_fd; |
|
| 2236 | - $v_zip_temp_fd = $v_swap; |
|
| 2237 | - |
|
| 2238 | - // ----- Add the files |
|
| 2239 | - $v_header_list = array(); |
|
| 2240 | - if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1) |
|
| 2241 | - { |
|
| 2242 | - fclose($v_zip_temp_fd); |
|
| 2243 | - $this->privCloseFd(); |
|
| 2244 | - @unlink($v_zip_temp_name); |
|
| 2245 | - $this->privSwapBackMagicQuotes(); |
|
| 2246 | - |
|
| 2247 | - // ----- Return |
|
| 2248 | - return $v_result; |
|
| 2249 | - } |
|
| 2231 | + // ----- Swap the file descriptor |
|
| 2232 | + // Here is a trick : I swap the temporary fd with the zip fd, in order to use |
|
| 2233 | + // the following methods on the temporary fil and not the real archive |
|
| 2234 | + $v_swap = $this->zip_fd; |
|
| 2235 | + $this->zip_fd = $v_zip_temp_fd; |
|
| 2236 | + $v_zip_temp_fd = $v_swap; |
|
| 2237 | + |
|
| 2238 | + // ----- Add the files |
|
| 2239 | + $v_header_list = array(); |
|
| 2240 | + if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1) |
|
| 2241 | + { |
|
| 2242 | + fclose($v_zip_temp_fd); |
|
| 2243 | + $this->privCloseFd(); |
|
| 2244 | + @unlink($v_zip_temp_name); |
|
| 2245 | + $this->privSwapBackMagicQuotes(); |
|
| 2246 | + |
|
| 2247 | + // ----- Return |
|
| 2248 | + return $v_result; |
|
| 2249 | + } |
|
| 2250 | 2250 | |
| 2251 | - // ----- Store the offset of the central dir |
|
| 2252 | - $v_offset = @ftell($this->zip_fd); |
|
| 2253 | - |
|
| 2254 | - // ----- Copy the block of file headers from the old archive |
|
| 2255 | - $v_size = $v_central_dir['size']; |
|
| 2256 | - while ($v_size != 0) |
|
| 2257 | - { |
|
| 2258 | - $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 2259 | - $v_buffer = @fread($v_zip_temp_fd, $v_read_size); |
|
| 2260 | - @fwrite($this->zip_fd, $v_buffer, $v_read_size); |
|
| 2261 | - $v_size -= $v_read_size; |
|
| 2262 | - } |
|
| 2251 | + // ----- Store the offset of the central dir |
|
| 2252 | + $v_offset = @ftell($this->zip_fd); |
|
| 2253 | + |
|
| 2254 | + // ----- Copy the block of file headers from the old archive |
|
| 2255 | + $v_size = $v_central_dir['size']; |
|
| 2256 | + while ($v_size != 0) |
|
| 2257 | + { |
|
| 2258 | + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 2259 | + $v_buffer = @fread($v_zip_temp_fd, $v_read_size); |
|
| 2260 | + @fwrite($this->zip_fd, $v_buffer, $v_read_size); |
|
| 2261 | + $v_size -= $v_read_size; |
|
| 2262 | + } |
|
| 2263 | 2263 | |
| 2264 | - // ----- Create the Central Dir files header |
|
| 2265 | - for ($i=0, $v_count=0; $i<sizeof($v_header_list); $i++) |
|
| 2266 | - { |
|
| 2267 | - // ----- Create the file header |
|
| 2268 | - if ($v_header_list[$i]['status'] == 'ok') { |
|
| 2269 | - if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) { |
|
| 2270 | - fclose($v_zip_temp_fd); |
|
| 2271 | - $this->privCloseFd(); |
|
| 2272 | - @unlink($v_zip_temp_name); |
|
| 2273 | - $this->privSwapBackMagicQuotes(); |
|
| 2274 | - |
|
| 2275 | - // ----- Return |
|
| 2276 | - return $v_result; |
|
| 2277 | - } |
|
| 2278 | - $v_count++; |
|
| 2279 | - } |
|
| 2264 | + // ----- Create the Central Dir files header |
|
| 2265 | + for ($i=0, $v_count=0; $i<sizeof($v_header_list); $i++) |
|
| 2266 | + { |
|
| 2267 | + // ----- Create the file header |
|
| 2268 | + if ($v_header_list[$i]['status'] == 'ok') { |
|
| 2269 | + if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) { |
|
| 2270 | + fclose($v_zip_temp_fd); |
|
| 2271 | + $this->privCloseFd(); |
|
| 2272 | + @unlink($v_zip_temp_name); |
|
| 2273 | + $this->privSwapBackMagicQuotes(); |
|
| 2274 | + |
|
| 2275 | + // ----- Return |
|
| 2276 | + return $v_result; |
|
| 2277 | + } |
|
| 2278 | + $v_count++; |
|
| 2279 | + } |
|
| 2280 | 2280 | |
| 2281 | - // ----- Transform the header to a 'usable' info |
|
| 2282 | - $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]); |
|
| 2283 | - } |
|
| 2281 | + // ----- Transform the header to a 'usable' info |
|
| 2282 | + $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]); |
|
| 2283 | + } |
|
| 2284 | 2284 | |
| 2285 | - // ----- Zip file comment |
|
| 2286 | - $v_comment = $v_central_dir['comment']; |
|
| 2287 | - if (isset($p_options[PCLZIP_OPT_COMMENT])) { |
|
| 2288 | - $v_comment = $p_options[PCLZIP_OPT_COMMENT]; |
|
| 2289 | - } |
|
| 2290 | - if (isset($p_options[PCLZIP_OPT_ADD_COMMENT])) { |
|
| 2291 | - $v_comment = $v_comment.$p_options[PCLZIP_OPT_ADD_COMMENT]; |
|
| 2292 | - } |
|
| 2293 | - if (isset($p_options[PCLZIP_OPT_PREPEND_COMMENT])) { |
|
| 2294 | - $v_comment = $p_options[PCLZIP_OPT_PREPEND_COMMENT].$v_comment; |
|
| 2295 | - } |
|
| 2285 | + // ----- Zip file comment |
|
| 2286 | + $v_comment = $v_central_dir['comment']; |
|
| 2287 | + if (isset($p_options[PCLZIP_OPT_COMMENT])) { |
|
| 2288 | + $v_comment = $p_options[PCLZIP_OPT_COMMENT]; |
|
| 2289 | + } |
|
| 2290 | + if (isset($p_options[PCLZIP_OPT_ADD_COMMENT])) { |
|
| 2291 | + $v_comment = $v_comment.$p_options[PCLZIP_OPT_ADD_COMMENT]; |
|
| 2292 | + } |
|
| 2293 | + if (isset($p_options[PCLZIP_OPT_PREPEND_COMMENT])) { |
|
| 2294 | + $v_comment = $p_options[PCLZIP_OPT_PREPEND_COMMENT].$v_comment; |
|
| 2295 | + } |
|
| 2296 | 2296 | |
| 2297 | - // ----- Calculate the size of the central header |
|
| 2298 | - $v_size = @ftell($this->zip_fd)-$v_offset; |
|
| 2297 | + // ----- Calculate the size of the central header |
|
| 2298 | + $v_size = @ftell($this->zip_fd)-$v_offset; |
|
| 2299 | 2299 | |
| 2300 | - // ----- Create the central dir footer |
|
| 2301 | - if (($v_result = $this->privWriteCentralHeader($v_count+$v_central_dir['entries'], $v_size, $v_offset, $v_comment)) != 1) |
|
| 2302 | - { |
|
| 2303 | - // ----- Reset the file list |
|
| 2304 | - unset($v_header_list); |
|
| 2305 | - $this->privSwapBackMagicQuotes(); |
|
| 2300 | + // ----- Create the central dir footer |
|
| 2301 | + if (($v_result = $this->privWriteCentralHeader($v_count+$v_central_dir['entries'], $v_size, $v_offset, $v_comment)) != 1) |
|
| 2302 | + { |
|
| 2303 | + // ----- Reset the file list |
|
| 2304 | + unset($v_header_list); |
|
| 2305 | + $this->privSwapBackMagicQuotes(); |
|
| 2306 | 2306 | |
| 2307 | - // ----- Return |
|
| 2308 | - return $v_result; |
|
| 2309 | - } |
|
| 2307 | + // ----- Return |
|
| 2308 | + return $v_result; |
|
| 2309 | + } |
|
| 2310 | 2310 | |
| 2311 | - // ----- Swap back the file descriptor |
|
| 2312 | - $v_swap = $this->zip_fd; |
|
| 2313 | - $this->zip_fd = $v_zip_temp_fd; |
|
| 2314 | - $v_zip_temp_fd = $v_swap; |
|
| 2311 | + // ----- Swap back the file descriptor |
|
| 2312 | + $v_swap = $this->zip_fd; |
|
| 2313 | + $this->zip_fd = $v_zip_temp_fd; |
|
| 2314 | + $v_zip_temp_fd = $v_swap; |
|
| 2315 | 2315 | |
| 2316 | - // ----- Close |
|
| 2317 | - $this->privCloseFd(); |
|
| 2316 | + // ----- Close |
|
| 2317 | + $this->privCloseFd(); |
|
| 2318 | 2318 | |
| 2319 | - // ----- Close the temporary file |
|
| 2320 | - @fclose($v_zip_temp_fd); |
|
| 2319 | + // ----- Close the temporary file |
|
| 2320 | + @fclose($v_zip_temp_fd); |
|
| 2321 | 2321 | |
| 2322 | - // ----- Magic quotes trick |
|
| 2323 | - $this->privSwapBackMagicQuotes(); |
|
| 2322 | + // ----- Magic quotes trick |
|
| 2323 | + $this->privSwapBackMagicQuotes(); |
|
| 2324 | 2324 | |
| 2325 | - // ----- Delete the zip file |
|
| 2326 | - // TBC : I should test the result ... |
|
| 2327 | - @unlink($this->zipname); |
|
| 2325 | + // ----- Delete the zip file |
|
| 2326 | + // TBC : I should test the result ... |
|
| 2327 | + @unlink($this->zipname); |
|
| 2328 | 2328 | |
| 2329 | - // ----- Rename the temporary file |
|
| 2330 | - // TBC : I should test the result ... |
|
| 2331 | - //@rename($v_zip_temp_name, $this->zipname); |
|
| 2332 | - PclZipUtilRename($v_zip_temp_name, $this->zipname); |
|
| 2329 | + // ----- Rename the temporary file |
|
| 2330 | + // TBC : I should test the result ... |
|
| 2331 | + //@rename($v_zip_temp_name, $this->zipname); |
|
| 2332 | + PclZipUtilRename($v_zip_temp_name, $this->zipname); |
|
| 2333 | 2333 | |
| 2334 | - // ----- Return |
|
| 2335 | - return $v_result; |
|
| 2334 | + // ----- Return |
|
| 2335 | + return $v_result; |
|
| 2336 | 2336 | } |
| 2337 | 2337 | // -------------------------------------------------------------------------------- |
| 2338 | 2338 | |
@@ -2343,30 +2343,30 @@ discard block |
||
| 2343 | 2343 | // -------------------------------------------------------------------------------- |
| 2344 | 2344 | function privOpenFd($p_mode) |
| 2345 | 2345 | { |
| 2346 | - $v_result=1; |
|
| 2346 | + $v_result=1; |
|
| 2347 | 2347 | |
| 2348 | - // ----- Look if already open |
|
| 2349 | - if ($this->zip_fd != 0) |
|
| 2350 | - { |
|
| 2351 | - // ----- Error log |
|
| 2352 | - PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Zip file \''.$this->zipname.'\' already open'); |
|
| 2348 | + // ----- Look if already open |
|
| 2349 | + if ($this->zip_fd != 0) |
|
| 2350 | + { |
|
| 2351 | + // ----- Error log |
|
| 2352 | + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Zip file \''.$this->zipname.'\' already open'); |
|
| 2353 | 2353 | |
| 2354 | - // ----- Return |
|
| 2355 | - return PclZip::errorCode(); |
|
| 2356 | - } |
|
| 2354 | + // ----- Return |
|
| 2355 | + return PclZip::errorCode(); |
|
| 2356 | + } |
|
| 2357 | 2357 | |
| 2358 | - // ----- Open the zip file |
|
| 2359 | - if (($this->zip_fd = @fopen($this->zipname, $p_mode)) == 0) |
|
| 2360 | - { |
|
| 2361 | - // ----- Error log |
|
| 2362 | - PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in '.$p_mode.' mode'); |
|
| 2358 | + // ----- Open the zip file |
|
| 2359 | + if (($this->zip_fd = @fopen($this->zipname, $p_mode)) == 0) |
|
| 2360 | + { |
|
| 2361 | + // ----- Error log |
|
| 2362 | + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in '.$p_mode.' mode'); |
|
| 2363 | 2363 | |
| 2364 | - // ----- Return |
|
| 2365 | - return PclZip::errorCode(); |
|
| 2366 | - } |
|
| 2364 | + // ----- Return |
|
| 2365 | + return PclZip::errorCode(); |
|
| 2366 | + } |
|
| 2367 | 2367 | |
| 2368 | - // ----- Return |
|
| 2369 | - return $v_result; |
|
| 2368 | + // ----- Return |
|
| 2369 | + return $v_result; |
|
| 2370 | 2370 | } |
| 2371 | 2371 | // -------------------------------------------------------------------------------- |
| 2372 | 2372 | |
@@ -2377,14 +2377,14 @@ discard block |
||
| 2377 | 2377 | // -------------------------------------------------------------------------------- |
| 2378 | 2378 | function privCloseFd() |
| 2379 | 2379 | { |
| 2380 | - $v_result=1; |
|
| 2380 | + $v_result=1; |
|
| 2381 | 2381 | |
| 2382 | - if ($this->zip_fd != 0) |
|
| 2383 | - @fclose($this->zip_fd); |
|
| 2384 | - $this->zip_fd = 0; |
|
| 2382 | + if ($this->zip_fd != 0) |
|
| 2383 | + @fclose($this->zip_fd); |
|
| 2384 | + $this->zip_fd = 0; |
|
| 2385 | 2385 | |
| 2386 | - // ----- Return |
|
| 2387 | - return $v_result; |
|
| 2386 | + // ----- Return |
|
| 2387 | + return $v_result; |
|
| 2388 | 2388 | } |
| 2389 | 2389 | // -------------------------------------------------------------------------------- |
| 2390 | 2390 | |
@@ -2404,56 +2404,56 @@ discard block |
||
| 2404 | 2404 | // function privAddList($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options) |
| 2405 | 2405 | function privAddList($p_filedescr_list, &$p_result_list, &$p_options) |
| 2406 | 2406 | { |
| 2407 | - $v_result=1; |
|
| 2408 | - |
|
| 2409 | - // ----- Add the files |
|
| 2410 | - $v_header_list = array(); |
|
| 2411 | - if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1) |
|
| 2412 | - { |
|
| 2413 | - // ----- Return |
|
| 2414 | - return $v_result; |
|
| 2415 | - } |
|
| 2407 | + $v_result=1; |
|
| 2408 | + |
|
| 2409 | + // ----- Add the files |
|
| 2410 | + $v_header_list = array(); |
|
| 2411 | + if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1) |
|
| 2412 | + { |
|
| 2413 | + // ----- Return |
|
| 2414 | + return $v_result; |
|
| 2415 | + } |
|
| 2416 | 2416 | |
| 2417 | - // ----- Store the offset of the central dir |
|
| 2418 | - $v_offset = @ftell($this->zip_fd); |
|
| 2419 | - |
|
| 2420 | - // ----- Create the Central Dir files header |
|
| 2421 | - for ($i=0,$v_count=0; $i<sizeof($v_header_list); $i++) |
|
| 2422 | - { |
|
| 2423 | - // ----- Create the file header |
|
| 2424 | - if ($v_header_list[$i]['status'] == 'ok') { |
|
| 2425 | - if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) { |
|
| 2426 | - // ----- Return |
|
| 2427 | - return $v_result; |
|
| 2428 | - } |
|
| 2429 | - $v_count++; |
|
| 2430 | - } |
|
| 2417 | + // ----- Store the offset of the central dir |
|
| 2418 | + $v_offset = @ftell($this->zip_fd); |
|
| 2419 | + |
|
| 2420 | + // ----- Create the Central Dir files header |
|
| 2421 | + for ($i=0,$v_count=0; $i<sizeof($v_header_list); $i++) |
|
| 2422 | + { |
|
| 2423 | + // ----- Create the file header |
|
| 2424 | + if ($v_header_list[$i]['status'] == 'ok') { |
|
| 2425 | + if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) { |
|
| 2426 | + // ----- Return |
|
| 2427 | + return $v_result; |
|
| 2428 | + } |
|
| 2429 | + $v_count++; |
|
| 2430 | + } |
|
| 2431 | 2431 | |
| 2432 | - // ----- Transform the header to a 'usable' info |
|
| 2433 | - $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]); |
|
| 2434 | - } |
|
| 2432 | + // ----- Transform the header to a 'usable' info |
|
| 2433 | + $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]); |
|
| 2434 | + } |
|
| 2435 | 2435 | |
| 2436 | - // ----- Zip file comment |
|
| 2437 | - $v_comment = ''; |
|
| 2438 | - if (isset($p_options[PCLZIP_OPT_COMMENT])) { |
|
| 2439 | - $v_comment = $p_options[PCLZIP_OPT_COMMENT]; |
|
| 2440 | - } |
|
| 2436 | + // ----- Zip file comment |
|
| 2437 | + $v_comment = ''; |
|
| 2438 | + if (isset($p_options[PCLZIP_OPT_COMMENT])) { |
|
| 2439 | + $v_comment = $p_options[PCLZIP_OPT_COMMENT]; |
|
| 2440 | + } |
|
| 2441 | 2441 | |
| 2442 | - // ----- Calculate the size of the central header |
|
| 2443 | - $v_size = @ftell($this->zip_fd)-$v_offset; |
|
| 2442 | + // ----- Calculate the size of the central header |
|
| 2443 | + $v_size = @ftell($this->zip_fd)-$v_offset; |
|
| 2444 | 2444 | |
| 2445 | - // ----- Create the central dir footer |
|
| 2446 | - if (($v_result = $this->privWriteCentralHeader($v_count, $v_size, $v_offset, $v_comment)) != 1) |
|
| 2447 | - { |
|
| 2448 | - // ----- Reset the file list |
|
| 2449 | - unset($v_header_list); |
|
| 2445 | + // ----- Create the central dir footer |
|
| 2446 | + if (($v_result = $this->privWriteCentralHeader($v_count, $v_size, $v_offset, $v_comment)) != 1) |
|
| 2447 | + { |
|
| 2448 | + // ----- Reset the file list |
|
| 2449 | + unset($v_header_list); |
|
| 2450 | 2450 | |
| 2451 | - // ----- Return |
|
| 2452 | - return $v_result; |
|
| 2453 | - } |
|
| 2451 | + // ----- Return |
|
| 2452 | + return $v_result; |
|
| 2453 | + } |
|
| 2454 | 2454 | |
| 2455 | - // ----- Return |
|
| 2456 | - return $v_result; |
|
| 2455 | + // ----- Return |
|
| 2456 | + return $v_result; |
|
| 2457 | 2457 | } |
| 2458 | 2458 | // -------------------------------------------------------------------------------- |
| 2459 | 2459 | |
@@ -2468,57 +2468,57 @@ discard block |
||
| 2468 | 2468 | // -------------------------------------------------------------------------------- |
| 2469 | 2469 | function privAddFileList($p_filedescr_list, &$p_result_list, &$p_options) |
| 2470 | 2470 | { |
| 2471 | - $v_result=1; |
|
| 2472 | - $v_header = array(); |
|
| 2471 | + $v_result=1; |
|
| 2472 | + $v_header = array(); |
|
| 2473 | 2473 | |
| 2474 | - // ----- Recuperate the current number of elt in list |
|
| 2475 | - $v_nb = sizeof($p_result_list); |
|
| 2474 | + // ----- Recuperate the current number of elt in list |
|
| 2475 | + $v_nb = sizeof($p_result_list); |
|
| 2476 | 2476 | |
| 2477 | - // ----- Loop on the files |
|
| 2478 | - for ($j=0; ($j<sizeof($p_filedescr_list)) && ($v_result==1); $j++) { |
|
| 2479 | - // ----- Format the filename |
|
| 2480 | - $p_filedescr_list[$j]['filename'] |
|
| 2481 | - = PclZipUtilTranslateWinPath($p_filedescr_list[$j]['filename'], false); |
|
| 2477 | + // ----- Loop on the files |
|
| 2478 | + for ($j=0; ($j<sizeof($p_filedescr_list)) && ($v_result==1); $j++) { |
|
| 2479 | + // ----- Format the filename |
|
| 2480 | + $p_filedescr_list[$j]['filename'] |
|
| 2481 | + = PclZipUtilTranslateWinPath($p_filedescr_list[$j]['filename'], false); |
|
| 2482 | 2482 | |
| 2483 | 2483 | |
| 2484 | - // ----- Skip empty file names |
|
| 2485 | - // TBC : Can this be possible ? not checked in DescrParseAtt ? |
|
| 2486 | - if ($p_filedescr_list[$j]['filename'] == "") { |
|
| 2487 | - continue; |
|
| 2488 | - } |
|
| 2484 | + // ----- Skip empty file names |
|
| 2485 | + // TBC : Can this be possible ? not checked in DescrParseAtt ? |
|
| 2486 | + if ($p_filedescr_list[$j]['filename'] == "") { |
|
| 2487 | + continue; |
|
| 2488 | + } |
|
| 2489 | 2489 | |
| 2490 | - // ----- Check the filename |
|
| 2491 | - if ( ($p_filedescr_list[$j]['type'] != 'virtual_file') |
|
| 2492 | - && (!file_exists($p_filedescr_list[$j]['filename']))) { |
|
| 2493 | - PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$p_filedescr_list[$j]['filename']."' does not exist"); |
|
| 2494 | - return PclZip::errorCode(); |
|
| 2495 | - } |
|
| 2490 | + // ----- Check the filename |
|
| 2491 | + if ( ($p_filedescr_list[$j]['type'] != 'virtual_file') |
|
| 2492 | + && (!file_exists($p_filedescr_list[$j]['filename']))) { |
|
| 2493 | + PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$p_filedescr_list[$j]['filename']."' does not exist"); |
|
| 2494 | + return PclZip::errorCode(); |
|
| 2495 | + } |
|
| 2496 | 2496 | |
| 2497 | - // ----- Look if it is a file or a dir with no all path remove option |
|
| 2498 | - // or a dir with all its path removed |
|
| 2497 | + // ----- Look if it is a file or a dir with no all path remove option |
|
| 2498 | + // or a dir with all its path removed |
|
| 2499 | 2499 | // if ( (is_file($p_filedescr_list[$j]['filename'])) |
| 2500 | 2500 | // || ( is_dir($p_filedescr_list[$j]['filename']) |
| 2501 | - if ( ($p_filedescr_list[$j]['type'] == 'file') |
|
| 2502 | - || ($p_filedescr_list[$j]['type'] == 'virtual_file') |
|
| 2503 | - || ( ($p_filedescr_list[$j]['type'] == 'folder') |
|
| 2504 | - && ( !isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH]) |
|
| 2505 | - || !$p_options[PCLZIP_OPT_REMOVE_ALL_PATH])) |
|
| 2506 | - ) { |
|
| 2507 | - |
|
| 2508 | - // ----- Add the file |
|
| 2509 | - $v_result = $this->privAddFile($p_filedescr_list[$j], $v_header, |
|
| 2510 | - $p_options); |
|
| 2511 | - if ($v_result != 1) { |
|
| 2512 | - return $v_result; |
|
| 2513 | - } |
|
| 2514 | - |
|
| 2515 | - // ----- Store the file infos |
|
| 2516 | - $p_result_list[$v_nb++] = $v_header; |
|
| 2517 | - } |
|
| 2518 | - } |
|
| 2501 | + if ( ($p_filedescr_list[$j]['type'] == 'file') |
|
| 2502 | + || ($p_filedescr_list[$j]['type'] == 'virtual_file') |
|
| 2503 | + || ( ($p_filedescr_list[$j]['type'] == 'folder') |
|
| 2504 | + && ( !isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH]) |
|
| 2505 | + || !$p_options[PCLZIP_OPT_REMOVE_ALL_PATH])) |
|
| 2506 | + ) { |
|
| 2507 | + |
|
| 2508 | + // ----- Add the file |
|
| 2509 | + $v_result = $this->privAddFile($p_filedescr_list[$j], $v_header, |
|
| 2510 | + $p_options); |
|
| 2511 | + if ($v_result != 1) { |
|
| 2512 | + return $v_result; |
|
| 2513 | + } |
|
| 2514 | + |
|
| 2515 | + // ----- Store the file infos |
|
| 2516 | + $p_result_list[$v_nb++] = $v_header; |
|
| 2517 | + } |
|
| 2518 | + } |
|
| 2519 | 2519 | |
| 2520 | - // ----- Return |
|
| 2521 | - return $v_result; |
|
| 2520 | + // ----- Return |
|
| 2521 | + return $v_result; |
|
| 2522 | 2522 | } |
| 2523 | 2523 | // -------------------------------------------------------------------------------- |
| 2524 | 2524 | |
@@ -2530,22 +2530,22 @@ discard block |
||
| 2530 | 2530 | // -------------------------------------------------------------------------------- |
| 2531 | 2531 | function privAddFile($p_filedescr, &$p_header, &$p_options) |
| 2532 | 2532 | { |
| 2533 | - $v_result=1; |
|
| 2533 | + $v_result=1; |
|
| 2534 | 2534 | |
| 2535 | - // ----- Working variable |
|
| 2536 | - $p_filename = $p_filedescr['filename']; |
|
| 2535 | + // ----- Working variable |
|
| 2536 | + $p_filename = $p_filedescr['filename']; |
|
| 2537 | 2537 | |
| 2538 | - // TBC : Already done in the fileAtt check ... ? |
|
| 2539 | - if ($p_filename == "") { |
|
| 2540 | - // ----- Error log |
|
| 2541 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file list parameter (invalid or empty list)"); |
|
| 2538 | + // TBC : Already done in the fileAtt check ... ? |
|
| 2539 | + if ($p_filename == "") { |
|
| 2540 | + // ----- Error log |
|
| 2541 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file list parameter (invalid or empty list)"); |
|
| 2542 | 2542 | |
| 2543 | - // ----- Return |
|
| 2544 | - return PclZip::errorCode(); |
|
| 2545 | - } |
|
| 2543 | + // ----- Return |
|
| 2544 | + return PclZip::errorCode(); |
|
| 2545 | + } |
|
| 2546 | 2546 | |
| 2547 | - // ----- Look for a stored different filename |
|
| 2548 | - /* TBC : Removed |
|
| 2547 | + // ----- Look for a stored different filename |
|
| 2548 | + /* TBC : Removed |
|
| 2549 | 2549 | if (isset($p_filedescr['stored_filename'])) { |
| 2550 | 2550 | $v_stored_filename = $p_filedescr['stored_filename']; |
| 2551 | 2551 | } |
@@ -2554,244 +2554,244 @@ discard block |
||
| 2554 | 2554 | } |
| 2555 | 2555 | */ |
| 2556 | 2556 | |
| 2557 | - // ----- Set the file properties |
|
| 2558 | - clearstatcache(); |
|
| 2559 | - $p_header['version'] = 20; |
|
| 2560 | - $p_header['version_extracted'] = 10; |
|
| 2561 | - $p_header['flag'] = 0; |
|
| 2562 | - $p_header['compression'] = 0; |
|
| 2563 | - $p_header['crc'] = 0; |
|
| 2564 | - $p_header['compressed_size'] = 0; |
|
| 2565 | - $p_header['filename_len'] = strlen($p_filename); |
|
| 2566 | - $p_header['extra_len'] = 0; |
|
| 2567 | - $p_header['disk'] = 0; |
|
| 2568 | - $p_header['internal'] = 0; |
|
| 2569 | - $p_header['offset'] = 0; |
|
| 2570 | - $p_header['filename'] = $p_filename; |
|
| 2557 | + // ----- Set the file properties |
|
| 2558 | + clearstatcache(); |
|
| 2559 | + $p_header['version'] = 20; |
|
| 2560 | + $p_header['version_extracted'] = 10; |
|
| 2561 | + $p_header['flag'] = 0; |
|
| 2562 | + $p_header['compression'] = 0; |
|
| 2563 | + $p_header['crc'] = 0; |
|
| 2564 | + $p_header['compressed_size'] = 0; |
|
| 2565 | + $p_header['filename_len'] = strlen($p_filename); |
|
| 2566 | + $p_header['extra_len'] = 0; |
|
| 2567 | + $p_header['disk'] = 0; |
|
| 2568 | + $p_header['internal'] = 0; |
|
| 2569 | + $p_header['offset'] = 0; |
|
| 2570 | + $p_header['filename'] = $p_filename; |
|
| 2571 | 2571 | // TBC : Removed $p_header['stored_filename'] = $v_stored_filename; |
| 2572 | - $p_header['stored_filename'] = $p_filedescr['stored_filename']; |
|
| 2573 | - $p_header['extra'] = ''; |
|
| 2574 | - $p_header['status'] = 'ok'; |
|
| 2575 | - $p_header['index'] = -1; |
|
| 2576 | - |
|
| 2577 | - // ----- Look for regular file |
|
| 2578 | - if ($p_filedescr['type']=='file') { |
|
| 2579 | - $p_header['external'] = 0x00000000; |
|
| 2580 | - $p_header['size'] = filesize($p_filename); |
|
| 2581 | - } |
|
| 2572 | + $p_header['stored_filename'] = $p_filedescr['stored_filename']; |
|
| 2573 | + $p_header['extra'] = ''; |
|
| 2574 | + $p_header['status'] = 'ok'; |
|
| 2575 | + $p_header['index'] = -1; |
|
| 2576 | + |
|
| 2577 | + // ----- Look for regular file |
|
| 2578 | + if ($p_filedescr['type']=='file') { |
|
| 2579 | + $p_header['external'] = 0x00000000; |
|
| 2580 | + $p_header['size'] = filesize($p_filename); |
|
| 2581 | + } |
|
| 2582 | 2582 | |
| 2583 | - // ----- Look for regular folder |
|
| 2584 | - else if ($p_filedescr['type']=='folder') { |
|
| 2585 | - $p_header['external'] = 0x00000010; |
|
| 2586 | - $p_header['mtime'] = filemtime($p_filename); |
|
| 2587 | - $p_header['size'] = filesize($p_filename); |
|
| 2588 | - } |
|
| 2583 | + // ----- Look for regular folder |
|
| 2584 | + else if ($p_filedescr['type']=='folder') { |
|
| 2585 | + $p_header['external'] = 0x00000010; |
|
| 2586 | + $p_header['mtime'] = filemtime($p_filename); |
|
| 2587 | + $p_header['size'] = filesize($p_filename); |
|
| 2588 | + } |
|
| 2589 | 2589 | |
| 2590 | - // ----- Look for virtual file |
|
| 2591 | - else if ($p_filedescr['type'] == 'virtual_file') { |
|
| 2592 | - $p_header['external'] = 0x00000000; |
|
| 2593 | - $p_header['size'] = strlen($p_filedescr['content']); |
|
| 2594 | - } |
|
| 2590 | + // ----- Look for virtual file |
|
| 2591 | + else if ($p_filedescr['type'] == 'virtual_file') { |
|
| 2592 | + $p_header['external'] = 0x00000000; |
|
| 2593 | + $p_header['size'] = strlen($p_filedescr['content']); |
|
| 2594 | + } |
|
| 2595 | 2595 | |
| 2596 | 2596 | |
| 2597 | - // ----- Look for filetime |
|
| 2598 | - if (isset($p_filedescr['mtime'])) { |
|
| 2599 | - $p_header['mtime'] = $p_filedescr['mtime']; |
|
| 2600 | - } |
|
| 2601 | - else if ($p_filedescr['type'] == 'virtual_file') { |
|
| 2602 | - $p_header['mtime'] = time(); |
|
| 2603 | - } |
|
| 2604 | - else { |
|
| 2605 | - $p_header['mtime'] = filemtime($p_filename); |
|
| 2606 | - } |
|
| 2597 | + // ----- Look for filetime |
|
| 2598 | + if (isset($p_filedescr['mtime'])) { |
|
| 2599 | + $p_header['mtime'] = $p_filedescr['mtime']; |
|
| 2600 | + } |
|
| 2601 | + else if ($p_filedescr['type'] == 'virtual_file') { |
|
| 2602 | + $p_header['mtime'] = time(); |
|
| 2603 | + } |
|
| 2604 | + else { |
|
| 2605 | + $p_header['mtime'] = filemtime($p_filename); |
|
| 2606 | + } |
|
| 2607 | 2607 | |
| 2608 | - // ------ Look for file comment |
|
| 2609 | - if (isset($p_filedescr['comment'])) { |
|
| 2610 | - $p_header['comment_len'] = strlen($p_filedescr['comment']); |
|
| 2611 | - $p_header['comment'] = $p_filedescr['comment']; |
|
| 2612 | - } |
|
| 2613 | - else { |
|
| 2614 | - $p_header['comment_len'] = 0; |
|
| 2615 | - $p_header['comment'] = ''; |
|
| 2616 | - } |
|
| 2608 | + // ------ Look for file comment |
|
| 2609 | + if (isset($p_filedescr['comment'])) { |
|
| 2610 | + $p_header['comment_len'] = strlen($p_filedescr['comment']); |
|
| 2611 | + $p_header['comment'] = $p_filedescr['comment']; |
|
| 2612 | + } |
|
| 2613 | + else { |
|
| 2614 | + $p_header['comment_len'] = 0; |
|
| 2615 | + $p_header['comment'] = ''; |
|
| 2616 | + } |
|
| 2617 | 2617 | |
| 2618 | - // ----- Look for pre-add callback |
|
| 2619 | - if (isset($p_options[PCLZIP_CB_PRE_ADD])) { |
|
| 2618 | + // ----- Look for pre-add callback |
|
| 2619 | + if (isset($p_options[PCLZIP_CB_PRE_ADD])) { |
|
| 2620 | 2620 | |
| 2621 | - // ----- Generate a local information |
|
| 2622 | - $v_local_header = array(); |
|
| 2623 | - $this->privConvertHeader2FileInfo($p_header, $v_local_header); |
|
| 2621 | + // ----- Generate a local information |
|
| 2622 | + $v_local_header = array(); |
|
| 2623 | + $this->privConvertHeader2FileInfo($p_header, $v_local_header); |
|
| 2624 | 2624 | |
| 2625 | - // ----- Call the callback |
|
| 2626 | - // Here I do not use call_user_func() because I need to send a reference to the |
|
| 2627 | - // header. |
|
| 2625 | + // ----- Call the callback |
|
| 2626 | + // Here I do not use call_user_func() because I need to send a reference to the |
|
| 2627 | + // header. |
|
| 2628 | 2628 | // eval('$v_result = '.$p_options[PCLZIP_CB_PRE_ADD].'(PCLZIP_CB_PRE_ADD, $v_local_header);'); |
| 2629 | - $v_result = $p_options[PCLZIP_CB_PRE_ADD](PCLZIP_CB_PRE_ADD, $v_local_header); |
|
| 2630 | - if ($v_result == 0) { |
|
| 2631 | - // ----- Change the file status |
|
| 2632 | - $p_header['status'] = "skipped"; |
|
| 2633 | - $v_result = 1; |
|
| 2634 | - } |
|
| 2629 | + $v_result = $p_options[PCLZIP_CB_PRE_ADD](PCLZIP_CB_PRE_ADD, $v_local_header); |
|
| 2630 | + if ($v_result == 0) { |
|
| 2631 | + // ----- Change the file status |
|
| 2632 | + $p_header['status'] = "skipped"; |
|
| 2633 | + $v_result = 1; |
|
| 2634 | + } |
|
| 2635 | 2635 | |
| 2636 | - // ----- Update the informations |
|
| 2637 | - // Only some fields can be modified |
|
| 2638 | - if ($p_header['stored_filename'] != $v_local_header['stored_filename']) { |
|
| 2639 | - $p_header['stored_filename'] = PclZipUtilPathReduction($v_local_header['stored_filename']); |
|
| 2640 | - } |
|
| 2641 | - } |
|
| 2636 | + // ----- Update the informations |
|
| 2637 | + // Only some fields can be modified |
|
| 2638 | + if ($p_header['stored_filename'] != $v_local_header['stored_filename']) { |
|
| 2639 | + $p_header['stored_filename'] = PclZipUtilPathReduction($v_local_header['stored_filename']); |
|
| 2640 | + } |
|
| 2641 | + } |
|
| 2642 | 2642 | |
| 2643 | - // ----- Look for empty stored filename |
|
| 2644 | - if ($p_header['stored_filename'] == "") { |
|
| 2645 | - $p_header['status'] = "filtered"; |
|
| 2646 | - } |
|
| 2643 | + // ----- Look for empty stored filename |
|
| 2644 | + if ($p_header['stored_filename'] == "") { |
|
| 2645 | + $p_header['status'] = "filtered"; |
|
| 2646 | + } |
|
| 2647 | 2647 | |
| 2648 | - // ----- Check the path length |
|
| 2649 | - if (strlen($p_header['stored_filename']) > 0xFF) { |
|
| 2650 | - $p_header['status'] = 'filename_too_long'; |
|
| 2651 | - } |
|
| 2648 | + // ----- Check the path length |
|
| 2649 | + if (strlen($p_header['stored_filename']) > 0xFF) { |
|
| 2650 | + $p_header['status'] = 'filename_too_long'; |
|
| 2651 | + } |
|
| 2652 | 2652 | |
| 2653 | - // ----- Look if no error, or file not skipped |
|
| 2654 | - if ($p_header['status'] == 'ok') { |
|
| 2655 | - |
|
| 2656 | - // ----- Look for a file |
|
| 2657 | - if ($p_filedescr['type'] == 'file') { |
|
| 2658 | - // ----- Look for using temporary file to zip |
|
| 2659 | - if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) |
|
| 2660 | - && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON]) |
|
| 2661 | - || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]) |
|
| 2662 | - && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_header['size'])) ) ) { |
|
| 2663 | - $v_result = $this->privAddFileUsingTempFile($p_filedescr, $p_header, $p_options); |
|
| 2664 | - if ($v_result < PCLZIP_ERR_NO_ERROR) { |
|
| 2665 | - return $v_result; |
|
| 2666 | - } |
|
| 2667 | - } |
|
| 2653 | + // ----- Look if no error, or file not skipped |
|
| 2654 | + if ($p_header['status'] == 'ok') { |
|
| 2655 | + |
|
| 2656 | + // ----- Look for a file |
|
| 2657 | + if ($p_filedescr['type'] == 'file') { |
|
| 2658 | + // ----- Look for using temporary file to zip |
|
| 2659 | + if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) |
|
| 2660 | + && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON]) |
|
| 2661 | + || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]) |
|
| 2662 | + && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_header['size'])) ) ) { |
|
| 2663 | + $v_result = $this->privAddFileUsingTempFile($p_filedescr, $p_header, $p_options); |
|
| 2664 | + if ($v_result < PCLZIP_ERR_NO_ERROR) { |
|
| 2665 | + return $v_result; |
|
| 2666 | + } |
|
| 2667 | + } |
|
| 2668 | 2668 | |
| 2669 | - // ----- Use "in memory" zip algo |
|
| 2670 | - else { |
|
| 2669 | + // ----- Use "in memory" zip algo |
|
| 2670 | + else { |
|
| 2671 | 2671 | |
| 2672 | - // ----- Open the source file |
|
| 2673 | - if (($v_file = @fopen($p_filename, "rb")) == 0) { |
|
| 2674 | - PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode"); |
|
| 2675 | - return PclZip::errorCode(); |
|
| 2676 | - } |
|
| 2672 | + // ----- Open the source file |
|
| 2673 | + if (($v_file = @fopen($p_filename, "rb")) == 0) { |
|
| 2674 | + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode"); |
|
| 2675 | + return PclZip::errorCode(); |
|
| 2676 | + } |
|
| 2677 | 2677 | |
| 2678 | - // ----- Read the file content |
|
| 2679 | - $v_content = @fread($v_file, $p_header['size']); |
|
| 2678 | + // ----- Read the file content |
|
| 2679 | + $v_content = @fread($v_file, $p_header['size']); |
|
| 2680 | 2680 | |
| 2681 | - // ----- Close the file |
|
| 2682 | - @fclose($v_file); |
|
| 2681 | + // ----- Close the file |
|
| 2682 | + @fclose($v_file); |
|
| 2683 | 2683 | |
| 2684 | - // ----- Calculate the CRC |
|
| 2685 | - $p_header['crc'] = @crc32($v_content); |
|
| 2684 | + // ----- Calculate the CRC |
|
| 2685 | + $p_header['crc'] = @crc32($v_content); |
|
| 2686 | 2686 | |
| 2687 | - // ----- Look for no compression |
|
| 2688 | - if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) { |
|
| 2689 | - // ----- Set header parameters |
|
| 2690 | - $p_header['compressed_size'] = $p_header['size']; |
|
| 2691 | - $p_header['compression'] = 0; |
|
| 2692 | - } |
|
| 2687 | + // ----- Look for no compression |
|
| 2688 | + if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) { |
|
| 2689 | + // ----- Set header parameters |
|
| 2690 | + $p_header['compressed_size'] = $p_header['size']; |
|
| 2691 | + $p_header['compression'] = 0; |
|
| 2692 | + } |
|
| 2693 | 2693 | |
| 2694 | - // ----- Look for normal compression |
|
| 2695 | - else { |
|
| 2696 | - // ----- Compress the content |
|
| 2697 | - $v_content = @gzdeflate($v_content); |
|
| 2698 | - |
|
| 2699 | - // ----- Set header parameters |
|
| 2700 | - $p_header['compressed_size'] = strlen($v_content); |
|
| 2701 | - $p_header['compression'] = 8; |
|
| 2702 | - } |
|
| 2694 | + // ----- Look for normal compression |
|
| 2695 | + else { |
|
| 2696 | + // ----- Compress the content |
|
| 2697 | + $v_content = @gzdeflate($v_content); |
|
| 2698 | + |
|
| 2699 | + // ----- Set header parameters |
|
| 2700 | + $p_header['compressed_size'] = strlen($v_content); |
|
| 2701 | + $p_header['compression'] = 8; |
|
| 2702 | + } |
|
| 2703 | 2703 | |
| 2704 | - // ----- Call the header generation |
|
| 2705 | - if (($v_result = $this->privWriteFileHeader($p_header)) != 1) { |
|
| 2706 | - @fclose($v_file); |
|
| 2707 | - return $v_result; |
|
| 2708 | - } |
|
| 2704 | + // ----- Call the header generation |
|
| 2705 | + if (($v_result = $this->privWriteFileHeader($p_header)) != 1) { |
|
| 2706 | + @fclose($v_file); |
|
| 2707 | + return $v_result; |
|
| 2708 | + } |
|
| 2709 | 2709 | |
| 2710 | - // ----- Write the compressed (or not) content |
|
| 2711 | - @fwrite($this->zip_fd, $v_content, $p_header['compressed_size']); |
|
| 2710 | + // ----- Write the compressed (or not) content |
|
| 2711 | + @fwrite($this->zip_fd, $v_content, $p_header['compressed_size']); |
|
| 2712 | 2712 | |
| 2713 | - } |
|
| 2713 | + } |
|
| 2714 | 2714 | |
| 2715 | - } |
|
| 2715 | + } |
|
| 2716 | 2716 | |
| 2717 | - // ----- Look for a virtual file (a file from string) |
|
| 2718 | - else if ($p_filedescr['type'] == 'virtual_file') { |
|
| 2717 | + // ----- Look for a virtual file (a file from string) |
|
| 2718 | + else if ($p_filedescr['type'] == 'virtual_file') { |
|
| 2719 | 2719 | |
| 2720 | - $v_content = $p_filedescr['content']; |
|
| 2720 | + $v_content = $p_filedescr['content']; |
|
| 2721 | 2721 | |
| 2722 | - // ----- Calculate the CRC |
|
| 2723 | - $p_header['crc'] = @crc32($v_content); |
|
| 2722 | + // ----- Calculate the CRC |
|
| 2723 | + $p_header['crc'] = @crc32($v_content); |
|
| 2724 | 2724 | |
| 2725 | - // ----- Look for no compression |
|
| 2726 | - if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) { |
|
| 2727 | - // ----- Set header parameters |
|
| 2728 | - $p_header['compressed_size'] = $p_header['size']; |
|
| 2729 | - $p_header['compression'] = 0; |
|
| 2730 | - } |
|
| 2725 | + // ----- Look for no compression |
|
| 2726 | + if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) { |
|
| 2727 | + // ----- Set header parameters |
|
| 2728 | + $p_header['compressed_size'] = $p_header['size']; |
|
| 2729 | + $p_header['compression'] = 0; |
|
| 2730 | + } |
|
| 2731 | 2731 | |
| 2732 | - // ----- Look for normal compression |
|
| 2733 | - else { |
|
| 2734 | - // ----- Compress the content |
|
| 2735 | - $v_content = @gzdeflate($v_content); |
|
| 2736 | - |
|
| 2737 | - // ----- Set header parameters |
|
| 2738 | - $p_header['compressed_size'] = strlen($v_content); |
|
| 2739 | - $p_header['compression'] = 8; |
|
| 2740 | - } |
|
| 2732 | + // ----- Look for normal compression |
|
| 2733 | + else { |
|
| 2734 | + // ----- Compress the content |
|
| 2735 | + $v_content = @gzdeflate($v_content); |
|
| 2736 | + |
|
| 2737 | + // ----- Set header parameters |
|
| 2738 | + $p_header['compressed_size'] = strlen($v_content); |
|
| 2739 | + $p_header['compression'] = 8; |
|
| 2740 | + } |
|
| 2741 | 2741 | |
| 2742 | - // ----- Call the header generation |
|
| 2743 | - if (($v_result = $this->privWriteFileHeader($p_header)) != 1) { |
|
| 2744 | - @fclose($v_file); |
|
| 2745 | - return $v_result; |
|
| 2746 | - } |
|
| 2747 | - |
|
| 2748 | - // ----- Write the compressed (or not) content |
|
| 2749 | - @fwrite($this->zip_fd, $v_content, $p_header['compressed_size']); |
|
| 2750 | - } |
|
| 2742 | + // ----- Call the header generation |
|
| 2743 | + if (($v_result = $this->privWriteFileHeader($p_header)) != 1) { |
|
| 2744 | + @fclose($v_file); |
|
| 2745 | + return $v_result; |
|
| 2746 | + } |
|
| 2747 | + |
|
| 2748 | + // ----- Write the compressed (or not) content |
|
| 2749 | + @fwrite($this->zip_fd, $v_content, $p_header['compressed_size']); |
|
| 2750 | + } |
|
| 2751 | 2751 | |
| 2752 | - // ----- Look for a directory |
|
| 2753 | - else if ($p_filedescr['type'] == 'folder') { |
|
| 2754 | - // ----- Look for directory last '/' |
|
| 2755 | - if (@substr($p_header['stored_filename'], -1) != '/') { |
|
| 2756 | - $p_header['stored_filename'] .= '/'; |
|
| 2757 | - } |
|
| 2758 | - |
|
| 2759 | - // ----- Set the file properties |
|
| 2760 | - $p_header['size'] = 0; |
|
| 2761 | - //$p_header['external'] = 0x41FF0010; // Value for a folder : to be checked |
|
| 2762 | - $p_header['external'] = 0x00000010; // Value for a folder : to be checked |
|
| 2763 | - |
|
| 2764 | - // ----- Call the header generation |
|
| 2765 | - if (($v_result = $this->privWriteFileHeader($p_header)) != 1) |
|
| 2766 | - { |
|
| 2767 | - return $v_result; |
|
| 2768 | - } |
|
| 2769 | - } |
|
| 2770 | - } |
|
| 2752 | + // ----- Look for a directory |
|
| 2753 | + else if ($p_filedescr['type'] == 'folder') { |
|
| 2754 | + // ----- Look for directory last '/' |
|
| 2755 | + if (@substr($p_header['stored_filename'], -1) != '/') { |
|
| 2756 | + $p_header['stored_filename'] .= '/'; |
|
| 2757 | + } |
|
| 2758 | + |
|
| 2759 | + // ----- Set the file properties |
|
| 2760 | + $p_header['size'] = 0; |
|
| 2761 | + //$p_header['external'] = 0x41FF0010; // Value for a folder : to be checked |
|
| 2762 | + $p_header['external'] = 0x00000010; // Value for a folder : to be checked |
|
| 2763 | + |
|
| 2764 | + // ----- Call the header generation |
|
| 2765 | + if (($v_result = $this->privWriteFileHeader($p_header)) != 1) |
|
| 2766 | + { |
|
| 2767 | + return $v_result; |
|
| 2768 | + } |
|
| 2769 | + } |
|
| 2770 | + } |
|
| 2771 | 2771 | |
| 2772 | - // ----- Look for post-add callback |
|
| 2773 | - if (isset($p_options[PCLZIP_CB_POST_ADD])) { |
|
| 2772 | + // ----- Look for post-add callback |
|
| 2773 | + if (isset($p_options[PCLZIP_CB_POST_ADD])) { |
|
| 2774 | 2774 | |
| 2775 | - // ----- Generate a local information |
|
| 2776 | - $v_local_header = array(); |
|
| 2777 | - $this->privConvertHeader2FileInfo($p_header, $v_local_header); |
|
| 2775 | + // ----- Generate a local information |
|
| 2776 | + $v_local_header = array(); |
|
| 2777 | + $this->privConvertHeader2FileInfo($p_header, $v_local_header); |
|
| 2778 | 2778 | |
| 2779 | - // ----- Call the callback |
|
| 2780 | - // Here I do not use call_user_func() because I need to send a reference to the |
|
| 2781 | - // header. |
|
| 2779 | + // ----- Call the callback |
|
| 2780 | + // Here I do not use call_user_func() because I need to send a reference to the |
|
| 2781 | + // header. |
|
| 2782 | 2782 | // eval('$v_result = '.$p_options[PCLZIP_CB_POST_ADD].'(PCLZIP_CB_POST_ADD, $v_local_header);'); |
| 2783 | - $v_result = $p_options[PCLZIP_CB_POST_ADD](PCLZIP_CB_POST_ADD, $v_local_header); |
|
| 2784 | - if ($v_result == 0) { |
|
| 2785 | - // ----- Ignored |
|
| 2786 | - $v_result = 1; |
|
| 2787 | - } |
|
| 2783 | + $v_result = $p_options[PCLZIP_CB_POST_ADD](PCLZIP_CB_POST_ADD, $v_local_header); |
|
| 2784 | + if ($v_result == 0) { |
|
| 2785 | + // ----- Ignored |
|
| 2786 | + $v_result = 1; |
|
| 2787 | + } |
|
| 2788 | 2788 | |
| 2789 | - // ----- Update the informations |
|
| 2790 | - // Nothing can be modified |
|
| 2791 | - } |
|
| 2789 | + // ----- Update the informations |
|
| 2790 | + // Nothing can be modified |
|
| 2791 | + } |
|
| 2792 | 2792 | |
| 2793 | - // ----- Return |
|
| 2794 | - return $v_result; |
|
| 2793 | + // ----- Return |
|
| 2794 | + return $v_result; |
|
| 2795 | 2795 | } |
| 2796 | 2796 | // -------------------------------------------------------------------------------- |
| 2797 | 2797 | |
@@ -2803,105 +2803,105 @@ discard block |
||
| 2803 | 2803 | // -------------------------------------------------------------------------------- |
| 2804 | 2804 | function privAddFileUsingTempFile($p_filedescr, &$p_header, &$p_options) |
| 2805 | 2805 | { |
| 2806 | - $v_result=PCLZIP_ERR_NO_ERROR; |
|
| 2806 | + $v_result=PCLZIP_ERR_NO_ERROR; |
|
| 2807 | 2807 | |
| 2808 | - // ----- Working variable |
|
| 2809 | - $p_filename = $p_filedescr['filename']; |
|
| 2808 | + // ----- Working variable |
|
| 2809 | + $p_filename = $p_filedescr['filename']; |
|
| 2810 | 2810 | |
| 2811 | 2811 | |
| 2812 | - // ----- Open the source file |
|
| 2813 | - if (($v_file = @fopen($p_filename, "rb")) == 0) { |
|
| 2814 | - PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode"); |
|
| 2815 | - return PclZip::errorCode(); |
|
| 2816 | - } |
|
| 2812 | + // ----- Open the source file |
|
| 2813 | + if (($v_file = @fopen($p_filename, "rb")) == 0) { |
|
| 2814 | + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode"); |
|
| 2815 | + return PclZip::errorCode(); |
|
| 2816 | + } |
|
| 2817 | 2817 | |
| 2818 | - // ----- Creates a compressed temporary file |
|
| 2819 | - $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz'; |
|
| 2820 | - if (($v_file_compressed = @gzopen($v_gzip_temp_name, "wb")) == 0) { |
|
| 2821 | - fclose($v_file); |
|
| 2822 | - PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode'); |
|
| 2823 | - return PclZip::errorCode(); |
|
| 2824 | - } |
|
| 2818 | + // ----- Creates a compressed temporary file |
|
| 2819 | + $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz'; |
|
| 2820 | + if (($v_file_compressed = @gzopen($v_gzip_temp_name, "wb")) == 0) { |
|
| 2821 | + fclose($v_file); |
|
| 2822 | + PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode'); |
|
| 2823 | + return PclZip::errorCode(); |
|
| 2824 | + } |
|
| 2825 | 2825 | |
| 2826 | - // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks |
|
| 2827 | - $v_size = filesize($p_filename); |
|
| 2828 | - while ($v_size != 0) { |
|
| 2829 | - $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 2830 | - $v_buffer = @fread($v_file, $v_read_size); |
|
| 2831 | - //$v_binary_data = pack('a'.$v_read_size, $v_buffer); |
|
| 2832 | - @gzputs($v_file_compressed, $v_buffer, $v_read_size); |
|
| 2833 | - $v_size -= $v_read_size; |
|
| 2834 | - } |
|
| 2826 | + // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks |
|
| 2827 | + $v_size = filesize($p_filename); |
|
| 2828 | + while ($v_size != 0) { |
|
| 2829 | + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 2830 | + $v_buffer = @fread($v_file, $v_read_size); |
|
| 2831 | + //$v_binary_data = pack('a'.$v_read_size, $v_buffer); |
|
| 2832 | + @gzputs($v_file_compressed, $v_buffer, $v_read_size); |
|
| 2833 | + $v_size -= $v_read_size; |
|
| 2834 | + } |
|
| 2835 | 2835 | |
| 2836 | - // ----- Close the file |
|
| 2837 | - @fclose($v_file); |
|
| 2838 | - @gzclose($v_file_compressed); |
|
| 2836 | + // ----- Close the file |
|
| 2837 | + @fclose($v_file); |
|
| 2838 | + @gzclose($v_file_compressed); |
|
| 2839 | 2839 | |
| 2840 | - // ----- Check the minimum file size |
|
| 2841 | - if (filesize($v_gzip_temp_name) < 18) { |
|
| 2842 | - PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'gzip temporary file \''.$v_gzip_temp_name.'\' has invalid filesize - should be minimum 18 bytes'); |
|
| 2843 | - return PclZip::errorCode(); |
|
| 2844 | - } |
|
| 2840 | + // ----- Check the minimum file size |
|
| 2841 | + if (filesize($v_gzip_temp_name) < 18) { |
|
| 2842 | + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'gzip temporary file \''.$v_gzip_temp_name.'\' has invalid filesize - should be minimum 18 bytes'); |
|
| 2843 | + return PclZip::errorCode(); |
|
| 2844 | + } |
|
| 2845 | 2845 | |
| 2846 | - // ----- Extract the compressed attributes |
|
| 2847 | - if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0) { |
|
| 2848 | - PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode'); |
|
| 2849 | - return PclZip::errorCode(); |
|
| 2850 | - } |
|
| 2846 | + // ----- Extract the compressed attributes |
|
| 2847 | + if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0) { |
|
| 2848 | + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode'); |
|
| 2849 | + return PclZip::errorCode(); |
|
| 2850 | + } |
|
| 2851 | 2851 | |
| 2852 | - // ----- Read the gzip file header |
|
| 2853 | - $v_binary_data = @fread($v_file_compressed, 10); |
|
| 2854 | - $v_data_header = unpack('a1id1/a1id2/a1cm/a1flag/Vmtime/a1xfl/a1os', $v_binary_data); |
|
| 2852 | + // ----- Read the gzip file header |
|
| 2853 | + $v_binary_data = @fread($v_file_compressed, 10); |
|
| 2854 | + $v_data_header = unpack('a1id1/a1id2/a1cm/a1flag/Vmtime/a1xfl/a1os', $v_binary_data); |
|
| 2855 | 2855 | |
| 2856 | - // ----- Check some parameters |
|
| 2857 | - $v_data_header['os'] = bin2hex($v_data_header['os']); |
|
| 2856 | + // ----- Check some parameters |
|
| 2857 | + $v_data_header['os'] = bin2hex($v_data_header['os']); |
|
| 2858 | 2858 | |
| 2859 | - // ----- Read the gzip file footer |
|
| 2860 | - @fseek($v_file_compressed, filesize($v_gzip_temp_name)-8); |
|
| 2861 | - $v_binary_data = @fread($v_file_compressed, 8); |
|
| 2862 | - $v_data_footer = unpack('Vcrc/Vcompressed_size', $v_binary_data); |
|
| 2859 | + // ----- Read the gzip file footer |
|
| 2860 | + @fseek($v_file_compressed, filesize($v_gzip_temp_name)-8); |
|
| 2861 | + $v_binary_data = @fread($v_file_compressed, 8); |
|
| 2862 | + $v_data_footer = unpack('Vcrc/Vcompressed_size', $v_binary_data); |
|
| 2863 | 2863 | |
| 2864 | - // ----- Set the attributes |
|
| 2865 | - $p_header['compression'] = ord($v_data_header['cm']); |
|
| 2866 | - //$p_header['mtime'] = $v_data_header['mtime']; |
|
| 2867 | - $p_header['crc'] = $v_data_footer['crc']; |
|
| 2868 | - $p_header['compressed_size'] = filesize($v_gzip_temp_name)-18; |
|
| 2864 | + // ----- Set the attributes |
|
| 2865 | + $p_header['compression'] = ord($v_data_header['cm']); |
|
| 2866 | + //$p_header['mtime'] = $v_data_header['mtime']; |
|
| 2867 | + $p_header['crc'] = $v_data_footer['crc']; |
|
| 2868 | + $p_header['compressed_size'] = filesize($v_gzip_temp_name)-18; |
|
| 2869 | 2869 | |
| 2870 | - // ----- Close the file |
|
| 2871 | - @fclose($v_file_compressed); |
|
| 2870 | + // ----- Close the file |
|
| 2871 | + @fclose($v_file_compressed); |
|
| 2872 | 2872 | |
| 2873 | - // ----- Call the header generation |
|
| 2874 | - if (($v_result = $this->privWriteFileHeader($p_header)) != 1) { |
|
| 2875 | - return $v_result; |
|
| 2876 | - } |
|
| 2873 | + // ----- Call the header generation |
|
| 2874 | + if (($v_result = $this->privWriteFileHeader($p_header)) != 1) { |
|
| 2875 | + return $v_result; |
|
| 2876 | + } |
|
| 2877 | 2877 | |
| 2878 | - // ----- Add the compressed data |
|
| 2879 | - if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0) |
|
| 2880 | - { |
|
| 2881 | - PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode'); |
|
| 2882 | - return PclZip::errorCode(); |
|
| 2883 | - } |
|
| 2878 | + // ----- Add the compressed data |
|
| 2879 | + if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0) |
|
| 2880 | + { |
|
| 2881 | + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode'); |
|
| 2882 | + return PclZip::errorCode(); |
|
| 2883 | + } |
|
| 2884 | 2884 | |
| 2885 | - // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks |
|
| 2886 | - fseek($v_file_compressed, 10); |
|
| 2887 | - $v_size = $p_header['compressed_size']; |
|
| 2888 | - while ($v_size != 0) |
|
| 2889 | - { |
|
| 2890 | - $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 2891 | - $v_buffer = @fread($v_file_compressed, $v_read_size); |
|
| 2892 | - //$v_binary_data = pack('a'.$v_read_size, $v_buffer); |
|
| 2893 | - @fwrite($this->zip_fd, $v_buffer, $v_read_size); |
|
| 2894 | - $v_size -= $v_read_size; |
|
| 2895 | - } |
|
| 2885 | + // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks |
|
| 2886 | + fseek($v_file_compressed, 10); |
|
| 2887 | + $v_size = $p_header['compressed_size']; |
|
| 2888 | + while ($v_size != 0) |
|
| 2889 | + { |
|
| 2890 | + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 2891 | + $v_buffer = @fread($v_file_compressed, $v_read_size); |
|
| 2892 | + //$v_binary_data = pack('a'.$v_read_size, $v_buffer); |
|
| 2893 | + @fwrite($this->zip_fd, $v_buffer, $v_read_size); |
|
| 2894 | + $v_size -= $v_read_size; |
|
| 2895 | + } |
|
| 2896 | 2896 | |
| 2897 | - // ----- Close the file |
|
| 2898 | - @fclose($v_file_compressed); |
|
| 2897 | + // ----- Close the file |
|
| 2898 | + @fclose($v_file_compressed); |
|
| 2899 | 2899 | |
| 2900 | - // ----- Unlink the temporary file |
|
| 2901 | - @unlink($v_gzip_temp_name); |
|
| 2900 | + // ----- Unlink the temporary file |
|
| 2901 | + @unlink($v_gzip_temp_name); |
|
| 2902 | 2902 | |
| 2903 | - // ----- Return |
|
| 2904 | - return $v_result; |
|
| 2903 | + // ----- Return |
|
| 2904 | + return $v_result; |
|
| 2905 | 2905 | } |
| 2906 | 2906 | // -------------------------------------------------------------------------------- |
| 2907 | 2907 | |
@@ -2915,107 +2915,107 @@ discard block |
||
| 2915 | 2915 | // -------------------------------------------------------------------------------- |
| 2916 | 2916 | function privCalculateStoredFilename(&$p_filedescr, &$p_options) |
| 2917 | 2917 | { |
| 2918 | - $v_result=1; |
|
| 2918 | + $v_result=1; |
|
| 2919 | 2919 | |
| 2920 | - // ----- Working variables |
|
| 2921 | - $p_filename = $p_filedescr['filename']; |
|
| 2922 | - if (isset($p_options[PCLZIP_OPT_ADD_PATH])) { |
|
| 2923 | - $p_add_dir = $p_options[PCLZIP_OPT_ADD_PATH]; |
|
| 2924 | - } |
|
| 2925 | - else { |
|
| 2926 | - $p_add_dir = ''; |
|
| 2927 | - } |
|
| 2928 | - if (isset($p_options[PCLZIP_OPT_REMOVE_PATH])) { |
|
| 2929 | - $p_remove_dir = $p_options[PCLZIP_OPT_REMOVE_PATH]; |
|
| 2930 | - } |
|
| 2931 | - else { |
|
| 2932 | - $p_remove_dir = ''; |
|
| 2933 | - } |
|
| 2934 | - if (isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])) { |
|
| 2935 | - $p_remove_all_dir = $p_options[PCLZIP_OPT_REMOVE_ALL_PATH]; |
|
| 2936 | - } |
|
| 2937 | - else { |
|
| 2938 | - $p_remove_all_dir = 0; |
|
| 2939 | - } |
|
| 2920 | + // ----- Working variables |
|
| 2921 | + $p_filename = $p_filedescr['filename']; |
|
| 2922 | + if (isset($p_options[PCLZIP_OPT_ADD_PATH])) { |
|
| 2923 | + $p_add_dir = $p_options[PCLZIP_OPT_ADD_PATH]; |
|
| 2924 | + } |
|
| 2925 | + else { |
|
| 2926 | + $p_add_dir = ''; |
|
| 2927 | + } |
|
| 2928 | + if (isset($p_options[PCLZIP_OPT_REMOVE_PATH])) { |
|
| 2929 | + $p_remove_dir = $p_options[PCLZIP_OPT_REMOVE_PATH]; |
|
| 2930 | + } |
|
| 2931 | + else { |
|
| 2932 | + $p_remove_dir = ''; |
|
| 2933 | + } |
|
| 2934 | + if (isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])) { |
|
| 2935 | + $p_remove_all_dir = $p_options[PCLZIP_OPT_REMOVE_ALL_PATH]; |
|
| 2936 | + } |
|
| 2937 | + else { |
|
| 2938 | + $p_remove_all_dir = 0; |
|
| 2939 | + } |
|
| 2940 | 2940 | |
| 2941 | 2941 | |
| 2942 | - // ----- Look for full name change |
|
| 2943 | - if (isset($p_filedescr['new_full_name'])) { |
|
| 2944 | - // ----- Remove drive letter if any |
|
| 2945 | - $v_stored_filename = PclZipUtilTranslateWinPath($p_filedescr['new_full_name']); |
|
| 2946 | - } |
|
| 2942 | + // ----- Look for full name change |
|
| 2943 | + if (isset($p_filedescr['new_full_name'])) { |
|
| 2944 | + // ----- Remove drive letter if any |
|
| 2945 | + $v_stored_filename = PclZipUtilTranslateWinPath($p_filedescr['new_full_name']); |
|
| 2946 | + } |
|
| 2947 | 2947 | |
| 2948 | - // ----- Look for path and/or short name change |
|
| 2949 | - else { |
|
| 2950 | - |
|
| 2951 | - // ----- Look for short name change |
|
| 2952 | - // Its when we cahnge just the filename but not the path |
|
| 2953 | - if (isset($p_filedescr['new_short_name'])) { |
|
| 2954 | - $v_path_info = pathinfo($p_filename); |
|
| 2955 | - $v_dir = ''; |
|
| 2956 | - if ($v_path_info['dirname'] != '') { |
|
| 2957 | - $v_dir = $v_path_info['dirname'].'/'; |
|
| 2958 | - } |
|
| 2959 | - $v_stored_filename = $v_dir.$p_filedescr['new_short_name']; |
|
| 2960 | - } |
|
| 2961 | - else { |
|
| 2962 | - // ----- Calculate the stored filename |
|
| 2963 | - $v_stored_filename = $p_filename; |
|
| 2964 | - } |
|
| 2948 | + // ----- Look for path and/or short name change |
|
| 2949 | + else { |
|
| 2950 | + |
|
| 2951 | + // ----- Look for short name change |
|
| 2952 | + // Its when we cahnge just the filename but not the path |
|
| 2953 | + if (isset($p_filedescr['new_short_name'])) { |
|
| 2954 | + $v_path_info = pathinfo($p_filename); |
|
| 2955 | + $v_dir = ''; |
|
| 2956 | + if ($v_path_info['dirname'] != '') { |
|
| 2957 | + $v_dir = $v_path_info['dirname'].'/'; |
|
| 2958 | + } |
|
| 2959 | + $v_stored_filename = $v_dir.$p_filedescr['new_short_name']; |
|
| 2960 | + } |
|
| 2961 | + else { |
|
| 2962 | + // ----- Calculate the stored filename |
|
| 2963 | + $v_stored_filename = $p_filename; |
|
| 2964 | + } |
|
| 2965 | 2965 | |
| 2966 | - // ----- Look for all path to remove |
|
| 2967 | - if ($p_remove_all_dir) { |
|
| 2968 | - $v_stored_filename = basename($p_filename); |
|
| 2969 | - } |
|
| 2970 | - // ----- Look for partial path remove |
|
| 2971 | - else if ($p_remove_dir != "") { |
|
| 2972 | - if (substr($p_remove_dir, -1) != '/') |
|
| 2973 | - $p_remove_dir .= "/"; |
|
| 2966 | + // ----- Look for all path to remove |
|
| 2967 | + if ($p_remove_all_dir) { |
|
| 2968 | + $v_stored_filename = basename($p_filename); |
|
| 2969 | + } |
|
| 2970 | + // ----- Look for partial path remove |
|
| 2971 | + else if ($p_remove_dir != "") { |
|
| 2972 | + if (substr($p_remove_dir, -1) != '/') |
|
| 2973 | + $p_remove_dir .= "/"; |
|
| 2974 | 2974 | |
| 2975 | - if ( (substr($p_filename, 0, 2) == "./") |
|
| 2976 | - || (substr($p_remove_dir, 0, 2) == "./")) { |
|
| 2975 | + if ( (substr($p_filename, 0, 2) == "./") |
|
| 2976 | + || (substr($p_remove_dir, 0, 2) == "./")) { |
|
| 2977 | 2977 | |
| 2978 | - if ( (substr($p_filename, 0, 2) == "./") |
|
| 2979 | - && (substr($p_remove_dir, 0, 2) != "./")) { |
|
| 2980 | - $p_remove_dir = "./".$p_remove_dir; |
|
| 2981 | - } |
|
| 2982 | - if ( (substr($p_filename, 0, 2) != "./") |
|
| 2983 | - && (substr($p_remove_dir, 0, 2) == "./")) { |
|
| 2984 | - $p_remove_dir = substr($p_remove_dir, 2); |
|
| 2985 | - } |
|
| 2986 | - } |
|
| 2978 | + if ( (substr($p_filename, 0, 2) == "./") |
|
| 2979 | + && (substr($p_remove_dir, 0, 2) != "./")) { |
|
| 2980 | + $p_remove_dir = "./".$p_remove_dir; |
|
| 2981 | + } |
|
| 2982 | + if ( (substr($p_filename, 0, 2) != "./") |
|
| 2983 | + && (substr($p_remove_dir, 0, 2) == "./")) { |
|
| 2984 | + $p_remove_dir = substr($p_remove_dir, 2); |
|
| 2985 | + } |
|
| 2986 | + } |
|
| 2987 | 2987 | |
| 2988 | - $v_compare = PclZipUtilPathInclusion($p_remove_dir, |
|
| 2989 | - $v_stored_filename); |
|
| 2990 | - if ($v_compare > 0) { |
|
| 2991 | - if ($v_compare == 2) { |
|
| 2992 | - $v_stored_filename = ""; |
|
| 2993 | - } |
|
| 2994 | - else { |
|
| 2995 | - $v_stored_filename = substr($v_stored_filename, |
|
| 2996 | - strlen($p_remove_dir)); |
|
| 2997 | - } |
|
| 2998 | - } |
|
| 2999 | - } |
|
| 2988 | + $v_compare = PclZipUtilPathInclusion($p_remove_dir, |
|
| 2989 | + $v_stored_filename); |
|
| 2990 | + if ($v_compare > 0) { |
|
| 2991 | + if ($v_compare == 2) { |
|
| 2992 | + $v_stored_filename = ""; |
|
| 2993 | + } |
|
| 2994 | + else { |
|
| 2995 | + $v_stored_filename = substr($v_stored_filename, |
|
| 2996 | + strlen($p_remove_dir)); |
|
| 2997 | + } |
|
| 2998 | + } |
|
| 2999 | + } |
|
| 3000 | 3000 | |
| 3001 | - // ----- Remove drive letter if any |
|
| 3002 | - $v_stored_filename = PclZipUtilTranslateWinPath($v_stored_filename); |
|
| 3001 | + // ----- Remove drive letter if any |
|
| 3002 | + $v_stored_filename = PclZipUtilTranslateWinPath($v_stored_filename); |
|
| 3003 | 3003 | |
| 3004 | - // ----- Look for path to add |
|
| 3005 | - if ($p_add_dir != "") { |
|
| 3006 | - if (substr($p_add_dir, -1) == "/") |
|
| 3007 | - $v_stored_filename = $p_add_dir.$v_stored_filename; |
|
| 3008 | - else |
|
| 3009 | - $v_stored_filename = $p_add_dir."/".$v_stored_filename; |
|
| 3010 | - } |
|
| 3011 | - } |
|
| 3004 | + // ----- Look for path to add |
|
| 3005 | + if ($p_add_dir != "") { |
|
| 3006 | + if (substr($p_add_dir, -1) == "/") |
|
| 3007 | + $v_stored_filename = $p_add_dir.$v_stored_filename; |
|
| 3008 | + else |
|
| 3009 | + $v_stored_filename = $p_add_dir."/".$v_stored_filename; |
|
| 3010 | + } |
|
| 3011 | + } |
|
| 3012 | 3012 | |
| 3013 | - // ----- Filename (reduce the path of stored name) |
|
| 3014 | - $v_stored_filename = PclZipUtilPathReduction($v_stored_filename); |
|
| 3015 | - $p_filedescr['stored_filename'] = $v_stored_filename; |
|
| 3013 | + // ----- Filename (reduce the path of stored name) |
|
| 3014 | + $v_stored_filename = PclZipUtilPathReduction($v_stored_filename); |
|
| 3015 | + $p_filedescr['stored_filename'] = $v_stored_filename; |
|
| 3016 | 3016 | |
| 3017 | - // ----- Return |
|
| 3018 | - return $v_result; |
|
| 3017 | + // ----- Return |
|
| 3018 | + return $v_result; |
|
| 3019 | 3019 | } |
| 3020 | 3020 | // -------------------------------------------------------------------------------- |
| 3021 | 3021 | |
@@ -3027,40 +3027,40 @@ discard block |
||
| 3027 | 3027 | // -------------------------------------------------------------------------------- |
| 3028 | 3028 | function privWriteFileHeader(&$p_header) |
| 3029 | 3029 | { |
| 3030 | - $v_result=1; |
|
| 3030 | + $v_result=1; |
|
| 3031 | 3031 | |
| 3032 | - // ----- Store the offset position of the file |
|
| 3033 | - $p_header['offset'] = ftell($this->zip_fd); |
|
| 3032 | + // ----- Store the offset position of the file |
|
| 3033 | + $p_header['offset'] = ftell($this->zip_fd); |
|
| 3034 | 3034 | |
| 3035 | - // ----- Transform UNIX mtime to DOS format mdate/mtime |
|
| 3036 | - $v_date = getdate($p_header['mtime']); |
|
| 3037 | - $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2; |
|
| 3038 | - $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday']; |
|
| 3035 | + // ----- Transform UNIX mtime to DOS format mdate/mtime |
|
| 3036 | + $v_date = getdate($p_header['mtime']); |
|
| 3037 | + $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2; |
|
| 3038 | + $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday']; |
|
| 3039 | 3039 | |
| 3040 | - // ----- Packed data |
|
| 3041 | - $v_binary_data = pack("VvvvvvVVVvv", 0x04034b50, |
|
| 3042 | - $p_header['version_extracted'], $p_header['flag'], |
|
| 3043 | - $p_header['compression'], $v_mtime, $v_mdate, |
|
| 3044 | - $p_header['crc'], $p_header['compressed_size'], |
|
| 3040 | + // ----- Packed data |
|
| 3041 | + $v_binary_data = pack("VvvvvvVVVvv", 0x04034b50, |
|
| 3042 | + $p_header['version_extracted'], $p_header['flag'], |
|
| 3043 | + $p_header['compression'], $v_mtime, $v_mdate, |
|
| 3044 | + $p_header['crc'], $p_header['compressed_size'], |
|
| 3045 | 3045 | $p_header['size'], |
| 3046 | - strlen($p_header['stored_filename']), |
|
| 3046 | + strlen($p_header['stored_filename']), |
|
| 3047 | 3047 | $p_header['extra_len']); |
| 3048 | 3048 | |
| 3049 | - // ----- Write the first 148 bytes of the header in the archive |
|
| 3050 | - fputs($this->zip_fd, $v_binary_data, 30); |
|
| 3049 | + // ----- Write the first 148 bytes of the header in the archive |
|
| 3050 | + fputs($this->zip_fd, $v_binary_data, 30); |
|
| 3051 | 3051 | |
| 3052 | - // ----- Write the variable fields |
|
| 3053 | - if (strlen($p_header['stored_filename']) != 0) |
|
| 3054 | - { |
|
| 3055 | - fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename'])); |
|
| 3056 | - } |
|
| 3057 | - if ($p_header['extra_len'] != 0) |
|
| 3058 | - { |
|
| 3059 | - fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']); |
|
| 3060 | - } |
|
| 3052 | + // ----- Write the variable fields |
|
| 3053 | + if (strlen($p_header['stored_filename']) != 0) |
|
| 3054 | + { |
|
| 3055 | + fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename'])); |
|
| 3056 | + } |
|
| 3057 | + if ($p_header['extra_len'] != 0) |
|
| 3058 | + { |
|
| 3059 | + fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']); |
|
| 3060 | + } |
|
| 3061 | 3061 | |
| 3062 | - // ----- Return |
|
| 3063 | - return $v_result; |
|
| 3062 | + // ----- Return |
|
| 3063 | + return $v_result; |
|
| 3064 | 3064 | } |
| 3065 | 3065 | // -------------------------------------------------------------------------------- |
| 3066 | 3066 | |
@@ -3072,48 +3072,48 @@ discard block |
||
| 3072 | 3072 | // -------------------------------------------------------------------------------- |
| 3073 | 3073 | function privWriteCentralFileHeader(&$p_header) |
| 3074 | 3074 | { |
| 3075 | - $v_result=1; |
|
| 3075 | + $v_result=1; |
|
| 3076 | 3076 | |
| 3077 | - // TBC |
|
| 3078 | - //for(reset($p_header); $key = key($p_header); next($p_header)) { |
|
| 3079 | - //} |
|
| 3077 | + // TBC |
|
| 3078 | + //for(reset($p_header); $key = key($p_header); next($p_header)) { |
|
| 3079 | + //} |
|
| 3080 | 3080 | |
| 3081 | - // ----- Transform UNIX mtime to DOS format mdate/mtime |
|
| 3082 | - $v_date = getdate($p_header['mtime']); |
|
| 3083 | - $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2; |
|
| 3084 | - $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday']; |
|
| 3081 | + // ----- Transform UNIX mtime to DOS format mdate/mtime |
|
| 3082 | + $v_date = getdate($p_header['mtime']); |
|
| 3083 | + $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2; |
|
| 3084 | + $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday']; |
|
| 3085 | 3085 | |
| 3086 | 3086 | |
| 3087 | - // ----- Packed data |
|
| 3088 | - $v_binary_data = pack("VvvvvvvVVVvvvvvVV", 0x02014b50, |
|
| 3089 | - $p_header['version'], $p_header['version_extracted'], |
|
| 3090 | - $p_header['flag'], $p_header['compression'], |
|
| 3087 | + // ----- Packed data |
|
| 3088 | + $v_binary_data = pack("VvvvvvvVVVvvvvvVV", 0x02014b50, |
|
| 3089 | + $p_header['version'], $p_header['version_extracted'], |
|
| 3090 | + $p_header['flag'], $p_header['compression'], |
|
| 3091 | 3091 | $v_mtime, $v_mdate, $p_header['crc'], |
| 3092 | - $p_header['compressed_size'], $p_header['size'], |
|
| 3093 | - strlen($p_header['stored_filename']), |
|
| 3092 | + $p_header['compressed_size'], $p_header['size'], |
|
| 3093 | + strlen($p_header['stored_filename']), |
|
| 3094 | 3094 | $p_header['extra_len'], $p_header['comment_len'], |
| 3095 | - $p_header['disk'], $p_header['internal'], |
|
| 3095 | + $p_header['disk'], $p_header['internal'], |
|
| 3096 | 3096 | $p_header['external'], $p_header['offset']); |
| 3097 | 3097 | |
| 3098 | - // ----- Write the 42 bytes of the header in the zip file |
|
| 3099 | - fputs($this->zip_fd, $v_binary_data, 46); |
|
| 3098 | + // ----- Write the 42 bytes of the header in the zip file |
|
| 3099 | + fputs($this->zip_fd, $v_binary_data, 46); |
|
| 3100 | 3100 | |
| 3101 | - // ----- Write the variable fields |
|
| 3102 | - if (strlen($p_header['stored_filename']) != 0) |
|
| 3103 | - { |
|
| 3104 | - fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename'])); |
|
| 3105 | - } |
|
| 3106 | - if ($p_header['extra_len'] != 0) |
|
| 3107 | - { |
|
| 3108 | - fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']); |
|
| 3109 | - } |
|
| 3110 | - if ($p_header['comment_len'] != 0) |
|
| 3111 | - { |
|
| 3112 | - fputs($this->zip_fd, $p_header['comment'], $p_header['comment_len']); |
|
| 3113 | - } |
|
| 3101 | + // ----- Write the variable fields |
|
| 3102 | + if (strlen($p_header['stored_filename']) != 0) |
|
| 3103 | + { |
|
| 3104 | + fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename'])); |
|
| 3105 | + } |
|
| 3106 | + if ($p_header['extra_len'] != 0) |
|
| 3107 | + { |
|
| 3108 | + fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']); |
|
| 3109 | + } |
|
| 3110 | + if ($p_header['comment_len'] != 0) |
|
| 3111 | + { |
|
| 3112 | + fputs($this->zip_fd, $p_header['comment'], $p_header['comment_len']); |
|
| 3113 | + } |
|
| 3114 | 3114 | |
| 3115 | - // ----- Return |
|
| 3116 | - return $v_result; |
|
| 3115 | + // ----- Return |
|
| 3116 | + return $v_result; |
|
| 3117 | 3117 | } |
| 3118 | 3118 | // -------------------------------------------------------------------------------- |
| 3119 | 3119 | |
@@ -3125,24 +3125,24 @@ discard block |
||
| 3125 | 3125 | // -------------------------------------------------------------------------------- |
| 3126 | 3126 | function privWriteCentralHeader($p_nb_entries, $p_size, $p_offset, $p_comment) |
| 3127 | 3127 | { |
| 3128 | - $v_result=1; |
|
| 3128 | + $v_result=1; |
|
| 3129 | 3129 | |
| 3130 | - // ----- Packed data |
|
| 3131 | - $v_binary_data = pack("VvvvvVVv", 0x06054b50, 0, 0, $p_nb_entries, |
|
| 3132 | - $p_nb_entries, $p_size, |
|
| 3130 | + // ----- Packed data |
|
| 3131 | + $v_binary_data = pack("VvvvvVVv", 0x06054b50, 0, 0, $p_nb_entries, |
|
| 3132 | + $p_nb_entries, $p_size, |
|
| 3133 | 3133 | $p_offset, strlen($p_comment)); |
| 3134 | 3134 | |
| 3135 | - // ----- Write the 22 bytes of the header in the zip file |
|
| 3136 | - fputs($this->zip_fd, $v_binary_data, 22); |
|
| 3135 | + // ----- Write the 22 bytes of the header in the zip file |
|
| 3136 | + fputs($this->zip_fd, $v_binary_data, 22); |
|
| 3137 | 3137 | |
| 3138 | - // ----- Write the variable fields |
|
| 3139 | - if (strlen($p_comment) != 0) |
|
| 3140 | - { |
|
| 3141 | - fputs($this->zip_fd, $p_comment, strlen($p_comment)); |
|
| 3142 | - } |
|
| 3138 | + // ----- Write the variable fields |
|
| 3139 | + if (strlen($p_comment) != 0) |
|
| 3140 | + { |
|
| 3141 | + fputs($this->zip_fd, $p_comment, strlen($p_comment)); |
|
| 3142 | + } |
|
| 3143 | 3143 | |
| 3144 | - // ----- Return |
|
| 3145 | - return $v_result; |
|
| 3144 | + // ----- Return |
|
| 3145 | + return $v_result; |
|
| 3146 | 3146 | } |
| 3147 | 3147 | // -------------------------------------------------------------------------------- |
| 3148 | 3148 | |
@@ -3154,69 +3154,69 @@ discard block |
||
| 3154 | 3154 | // -------------------------------------------------------------------------------- |
| 3155 | 3155 | function privList(&$p_list) |
| 3156 | 3156 | { |
| 3157 | - $v_result=1; |
|
| 3157 | + $v_result=1; |
|
| 3158 | 3158 | |
| 3159 | - // ----- Magic quotes trick |
|
| 3160 | - $this->privDisableMagicQuotes(); |
|
| 3159 | + // ----- Magic quotes trick |
|
| 3160 | + $this->privDisableMagicQuotes(); |
|
| 3161 | 3161 | |
| 3162 | - // ----- Open the zip file |
|
| 3163 | - if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0) |
|
| 3164 | - { |
|
| 3165 | - // ----- Magic quotes trick |
|
| 3166 | - $this->privSwapBackMagicQuotes(); |
|
| 3162 | + // ----- Open the zip file |
|
| 3163 | + if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0) |
|
| 3164 | + { |
|
| 3165 | + // ----- Magic quotes trick |
|
| 3166 | + $this->privSwapBackMagicQuotes(); |
|
| 3167 | 3167 | |
| 3168 | - // ----- Error log |
|
| 3169 | - PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode'); |
|
| 3168 | + // ----- Error log |
|
| 3169 | + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode'); |
|
| 3170 | 3170 | |
| 3171 | - // ----- Return |
|
| 3172 | - return PclZip::errorCode(); |
|
| 3173 | - } |
|
| 3171 | + // ----- Return |
|
| 3172 | + return PclZip::errorCode(); |
|
| 3173 | + } |
|
| 3174 | 3174 | |
| 3175 | - // ----- Read the central directory informations |
|
| 3176 | - $v_central_dir = array(); |
|
| 3177 | - if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) |
|
| 3178 | - { |
|
| 3179 | - $this->privSwapBackMagicQuotes(); |
|
| 3180 | - return $v_result; |
|
| 3181 | - } |
|
| 3175 | + // ----- Read the central directory informations |
|
| 3176 | + $v_central_dir = array(); |
|
| 3177 | + if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) |
|
| 3178 | + { |
|
| 3179 | + $this->privSwapBackMagicQuotes(); |
|
| 3180 | + return $v_result; |
|
| 3181 | + } |
|
| 3182 | 3182 | |
| 3183 | - // ----- Go to beginning of Central Dir |
|
| 3184 | - @rewind($this->zip_fd); |
|
| 3185 | - if (@fseek($this->zip_fd, $v_central_dir['offset'])) |
|
| 3186 | - { |
|
| 3187 | - $this->privSwapBackMagicQuotes(); |
|
| 3183 | + // ----- Go to beginning of Central Dir |
|
| 3184 | + @rewind($this->zip_fd); |
|
| 3185 | + if (@fseek($this->zip_fd, $v_central_dir['offset'])) |
|
| 3186 | + { |
|
| 3187 | + $this->privSwapBackMagicQuotes(); |
|
| 3188 | 3188 | |
| 3189 | - // ----- Error log |
|
| 3190 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); |
|
| 3189 | + // ----- Error log |
|
| 3190 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); |
|
| 3191 | 3191 | |
| 3192 | - // ----- Return |
|
| 3193 | - return PclZip::errorCode(); |
|
| 3194 | - } |
|
| 3192 | + // ----- Return |
|
| 3193 | + return PclZip::errorCode(); |
|
| 3194 | + } |
|
| 3195 | 3195 | |
| 3196 | - // ----- Read each entry |
|
| 3197 | - for ($i=0; $i<$v_central_dir['entries']; $i++) |
|
| 3198 | - { |
|
| 3199 | - // ----- Read the file header |
|
| 3200 | - if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1) |
|
| 3201 | - { |
|
| 3202 | - $this->privSwapBackMagicQuotes(); |
|
| 3203 | - return $v_result; |
|
| 3204 | - } |
|
| 3205 | - $v_header['index'] = $i; |
|
| 3196 | + // ----- Read each entry |
|
| 3197 | + for ($i=0; $i<$v_central_dir['entries']; $i++) |
|
| 3198 | + { |
|
| 3199 | + // ----- Read the file header |
|
| 3200 | + if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1) |
|
| 3201 | + { |
|
| 3202 | + $this->privSwapBackMagicQuotes(); |
|
| 3203 | + return $v_result; |
|
| 3204 | + } |
|
| 3205 | + $v_header['index'] = $i; |
|
| 3206 | 3206 | |
| 3207 | - // ----- Get the only interesting attributes |
|
| 3208 | - $this->privConvertHeader2FileInfo($v_header, $p_list[$i]); |
|
| 3209 | - unset($v_header); |
|
| 3210 | - } |
|
| 3207 | + // ----- Get the only interesting attributes |
|
| 3208 | + $this->privConvertHeader2FileInfo($v_header, $p_list[$i]); |
|
| 3209 | + unset($v_header); |
|
| 3210 | + } |
|
| 3211 | 3211 | |
| 3212 | - // ----- Close the zip file |
|
| 3213 | - $this->privCloseFd(); |
|
| 3212 | + // ----- Close the zip file |
|
| 3213 | + $this->privCloseFd(); |
|
| 3214 | 3214 | |
| 3215 | - // ----- Magic quotes trick |
|
| 3216 | - $this->privSwapBackMagicQuotes(); |
|
| 3215 | + // ----- Magic quotes trick |
|
| 3216 | + $this->privSwapBackMagicQuotes(); |
|
| 3217 | 3217 | |
| 3218 | - // ----- Return |
|
| 3219 | - return $v_result; |
|
| 3218 | + // ----- Return |
|
| 3219 | + return $v_result; |
|
| 3220 | 3220 | } |
| 3221 | 3221 | // -------------------------------------------------------------------------------- |
| 3222 | 3222 | |
@@ -3241,24 +3241,24 @@ discard block |
||
| 3241 | 3241 | // -------------------------------------------------------------------------------- |
| 3242 | 3242 | function privConvertHeader2FileInfo($p_header, &$p_info) |
| 3243 | 3243 | { |
| 3244 | - $v_result=1; |
|
| 3245 | - |
|
| 3246 | - // ----- Get the interesting attributes |
|
| 3247 | - $v_temp_path = PclZipUtilPathReduction($p_header['filename']); |
|
| 3248 | - $p_info['filename'] = $v_temp_path; |
|
| 3249 | - $v_temp_path = PclZipUtilPathReduction($p_header['stored_filename']); |
|
| 3250 | - $p_info['stored_filename'] = $v_temp_path; |
|
| 3251 | - $p_info['size'] = $p_header['size']; |
|
| 3252 | - $p_info['compressed_size'] = $p_header['compressed_size']; |
|
| 3253 | - $p_info['mtime'] = $p_header['mtime']; |
|
| 3254 | - $p_info['comment'] = $p_header['comment']; |
|
| 3255 | - $p_info['folder'] = (($p_header['external']&0x00000010)==0x00000010); |
|
| 3256 | - $p_info['index'] = $p_header['index']; |
|
| 3257 | - $p_info['status'] = $p_header['status']; |
|
| 3258 | - $p_info['crc'] = $p_header['crc']; |
|
| 3259 | - |
|
| 3260 | - // ----- Return |
|
| 3261 | - return $v_result; |
|
| 3244 | + $v_result=1; |
|
| 3245 | + |
|
| 3246 | + // ----- Get the interesting attributes |
|
| 3247 | + $v_temp_path = PclZipUtilPathReduction($p_header['filename']); |
|
| 3248 | + $p_info['filename'] = $v_temp_path; |
|
| 3249 | + $v_temp_path = PclZipUtilPathReduction($p_header['stored_filename']); |
|
| 3250 | + $p_info['stored_filename'] = $v_temp_path; |
|
| 3251 | + $p_info['size'] = $p_header['size']; |
|
| 3252 | + $p_info['compressed_size'] = $p_header['compressed_size']; |
|
| 3253 | + $p_info['mtime'] = $p_header['mtime']; |
|
| 3254 | + $p_info['comment'] = $p_header['comment']; |
|
| 3255 | + $p_info['folder'] = (($p_header['external']&0x00000010)==0x00000010); |
|
| 3256 | + $p_info['index'] = $p_header['index']; |
|
| 3257 | + $p_info['status'] = $p_header['status']; |
|
| 3258 | + $p_info['crc'] = $p_header['crc']; |
|
| 3259 | + |
|
| 3260 | + // ----- Return |
|
| 3261 | + return $v_result; |
|
| 3262 | 3262 | } |
| 3263 | 3263 | // -------------------------------------------------------------------------------- |
| 3264 | 3264 | |
@@ -3280,122 +3280,122 @@ discard block |
||
| 3280 | 3280 | // -------------------------------------------------------------------------------- |
| 3281 | 3281 | function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all_path, &$p_options) |
| 3282 | 3282 | { |
| 3283 | - $v_result=1; |
|
| 3283 | + $v_result=1; |
|
| 3284 | 3284 | |
| 3285 | - // ----- Magic quotes trick |
|
| 3286 | - $this->privDisableMagicQuotes(); |
|
| 3285 | + // ----- Magic quotes trick |
|
| 3286 | + $this->privDisableMagicQuotes(); |
|
| 3287 | 3287 | |
| 3288 | - // ----- Check the path |
|
| 3289 | - if ( ($p_path == "") |
|
| 3290 | - || ( (substr($p_path, 0, 1) != "/") |
|
| 3291 | - && (substr($p_path, 0, 3) != "../") |
|
| 3288 | + // ----- Check the path |
|
| 3289 | + if ( ($p_path == "") |
|
| 3290 | + || ( (substr($p_path, 0, 1) != "/") |
|
| 3291 | + && (substr($p_path, 0, 3) != "../") |
|
| 3292 | 3292 | && (substr($p_path,1,2)!=":/"))) |
| 3293 | - $p_path = "./".$p_path; |
|
| 3294 | - |
|
| 3295 | - // ----- Reduce the path last (and duplicated) '/' |
|
| 3296 | - if (($p_path != "./") && ($p_path != "/")) |
|
| 3297 | - { |
|
| 3298 | - // ----- Look for the path end '/' |
|
| 3299 | - while (substr($p_path, -1) == "/") |
|
| 3300 | - { |
|
| 3301 | - $p_path = substr($p_path, 0, strlen($p_path)-1); |
|
| 3302 | - } |
|
| 3303 | - } |
|
| 3293 | + $p_path = "./".$p_path; |
|
| 3294 | + |
|
| 3295 | + // ----- Reduce the path last (and duplicated) '/' |
|
| 3296 | + if (($p_path != "./") && ($p_path != "/")) |
|
| 3297 | + { |
|
| 3298 | + // ----- Look for the path end '/' |
|
| 3299 | + while (substr($p_path, -1) == "/") |
|
| 3300 | + { |
|
| 3301 | + $p_path = substr($p_path, 0, strlen($p_path)-1); |
|
| 3302 | + } |
|
| 3303 | + } |
|
| 3304 | 3304 | |
| 3305 | - // ----- Look for path to remove format (should end by /) |
|
| 3306 | - if (($p_remove_path != "") && (substr($p_remove_path, -1) != '/')) |
|
| 3307 | - { |
|
| 3308 | - $p_remove_path .= '/'; |
|
| 3309 | - } |
|
| 3310 | - $p_remove_path_size = strlen($p_remove_path); |
|
| 3305 | + // ----- Look for path to remove format (should end by /) |
|
| 3306 | + if (($p_remove_path != "") && (substr($p_remove_path, -1) != '/')) |
|
| 3307 | + { |
|
| 3308 | + $p_remove_path .= '/'; |
|
| 3309 | + } |
|
| 3310 | + $p_remove_path_size = strlen($p_remove_path); |
|
| 3311 | 3311 | |
| 3312 | - // ----- Open the zip file |
|
| 3313 | - if (($v_result = $this->privOpenFd('rb')) != 1) |
|
| 3314 | - { |
|
| 3315 | - $this->privSwapBackMagicQuotes(); |
|
| 3316 | - return $v_result; |
|
| 3317 | - } |
|
| 3312 | + // ----- Open the zip file |
|
| 3313 | + if (($v_result = $this->privOpenFd('rb')) != 1) |
|
| 3314 | + { |
|
| 3315 | + $this->privSwapBackMagicQuotes(); |
|
| 3316 | + return $v_result; |
|
| 3317 | + } |
|
| 3318 | 3318 | |
| 3319 | - // ----- Read the central directory informations |
|
| 3320 | - $v_central_dir = array(); |
|
| 3321 | - if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) |
|
| 3322 | - { |
|
| 3323 | - // ----- Close the zip file |
|
| 3324 | - $this->privCloseFd(); |
|
| 3325 | - $this->privSwapBackMagicQuotes(); |
|
| 3319 | + // ----- Read the central directory informations |
|
| 3320 | + $v_central_dir = array(); |
|
| 3321 | + if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) |
|
| 3322 | + { |
|
| 3323 | + // ----- Close the zip file |
|
| 3324 | + $this->privCloseFd(); |
|
| 3325 | + $this->privSwapBackMagicQuotes(); |
|
| 3326 | 3326 | |
| 3327 | - return $v_result; |
|
| 3328 | - } |
|
| 3327 | + return $v_result; |
|
| 3328 | + } |
|
| 3329 | 3329 | |
| 3330 | - // ----- Start at beginning of Central Dir |
|
| 3331 | - $v_pos_entry = $v_central_dir['offset']; |
|
| 3330 | + // ----- Start at beginning of Central Dir |
|
| 3331 | + $v_pos_entry = $v_central_dir['offset']; |
|
| 3332 | 3332 | |
| 3333 | - // ----- Read each entry |
|
| 3334 | - $j_start = 0; |
|
| 3335 | - for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++) |
|
| 3336 | - { |
|
| 3333 | + // ----- Read each entry |
|
| 3334 | + $j_start = 0; |
|
| 3335 | + for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++) |
|
| 3336 | + { |
|
| 3337 | 3337 | |
| 3338 | - // ----- Read next Central dir entry |
|
| 3339 | - @rewind($this->zip_fd); |
|
| 3340 | - if (@fseek($this->zip_fd, $v_pos_entry)) |
|
| 3341 | - { |
|
| 3342 | - // ----- Close the zip file |
|
| 3343 | - $this->privCloseFd(); |
|
| 3344 | - $this->privSwapBackMagicQuotes(); |
|
| 3338 | + // ----- Read next Central dir entry |
|
| 3339 | + @rewind($this->zip_fd); |
|
| 3340 | + if (@fseek($this->zip_fd, $v_pos_entry)) |
|
| 3341 | + { |
|
| 3342 | + // ----- Close the zip file |
|
| 3343 | + $this->privCloseFd(); |
|
| 3344 | + $this->privSwapBackMagicQuotes(); |
|
| 3345 | 3345 | |
| 3346 | - // ----- Error log |
|
| 3347 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); |
|
| 3346 | + // ----- Error log |
|
| 3347 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); |
|
| 3348 | 3348 | |
| 3349 | - // ----- Return |
|
| 3350 | - return PclZip::errorCode(); |
|
| 3351 | - } |
|
| 3349 | + // ----- Return |
|
| 3350 | + return PclZip::errorCode(); |
|
| 3351 | + } |
|
| 3352 | 3352 | |
| 3353 | - // ----- Read the file header |
|
| 3354 | - $v_header = array(); |
|
| 3355 | - if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1) |
|
| 3356 | - { |
|
| 3357 | - // ----- Close the zip file |
|
| 3358 | - $this->privCloseFd(); |
|
| 3359 | - $this->privSwapBackMagicQuotes(); |
|
| 3353 | + // ----- Read the file header |
|
| 3354 | + $v_header = array(); |
|
| 3355 | + if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1) |
|
| 3356 | + { |
|
| 3357 | + // ----- Close the zip file |
|
| 3358 | + $this->privCloseFd(); |
|
| 3359 | + $this->privSwapBackMagicQuotes(); |
|
| 3360 | 3360 | |
| 3361 | - return $v_result; |
|
| 3362 | - } |
|
| 3361 | + return $v_result; |
|
| 3362 | + } |
|
| 3363 | 3363 | |
| 3364 | - // ----- Store the index |
|
| 3365 | - $v_header['index'] = $i; |
|
| 3364 | + // ----- Store the index |
|
| 3365 | + $v_header['index'] = $i; |
|
| 3366 | 3366 | |
| 3367 | - // ----- Store the file position |
|
| 3368 | - $v_pos_entry = ftell($this->zip_fd); |
|
| 3367 | + // ----- Store the file position |
|
| 3368 | + $v_pos_entry = ftell($this->zip_fd); |
|
| 3369 | 3369 | |
| 3370 | - // ----- Look for the specific extract rules |
|
| 3371 | - $v_extract = false; |
|
| 3370 | + // ----- Look for the specific extract rules |
|
| 3371 | + $v_extract = false; |
|
| 3372 | 3372 | |
| 3373 | - // ----- Look for extract by name rule |
|
| 3374 | - if ( (isset($p_options[PCLZIP_OPT_BY_NAME])) |
|
| 3375 | - && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) { |
|
| 3373 | + // ----- Look for extract by name rule |
|
| 3374 | + if ( (isset($p_options[PCLZIP_OPT_BY_NAME])) |
|
| 3375 | + && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) { |
|
| 3376 | 3376 | |
| 3377 | - // ----- Look if the filename is in the list |
|
| 3378 | - for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_extract); $j++) { |
|
| 3377 | + // ----- Look if the filename is in the list |
|
| 3378 | + for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_extract); $j++) { |
|
| 3379 | 3379 | |
| 3380 | - // ----- Look for a directory |
|
| 3381 | - if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") { |
|
| 3380 | + // ----- Look for a directory |
|
| 3381 | + if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") { |
|
| 3382 | 3382 | |
| 3383 | - // ----- Look if the directory is in the filename path |
|
| 3384 | - if ( (strlen($v_header['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) |
|
| 3385 | - && (substr($v_header['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) { |
|
| 3386 | - $v_extract = true; |
|
| 3387 | - } |
|
| 3388 | - } |
|
| 3389 | - // ----- Look for a filename |
|
| 3390 | - elseif ($v_header['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) { |
|
| 3391 | - $v_extract = true; |
|
| 3392 | - } |
|
| 3393 | - } |
|
| 3394 | - } |
|
| 3383 | + // ----- Look if the directory is in the filename path |
|
| 3384 | + if ( (strlen($v_header['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) |
|
| 3385 | + && (substr($v_header['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) { |
|
| 3386 | + $v_extract = true; |
|
| 3387 | + } |
|
| 3388 | + } |
|
| 3389 | + // ----- Look for a filename |
|
| 3390 | + elseif ($v_header['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) { |
|
| 3391 | + $v_extract = true; |
|
| 3392 | + } |
|
| 3393 | + } |
|
| 3394 | + } |
|
| 3395 | 3395 | |
| 3396 | - // ----- Look for extract by ereg rule |
|
| 3397 | - // ereg() is deprecated with PHP 5.3 |
|
| 3398 | - /* |
|
| 3396 | + // ----- Look for extract by ereg rule |
|
| 3397 | + // ereg() is deprecated with PHP 5.3 |
|
| 3398 | + /* |
|
| 3399 | 3399 | else if ( (isset($p_options[PCLZIP_OPT_BY_EREG])) |
| 3400 | 3400 | && ($p_options[PCLZIP_OPT_BY_EREG] != "")) { |
| 3401 | 3401 | |
@@ -3405,207 +3405,207 @@ discard block |
||
| 3405 | 3405 | } |
| 3406 | 3406 | */ |
| 3407 | 3407 | |
| 3408 | - // ----- Look for extract by preg rule |
|
| 3409 | - else if ( (isset($p_options[PCLZIP_OPT_BY_PREG])) |
|
| 3410 | - && ($p_options[PCLZIP_OPT_BY_PREG] != "")) { |
|
| 3408 | + // ----- Look for extract by preg rule |
|
| 3409 | + else if ( (isset($p_options[PCLZIP_OPT_BY_PREG])) |
|
| 3410 | + && ($p_options[PCLZIP_OPT_BY_PREG] != "")) { |
|
| 3411 | 3411 | |
| 3412 | - if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header['stored_filename'])) { |
|
| 3413 | - $v_extract = true; |
|
| 3414 | - } |
|
| 3415 | - } |
|
| 3412 | + if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header['stored_filename'])) { |
|
| 3413 | + $v_extract = true; |
|
| 3414 | + } |
|
| 3415 | + } |
|
| 3416 | 3416 | |
| 3417 | - // ----- Look for extract by index rule |
|
| 3418 | - else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX])) |
|
| 3419 | - && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) { |
|
| 3417 | + // ----- Look for extract by index rule |
|
| 3418 | + else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX])) |
|
| 3419 | + && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) { |
|
| 3420 | 3420 | |
| 3421 | - // ----- Look if the index is in the list |
|
| 3422 | - for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_extract); $j++) { |
|
| 3423 | - |
|
| 3424 | - if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) { |
|
| 3425 | - $v_extract = true; |
|
| 3426 | - } |
|
| 3427 | - if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) { |
|
| 3428 | - $j_start = $j+1; |
|
| 3429 | - } |
|
| 3430 | - |
|
| 3431 | - if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) { |
|
| 3432 | - break; |
|
| 3433 | - } |
|
| 3434 | - } |
|
| 3435 | - } |
|
| 3421 | + // ----- Look if the index is in the list |
|
| 3422 | + for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_extract); $j++) { |
|
| 3423 | + |
|
| 3424 | + if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) { |
|
| 3425 | + $v_extract = true; |
|
| 3426 | + } |
|
| 3427 | + if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) { |
|
| 3428 | + $j_start = $j+1; |
|
| 3429 | + } |
|
| 3430 | + |
|
| 3431 | + if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) { |
|
| 3432 | + break; |
|
| 3433 | + } |
|
| 3434 | + } |
|
| 3435 | + } |
|
| 3436 | 3436 | |
| 3437 | - // ----- Look for no rule, which means extract all the archive |
|
| 3438 | - else { |
|
| 3439 | - $v_extract = true; |
|
| 3440 | - } |
|
| 3437 | + // ----- Look for no rule, which means extract all the archive |
|
| 3438 | + else { |
|
| 3439 | + $v_extract = true; |
|
| 3440 | + } |
|
| 3441 | 3441 | |
| 3442 | 3442 | // ----- Check compression method |
| 3443 | 3443 | if ( ($v_extract) |
| 3444 | - && ( ($v_header['compression'] != 8) |
|
| 3445 | - && ($v_header['compression'] != 0))) { |
|
| 3446 | - $v_header['status'] = 'unsupported_compression'; |
|
| 3444 | + && ( ($v_header['compression'] != 8) |
|
| 3445 | + && ($v_header['compression'] != 0))) { |
|
| 3446 | + $v_header['status'] = 'unsupported_compression'; |
|
| 3447 | 3447 | |
| 3448 | - // ----- Look for PCLZIP_OPT_STOP_ON_ERROR |
|
| 3449 | - if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
|
| 3450 | - && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { |
|
| 3448 | + // ----- Look for PCLZIP_OPT_STOP_ON_ERROR |
|
| 3449 | + if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
|
| 3450 | + && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { |
|
| 3451 | 3451 | |
| 3452 | - $this->privSwapBackMagicQuotes(); |
|
| 3452 | + $this->privSwapBackMagicQuotes(); |
|
| 3453 | 3453 | |
| 3454 | - PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_COMPRESSION, |
|
| 3455 | - "Filename '".$v_header['stored_filename']."' is " |
|
| 3456 | - ."compressed by an unsupported compression " |
|
| 3457 | - ."method (".$v_header['compression'].") "); |
|
| 3454 | + PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_COMPRESSION, |
|
| 3455 | + "Filename '".$v_header['stored_filename']."' is " |
|
| 3456 | + ."compressed by an unsupported compression " |
|
| 3457 | + ."method (".$v_header['compression'].") "); |
|
| 3458 | 3458 | |
| 3459 | - return PclZip::errorCode(); |
|
| 3459 | + return PclZip::errorCode(); |
|
| 3460 | 3460 | } |
| 3461 | 3461 | } |
| 3462 | 3462 | |
| 3463 | 3463 | // ----- Check encrypted files |
| 3464 | 3464 | if (($v_extract) && (($v_header['flag'] & 1) == 1)) { |
| 3465 | - $v_header['status'] = 'unsupported_encryption'; |
|
| 3465 | + $v_header['status'] = 'unsupported_encryption'; |
|
| 3466 | 3466 | |
| 3467 | - // ----- Look for PCLZIP_OPT_STOP_ON_ERROR |
|
| 3468 | - if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
|
| 3469 | - && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { |
|
| 3467 | + // ----- Look for PCLZIP_OPT_STOP_ON_ERROR |
|
| 3468 | + if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
|
| 3469 | + && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { |
|
| 3470 | 3470 | |
| 3471 | - $this->privSwapBackMagicQuotes(); |
|
| 3471 | + $this->privSwapBackMagicQuotes(); |
|
| 3472 | 3472 | |
| 3473 | - PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION, |
|
| 3474 | - "Unsupported encryption for " |
|
| 3475 | - ." filename '".$v_header['stored_filename'] |
|
| 3473 | + PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION, |
|
| 3474 | + "Unsupported encryption for " |
|
| 3475 | + ." filename '".$v_header['stored_filename'] |
|
| 3476 | 3476 | ."'"); |
| 3477 | 3477 | |
| 3478 | - return PclZip::errorCode(); |
|
| 3478 | + return PclZip::errorCode(); |
|
| 3479 | 3479 | } |
| 3480 | - } |
|
| 3480 | + } |
|
| 3481 | 3481 | |
| 3482 | - // ----- Look for real extraction |
|
| 3483 | - if (($v_extract) && ($v_header['status'] != 'ok')) { |
|
| 3484 | - $v_result = $this->privConvertHeader2FileInfo($v_header, |
|
| 3485 | - $p_file_list[$v_nb_extracted++]); |
|
| 3486 | - if ($v_result != 1) { |
|
| 3487 | - $this->privCloseFd(); |
|
| 3488 | - $this->privSwapBackMagicQuotes(); |
|
| 3489 | - return $v_result; |
|
| 3490 | - } |
|
| 3482 | + // ----- Look for real extraction |
|
| 3483 | + if (($v_extract) && ($v_header['status'] != 'ok')) { |
|
| 3484 | + $v_result = $this->privConvertHeader2FileInfo($v_header, |
|
| 3485 | + $p_file_list[$v_nb_extracted++]); |
|
| 3486 | + if ($v_result != 1) { |
|
| 3487 | + $this->privCloseFd(); |
|
| 3488 | + $this->privSwapBackMagicQuotes(); |
|
| 3489 | + return $v_result; |
|
| 3490 | + } |
|
| 3491 | 3491 | |
| 3492 | - $v_extract = false; |
|
| 3493 | - } |
|
| 3492 | + $v_extract = false; |
|
| 3493 | + } |
|
| 3494 | 3494 | |
| 3495 | - // ----- Look for real extraction |
|
| 3496 | - if ($v_extract) |
|
| 3497 | - { |
|
| 3495 | + // ----- Look for real extraction |
|
| 3496 | + if ($v_extract) |
|
| 3497 | + { |
|
| 3498 | 3498 | |
| 3499 | - // ----- Go to the file position |
|
| 3500 | - @rewind($this->zip_fd); |
|
| 3501 | - if (@fseek($this->zip_fd, $v_header['offset'])) |
|
| 3502 | - { |
|
| 3503 | - // ----- Close the zip file |
|
| 3504 | - $this->privCloseFd(); |
|
| 3499 | + // ----- Go to the file position |
|
| 3500 | + @rewind($this->zip_fd); |
|
| 3501 | + if (@fseek($this->zip_fd, $v_header['offset'])) |
|
| 3502 | + { |
|
| 3503 | + // ----- Close the zip file |
|
| 3504 | + $this->privCloseFd(); |
|
| 3505 | 3505 | |
| 3506 | - $this->privSwapBackMagicQuotes(); |
|
| 3506 | + $this->privSwapBackMagicQuotes(); |
|
| 3507 | 3507 | |
| 3508 | - // ----- Error log |
|
| 3509 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); |
|
| 3508 | + // ----- Error log |
|
| 3509 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); |
|
| 3510 | 3510 | |
| 3511 | - // ----- Return |
|
| 3512 | - return PclZip::errorCode(); |
|
| 3513 | - } |
|
| 3511 | + // ----- Return |
|
| 3512 | + return PclZip::errorCode(); |
|
| 3513 | + } |
|
| 3514 | 3514 | |
| 3515 | - // ----- Look for extraction as string |
|
| 3516 | - if ($p_options[PCLZIP_OPT_EXTRACT_AS_STRING]) { |
|
| 3515 | + // ----- Look for extraction as string |
|
| 3516 | + if ($p_options[PCLZIP_OPT_EXTRACT_AS_STRING]) { |
|
| 3517 | 3517 | |
| 3518 | - $v_string = ''; |
|
| 3518 | + $v_string = ''; |
|
| 3519 | 3519 | |
| 3520 | - // ----- Extracting the file |
|
| 3521 | - $v_result1 = $this->privExtractFileAsString($v_header, $v_string, $p_options); |
|
| 3522 | - if ($v_result1 < 1) { |
|
| 3523 | - $this->privCloseFd(); |
|
| 3524 | - $this->privSwapBackMagicQuotes(); |
|
| 3525 | - return $v_result1; |
|
| 3526 | - } |
|
| 3520 | + // ----- Extracting the file |
|
| 3521 | + $v_result1 = $this->privExtractFileAsString($v_header, $v_string, $p_options); |
|
| 3522 | + if ($v_result1 < 1) { |
|
| 3523 | + $this->privCloseFd(); |
|
| 3524 | + $this->privSwapBackMagicQuotes(); |
|
| 3525 | + return $v_result1; |
|
| 3526 | + } |
|
| 3527 | 3527 | |
| 3528 | - // ----- Get the only interesting attributes |
|
| 3529 | - if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted])) != 1) |
|
| 3530 | - { |
|
| 3531 | - // ----- Close the zip file |
|
| 3532 | - $this->privCloseFd(); |
|
| 3533 | - $this->privSwapBackMagicQuotes(); |
|
| 3528 | + // ----- Get the only interesting attributes |
|
| 3529 | + if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted])) != 1) |
|
| 3530 | + { |
|
| 3531 | + // ----- Close the zip file |
|
| 3532 | + $this->privCloseFd(); |
|
| 3533 | + $this->privSwapBackMagicQuotes(); |
|
| 3534 | 3534 | |
| 3535 | - return $v_result; |
|
| 3536 | - } |
|
| 3535 | + return $v_result; |
|
| 3536 | + } |
|
| 3537 | 3537 | |
| 3538 | - // ----- Set the file content |
|
| 3539 | - $p_file_list[$v_nb_extracted]['content'] = $v_string; |
|
| 3538 | + // ----- Set the file content |
|
| 3539 | + $p_file_list[$v_nb_extracted]['content'] = $v_string; |
|
| 3540 | 3540 | |
| 3541 | - // ----- Next extracted file |
|
| 3542 | - $v_nb_extracted++; |
|
| 3541 | + // ----- Next extracted file |
|
| 3542 | + $v_nb_extracted++; |
|
| 3543 | 3543 | |
| 3544 | - // ----- Look for user callback abort |
|
| 3545 | - if ($v_result1 == 2) { |
|
| 3546 | - break; |
|
| 3547 | - } |
|
| 3548 | - } |
|
| 3549 | - // ----- Look for extraction in standard output |
|
| 3550 | - elseif ( (isset($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) |
|
| 3551 | - && ($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) { |
|
| 3552 | - // ----- Extracting the file in standard output |
|
| 3553 | - $v_result1 = $this->privExtractFileInOutput($v_header, $p_options); |
|
| 3554 | - if ($v_result1 < 1) { |
|
| 3555 | - $this->privCloseFd(); |
|
| 3556 | - $this->privSwapBackMagicQuotes(); |
|
| 3557 | - return $v_result1; |
|
| 3558 | - } |
|
| 3544 | + // ----- Look for user callback abort |
|
| 3545 | + if ($v_result1 == 2) { |
|
| 3546 | + break; |
|
| 3547 | + } |
|
| 3548 | + } |
|
| 3549 | + // ----- Look for extraction in standard output |
|
| 3550 | + elseif ( (isset($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) |
|
| 3551 | + && ($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) { |
|
| 3552 | + // ----- Extracting the file in standard output |
|
| 3553 | + $v_result1 = $this->privExtractFileInOutput($v_header, $p_options); |
|
| 3554 | + if ($v_result1 < 1) { |
|
| 3555 | + $this->privCloseFd(); |
|
| 3556 | + $this->privSwapBackMagicQuotes(); |
|
| 3557 | + return $v_result1; |
|
| 3558 | + } |
|
| 3559 | 3559 | |
| 3560 | - // ----- Get the only interesting attributes |
|
| 3561 | - if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) { |
|
| 3562 | - $this->privCloseFd(); |
|
| 3563 | - $this->privSwapBackMagicQuotes(); |
|
| 3564 | - return $v_result; |
|
| 3565 | - } |
|
| 3560 | + // ----- Get the only interesting attributes |
|
| 3561 | + if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) { |
|
| 3562 | + $this->privCloseFd(); |
|
| 3563 | + $this->privSwapBackMagicQuotes(); |
|
| 3564 | + return $v_result; |
|
| 3565 | + } |
|
| 3566 | 3566 | |
| 3567 | - // ----- Look for user callback abort |
|
| 3568 | - if ($v_result1 == 2) { |
|
| 3569 | - break; |
|
| 3570 | - } |
|
| 3571 | - } |
|
| 3572 | - // ----- Look for normal extraction |
|
| 3573 | - else { |
|
| 3574 | - // ----- Extracting the file |
|
| 3575 | - $v_result1 = $this->privExtractFile($v_header, |
|
| 3576 | - $p_path, $p_remove_path, |
|
| 3567 | + // ----- Look for user callback abort |
|
| 3568 | + if ($v_result1 == 2) { |
|
| 3569 | + break; |
|
| 3570 | + } |
|
| 3571 | + } |
|
| 3572 | + // ----- Look for normal extraction |
|
| 3573 | + else { |
|
| 3574 | + // ----- Extracting the file |
|
| 3575 | + $v_result1 = $this->privExtractFile($v_header, |
|
| 3576 | + $p_path, $p_remove_path, |
|
| 3577 | 3577 | $p_remove_all_path, |
| 3578 | 3578 | $p_options); |
| 3579 | - if ($v_result1 < 1) { |
|
| 3580 | - $this->privCloseFd(); |
|
| 3581 | - $this->privSwapBackMagicQuotes(); |
|
| 3582 | - return $v_result1; |
|
| 3583 | - } |
|
| 3579 | + if ($v_result1 < 1) { |
|
| 3580 | + $this->privCloseFd(); |
|
| 3581 | + $this->privSwapBackMagicQuotes(); |
|
| 3582 | + return $v_result1; |
|
| 3583 | + } |
|
| 3584 | 3584 | |
| 3585 | - // ----- Get the only interesting attributes |
|
| 3586 | - if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) |
|
| 3587 | - { |
|
| 3588 | - // ----- Close the zip file |
|
| 3589 | - $this->privCloseFd(); |
|
| 3590 | - $this->privSwapBackMagicQuotes(); |
|
| 3585 | + // ----- Get the only interesting attributes |
|
| 3586 | + if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) |
|
| 3587 | + { |
|
| 3588 | + // ----- Close the zip file |
|
| 3589 | + $this->privCloseFd(); |
|
| 3590 | + $this->privSwapBackMagicQuotes(); |
|
| 3591 | 3591 | |
| 3592 | - return $v_result; |
|
| 3593 | - } |
|
| 3592 | + return $v_result; |
|
| 3593 | + } |
|
| 3594 | 3594 | |
| 3595 | - // ----- Look for user callback abort |
|
| 3596 | - if ($v_result1 == 2) { |
|
| 3597 | - break; |
|
| 3598 | - } |
|
| 3599 | - } |
|
| 3600 | - } |
|
| 3601 | - } |
|
| 3595 | + // ----- Look for user callback abort |
|
| 3596 | + if ($v_result1 == 2) { |
|
| 3597 | + break; |
|
| 3598 | + } |
|
| 3599 | + } |
|
| 3600 | + } |
|
| 3601 | + } |
|
| 3602 | 3602 | |
| 3603 | - // ----- Close the zip file |
|
| 3604 | - $this->privCloseFd(); |
|
| 3605 | - $this->privSwapBackMagicQuotes(); |
|
| 3603 | + // ----- Close the zip file |
|
| 3604 | + $this->privCloseFd(); |
|
| 3605 | + $this->privSwapBackMagicQuotes(); |
|
| 3606 | 3606 | |
| 3607 | - // ----- Return |
|
| 3608 | - return $v_result; |
|
| 3607 | + // ----- Return |
|
| 3608 | + return $v_result; |
|
| 3609 | 3609 | } |
| 3610 | 3610 | // -------------------------------------------------------------------------------- |
| 3611 | 3611 | |
@@ -3620,346 +3620,346 @@ discard block |
||
| 3620 | 3620 | // -------------------------------------------------------------------------------- |
| 3621 | 3621 | function privExtractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_options) |
| 3622 | 3622 | { |
| 3623 | - $v_result=1; |
|
| 3623 | + $v_result=1; |
|
| 3624 | 3624 | |
| 3625 | - // ----- Read the file header |
|
| 3626 | - if (($v_result = $this->privReadFileHeader($v_header)) != 1) |
|
| 3627 | - { |
|
| 3628 | - // ----- Return |
|
| 3629 | - return $v_result; |
|
| 3630 | - } |
|
| 3625 | + // ----- Read the file header |
|
| 3626 | + if (($v_result = $this->privReadFileHeader($v_header)) != 1) |
|
| 3627 | + { |
|
| 3628 | + // ----- Return |
|
| 3629 | + return $v_result; |
|
| 3630 | + } |
|
| 3631 | 3631 | |
| 3632 | 3632 | |
| 3633 | - // ----- Check that the file header is coherent with $p_entry info |
|
| 3634 | - if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) { |
|
| 3635 | - // TBC |
|
| 3636 | - } |
|
| 3633 | + // ----- Check that the file header is coherent with $p_entry info |
|
| 3634 | + if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) { |
|
| 3635 | + // TBC |
|
| 3636 | + } |
|
| 3637 | 3637 | |
| 3638 | - // ----- Look for all path to remove |
|
| 3639 | - if ($p_remove_all_path == true) { |
|
| 3640 | - // ----- Look for folder entry that not need to be extracted |
|
| 3641 | - if (($p_entry['external']&0x00000010)==0x00000010) { |
|
| 3638 | + // ----- Look for all path to remove |
|
| 3639 | + if ($p_remove_all_path == true) { |
|
| 3640 | + // ----- Look for folder entry that not need to be extracted |
|
| 3641 | + if (($p_entry['external']&0x00000010)==0x00000010) { |
|
| 3642 | 3642 | |
| 3643 | - $p_entry['status'] = "filtered"; |
|
| 3643 | + $p_entry['status'] = "filtered"; |
|
| 3644 | 3644 | |
| 3645 | - return $v_result; |
|
| 3646 | - } |
|
| 3645 | + return $v_result; |
|
| 3646 | + } |
|
| 3647 | 3647 | |
| 3648 | - // ----- Get the basename of the path |
|
| 3649 | - $p_entry['filename'] = basename($p_entry['filename']); |
|
| 3650 | - } |
|
| 3648 | + // ----- Get the basename of the path |
|
| 3649 | + $p_entry['filename'] = basename($p_entry['filename']); |
|
| 3650 | + } |
|
| 3651 | 3651 | |
| 3652 | - // ----- Look for path to remove |
|
| 3653 | - else if ($p_remove_path != "") |
|
| 3654 | - { |
|
| 3655 | - if (PclZipUtilPathInclusion($p_remove_path, $p_entry['filename']) == 2) |
|
| 3656 | - { |
|
| 3652 | + // ----- Look for path to remove |
|
| 3653 | + else if ($p_remove_path != "") |
|
| 3654 | + { |
|
| 3655 | + if (PclZipUtilPathInclusion($p_remove_path, $p_entry['filename']) == 2) |
|
| 3656 | + { |
|
| 3657 | 3657 | |
| 3658 | - // ----- Change the file status |
|
| 3659 | - $p_entry['status'] = "filtered"; |
|
| 3658 | + // ----- Change the file status |
|
| 3659 | + $p_entry['status'] = "filtered"; |
|
| 3660 | 3660 | |
| 3661 | - // ----- Return |
|
| 3662 | - return $v_result; |
|
| 3663 | - } |
|
| 3661 | + // ----- Return |
|
| 3662 | + return $v_result; |
|
| 3663 | + } |
|
| 3664 | 3664 | |
| 3665 | - $p_remove_path_size = strlen($p_remove_path); |
|
| 3666 | - if (substr($p_entry['filename'], 0, $p_remove_path_size) == $p_remove_path) |
|
| 3667 | - { |
|
| 3665 | + $p_remove_path_size = strlen($p_remove_path); |
|
| 3666 | + if (substr($p_entry['filename'], 0, $p_remove_path_size) == $p_remove_path) |
|
| 3667 | + { |
|
| 3668 | 3668 | |
| 3669 | - // ----- Remove the path |
|
| 3670 | - $p_entry['filename'] = substr($p_entry['filename'], $p_remove_path_size); |
|
| 3669 | + // ----- Remove the path |
|
| 3670 | + $p_entry['filename'] = substr($p_entry['filename'], $p_remove_path_size); |
|
| 3671 | 3671 | |
| 3672 | - } |
|
| 3673 | - } |
|
| 3672 | + } |
|
| 3673 | + } |
|
| 3674 | 3674 | |
| 3675 | - // ----- Add the path |
|
| 3676 | - if ($p_path != '') { |
|
| 3677 | - $p_entry['filename'] = $p_path."/".$p_entry['filename']; |
|
| 3678 | - } |
|
| 3675 | + // ----- Add the path |
|
| 3676 | + if ($p_path != '') { |
|
| 3677 | + $p_entry['filename'] = $p_path."/".$p_entry['filename']; |
|
| 3678 | + } |
|
| 3679 | 3679 | |
| 3680 | - // ----- Check a base_dir_restriction |
|
| 3681 | - if (isset($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION])) { |
|
| 3682 | - $v_inclusion |
|
| 3683 | - = PclZipUtilPathInclusion($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION], |
|
| 3684 | - $p_entry['filename']); |
|
| 3685 | - if ($v_inclusion == 0) { |
|
| 3686 | - |
|
| 3687 | - PclZip::privErrorLog(PCLZIP_ERR_DIRECTORY_RESTRICTION, |
|
| 3688 | - "Filename '".$p_entry['filename']."' is " |
|
| 3680 | + // ----- Check a base_dir_restriction |
|
| 3681 | + if (isset($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION])) { |
|
| 3682 | + $v_inclusion |
|
| 3683 | + = PclZipUtilPathInclusion($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION], |
|
| 3684 | + $p_entry['filename']); |
|
| 3685 | + if ($v_inclusion == 0) { |
|
| 3686 | + |
|
| 3687 | + PclZip::privErrorLog(PCLZIP_ERR_DIRECTORY_RESTRICTION, |
|
| 3688 | + "Filename '".$p_entry['filename']."' is " |
|
| 3689 | 3689 | ."outside PCLZIP_OPT_EXTRACT_DIR_RESTRICTION"); |
| 3690 | 3690 | |
| 3691 | - return PclZip::errorCode(); |
|
| 3692 | - } |
|
| 3693 | - } |
|
| 3691 | + return PclZip::errorCode(); |
|
| 3692 | + } |
|
| 3693 | + } |
|
| 3694 | 3694 | |
| 3695 | - // ----- Look for pre-extract callback |
|
| 3696 | - if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) { |
|
| 3695 | + // ----- Look for pre-extract callback |
|
| 3696 | + if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) { |
|
| 3697 | 3697 | |
| 3698 | - // ----- Generate a local information |
|
| 3699 | - $v_local_header = array(); |
|
| 3700 | - $this->privConvertHeader2FileInfo($p_entry, $v_local_header); |
|
| 3698 | + // ----- Generate a local information |
|
| 3699 | + $v_local_header = array(); |
|
| 3700 | + $this->privConvertHeader2FileInfo($p_entry, $v_local_header); |
|
| 3701 | 3701 | |
| 3702 | - // ----- Call the callback |
|
| 3703 | - // Here I do not use call_user_func() because I need to send a reference to the |
|
| 3704 | - // header. |
|
| 3702 | + // ----- Call the callback |
|
| 3703 | + // Here I do not use call_user_func() because I need to send a reference to the |
|
| 3704 | + // header. |
|
| 3705 | 3705 | // eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);'); |
| 3706 | - $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header); |
|
| 3707 | - if ($v_result == 0) { |
|
| 3708 | - // ----- Change the file status |
|
| 3709 | - $p_entry['status'] = "skipped"; |
|
| 3710 | - $v_result = 1; |
|
| 3711 | - } |
|
| 3706 | + $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header); |
|
| 3707 | + if ($v_result == 0) { |
|
| 3708 | + // ----- Change the file status |
|
| 3709 | + $p_entry['status'] = "skipped"; |
|
| 3710 | + $v_result = 1; |
|
| 3711 | + } |
|
| 3712 | 3712 | |
| 3713 | - // ----- Look for abort result |
|
| 3714 | - if ($v_result == 2) { |
|
| 3715 | - // ----- This status is internal and will be changed in 'skipped' |
|
| 3716 | - $p_entry['status'] = "aborted"; |
|
| 3717 | - $v_result = PCLZIP_ERR_USER_ABORTED; |
|
| 3718 | - } |
|
| 3713 | + // ----- Look for abort result |
|
| 3714 | + if ($v_result == 2) { |
|
| 3715 | + // ----- This status is internal and will be changed in 'skipped' |
|
| 3716 | + $p_entry['status'] = "aborted"; |
|
| 3717 | + $v_result = PCLZIP_ERR_USER_ABORTED; |
|
| 3718 | + } |
|
| 3719 | 3719 | |
| 3720 | - // ----- Update the informations |
|
| 3721 | - // Only some fields can be modified |
|
| 3722 | - $p_entry['filename'] = $v_local_header['filename']; |
|
| 3723 | - } |
|
| 3720 | + // ----- Update the informations |
|
| 3721 | + // Only some fields can be modified |
|
| 3722 | + $p_entry['filename'] = $v_local_header['filename']; |
|
| 3723 | + } |
|
| 3724 | 3724 | |
| 3725 | 3725 | |
| 3726 | - // ----- Look if extraction should be done |
|
| 3727 | - if ($p_entry['status'] == 'ok') { |
|
| 3726 | + // ----- Look if extraction should be done |
|
| 3727 | + if ($p_entry['status'] == 'ok') { |
|
| 3728 | 3728 | |
| 3729 | - // ----- Look for specific actions while the file exist |
|
| 3730 | - if (file_exists($p_entry['filename'])) |
|
| 3731 | - { |
|
| 3729 | + // ----- Look for specific actions while the file exist |
|
| 3730 | + if (file_exists($p_entry['filename'])) |
|
| 3731 | + { |
|
| 3732 | 3732 | |
| 3733 | - // ----- Look if file is a directory |
|
| 3734 | - if (is_dir($p_entry['filename'])) |
|
| 3735 | - { |
|
| 3733 | + // ----- Look if file is a directory |
|
| 3734 | + if (is_dir($p_entry['filename'])) |
|
| 3735 | + { |
|
| 3736 | 3736 | |
| 3737 | - // ----- Change the file status |
|
| 3738 | - $p_entry['status'] = "already_a_directory"; |
|
| 3737 | + // ----- Change the file status |
|
| 3738 | + $p_entry['status'] = "already_a_directory"; |
|
| 3739 | 3739 | |
| 3740 | - // ----- Look for PCLZIP_OPT_STOP_ON_ERROR |
|
| 3741 | - // For historical reason first PclZip implementation does not stop |
|
| 3742 | - // when this kind of error occurs. |
|
| 3743 | - if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
|
| 3744 | - && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { |
|
| 3745 | - |
|
| 3746 | - PclZip::privErrorLog(PCLZIP_ERR_ALREADY_A_DIRECTORY, |
|
| 3747 | - "Filename '".$p_entry['filename']."' is " |
|
| 3740 | + // ----- Look for PCLZIP_OPT_STOP_ON_ERROR |
|
| 3741 | + // For historical reason first PclZip implementation does not stop |
|
| 3742 | + // when this kind of error occurs. |
|
| 3743 | + if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
|
| 3744 | + && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { |
|
| 3745 | + |
|
| 3746 | + PclZip::privErrorLog(PCLZIP_ERR_ALREADY_A_DIRECTORY, |
|
| 3747 | + "Filename '".$p_entry['filename']."' is " |
|
| 3748 | 3748 | ."already used by an existing directory"); |
| 3749 | 3749 | |
| 3750 | - return PclZip::errorCode(); |
|
| 3751 | - } |
|
| 3752 | - } |
|
| 3753 | - // ----- Look if file is write protected |
|
| 3754 | - else if (!is_writeable($p_entry['filename'])) |
|
| 3755 | - { |
|
| 3750 | + return PclZip::errorCode(); |
|
| 3751 | + } |
|
| 3752 | + } |
|
| 3753 | + // ----- Look if file is write protected |
|
| 3754 | + else if (!is_writeable($p_entry['filename'])) |
|
| 3755 | + { |
|
| 3756 | 3756 | |
| 3757 | - // ----- Change the file status |
|
| 3758 | - $p_entry['status'] = "write_protected"; |
|
| 3757 | + // ----- Change the file status |
|
| 3758 | + $p_entry['status'] = "write_protected"; |
|
| 3759 | 3759 | |
| 3760 | - // ----- Look for PCLZIP_OPT_STOP_ON_ERROR |
|
| 3761 | - // For historical reason first PclZip implementation does not stop |
|
| 3762 | - // when this kind of error occurs. |
|
| 3763 | - if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
|
| 3764 | - && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { |
|
| 3760 | + // ----- Look for PCLZIP_OPT_STOP_ON_ERROR |
|
| 3761 | + // For historical reason first PclZip implementation does not stop |
|
| 3762 | + // when this kind of error occurs. |
|
| 3763 | + if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
|
| 3764 | + && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { |
|
| 3765 | 3765 | |
| 3766 | - PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, |
|
| 3767 | - "Filename '".$p_entry['filename']."' exists " |
|
| 3766 | + PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, |
|
| 3767 | + "Filename '".$p_entry['filename']."' exists " |
|
| 3768 | 3768 | ."and is write protected"); |
| 3769 | 3769 | |
| 3770 | - return PclZip::errorCode(); |
|
| 3771 | - } |
|
| 3772 | - } |
|
| 3770 | + return PclZip::errorCode(); |
|
| 3771 | + } |
|
| 3772 | + } |
|
| 3773 | 3773 | |
| 3774 | - // ----- Look if the extracted file is older |
|
| 3775 | - else if (filemtime($p_entry['filename']) > $p_entry['mtime']) |
|
| 3776 | - { |
|
| 3777 | - // ----- Change the file status |
|
| 3778 | - if ( (isset($p_options[PCLZIP_OPT_REPLACE_NEWER])) |
|
| 3779 | - && ($p_options[PCLZIP_OPT_REPLACE_NEWER]===true)) { |
|
| 3774 | + // ----- Look if the extracted file is older |
|
| 3775 | + else if (filemtime($p_entry['filename']) > $p_entry['mtime']) |
|
| 3776 | + { |
|
| 3777 | + // ----- Change the file status |
|
| 3778 | + if ( (isset($p_options[PCLZIP_OPT_REPLACE_NEWER])) |
|
| 3779 | + && ($p_options[PCLZIP_OPT_REPLACE_NEWER]===true)) { |
|
| 3780 | 3780 | } |
| 3781 | - else { |
|
| 3782 | - $p_entry['status'] = "newer_exist"; |
|
| 3783 | - |
|
| 3784 | - // ----- Look for PCLZIP_OPT_STOP_ON_ERROR |
|
| 3785 | - // For historical reason first PclZip implementation does not stop |
|
| 3786 | - // when this kind of error occurs. |
|
| 3787 | - if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
|
| 3788 | - && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { |
|
| 3789 | - |
|
| 3790 | - PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, |
|
| 3791 | - "Newer version of '".$p_entry['filename']."' exists " |
|
| 3792 | - ."and option PCLZIP_OPT_REPLACE_NEWER is not selected"); |
|
| 3793 | - |
|
| 3794 | - return PclZip::errorCode(); |
|
| 3795 | - } |
|
| 3796 | - } |
|
| 3797 | - } |
|
| 3798 | - else { |
|
| 3799 | - } |
|
| 3800 | - } |
|
| 3781 | + else { |
|
| 3782 | + $p_entry['status'] = "newer_exist"; |
|
| 3783 | + |
|
| 3784 | + // ----- Look for PCLZIP_OPT_STOP_ON_ERROR |
|
| 3785 | + // For historical reason first PclZip implementation does not stop |
|
| 3786 | + // when this kind of error occurs. |
|
| 3787 | + if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
|
| 3788 | + && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { |
|
| 3789 | + |
|
| 3790 | + PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, |
|
| 3791 | + "Newer version of '".$p_entry['filename']."' exists " |
|
| 3792 | + ."and option PCLZIP_OPT_REPLACE_NEWER is not selected"); |
|
| 3793 | + |
|
| 3794 | + return PclZip::errorCode(); |
|
| 3795 | + } |
|
| 3796 | + } |
|
| 3797 | + } |
|
| 3798 | + else { |
|
| 3799 | + } |
|
| 3800 | + } |
|
| 3801 | 3801 | |
| 3802 | - // ----- Check the directory availability and create it if necessary |
|
| 3803 | - else { |
|
| 3804 | - if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/')) |
|
| 3805 | - $v_dir_to_check = $p_entry['filename']; |
|
| 3806 | - else if (!strstr($p_entry['filename'], "/")) |
|
| 3807 | - $v_dir_to_check = ""; |
|
| 3808 | - else |
|
| 3809 | - $v_dir_to_check = dirname($p_entry['filename']); |
|
| 3810 | - |
|
| 3811 | - if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external']&0x00000010)==0x00000010))) != 1) { |
|
| 3812 | - |
|
| 3813 | - // ----- Change the file status |
|
| 3814 | - $p_entry['status'] = "path_creation_fail"; |
|
| 3802 | + // ----- Check the directory availability and create it if necessary |
|
| 3803 | + else { |
|
| 3804 | + if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/')) |
|
| 3805 | + $v_dir_to_check = $p_entry['filename']; |
|
| 3806 | + else if (!strstr($p_entry['filename'], "/")) |
|
| 3807 | + $v_dir_to_check = ""; |
|
| 3808 | + else |
|
| 3809 | + $v_dir_to_check = dirname($p_entry['filename']); |
|
| 3810 | + |
|
| 3811 | + if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external']&0x00000010)==0x00000010))) != 1) { |
|
| 3815 | 3812 | |
| 3816 | - // ----- Return |
|
| 3817 | - //return $v_result; |
|
| 3818 | - $v_result = 1; |
|
| 3819 | - } |
|
| 3820 | - } |
|
| 3821 | - } |
|
| 3813 | + // ----- Change the file status |
|
| 3814 | + $p_entry['status'] = "path_creation_fail"; |
|
| 3815 | + |
|
| 3816 | + // ----- Return |
|
| 3817 | + //return $v_result; |
|
| 3818 | + $v_result = 1; |
|
| 3819 | + } |
|
| 3820 | + } |
|
| 3821 | + } |
|
| 3822 | 3822 | |
| 3823 | - // ----- Look if extraction should be done |
|
| 3824 | - if ($p_entry['status'] == 'ok') { |
|
| 3823 | + // ----- Look if extraction should be done |
|
| 3824 | + if ($p_entry['status'] == 'ok') { |
|
| 3825 | 3825 | |
| 3826 | - // ----- Do the extraction (if not a folder) |
|
| 3827 | - if (!(($p_entry['external']&0x00000010)==0x00000010)) |
|
| 3828 | - { |
|
| 3829 | - // ----- Look for not compressed file |
|
| 3830 | - if ($p_entry['compression'] == 0) { |
|
| 3826 | + // ----- Do the extraction (if not a folder) |
|
| 3827 | + if (!(($p_entry['external']&0x00000010)==0x00000010)) |
|
| 3828 | + { |
|
| 3829 | + // ----- Look for not compressed file |
|
| 3830 | + if ($p_entry['compression'] == 0) { |
|
| 3831 | 3831 | |
| 3832 | - // ----- Opening destination file |
|
| 3833 | - if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) |
|
| 3834 | - { |
|
| 3832 | + // ----- Opening destination file |
|
| 3833 | + if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) |
|
| 3834 | + { |
|
| 3835 | 3835 | |
| 3836 | - // ----- Change the file status |
|
| 3837 | - $p_entry['status'] = "write_error"; |
|
| 3836 | + // ----- Change the file status |
|
| 3837 | + $p_entry['status'] = "write_error"; |
|
| 3838 | 3838 | |
| 3839 | - // ----- Return |
|
| 3840 | - return $v_result; |
|
| 3841 | - } |
|
| 3839 | + // ----- Return |
|
| 3840 | + return $v_result; |
|
| 3841 | + } |
|
| 3842 | 3842 | |
| 3843 | 3843 | |
| 3844 | - // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks |
|
| 3845 | - $v_size = $p_entry['compressed_size']; |
|
| 3846 | - while ($v_size != 0) |
|
| 3847 | - { |
|
| 3848 | - $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 3849 | - $v_buffer = @fread($this->zip_fd, $v_read_size); |
|
| 3850 | - /* Try to speed up the code |
|
| 3844 | + // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks |
|
| 3845 | + $v_size = $p_entry['compressed_size']; |
|
| 3846 | + while ($v_size != 0) |
|
| 3847 | + { |
|
| 3848 | + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 3849 | + $v_buffer = @fread($this->zip_fd, $v_read_size); |
|
| 3850 | + /* Try to speed up the code |
|
| 3851 | 3851 | $v_binary_data = pack('a'.$v_read_size, $v_buffer); |
| 3852 | 3852 | @fwrite($v_dest_file, $v_binary_data, $v_read_size); |
| 3853 | 3853 | */ |
| 3854 | - @fwrite($v_dest_file, $v_buffer, $v_read_size); |
|
| 3855 | - $v_size -= $v_read_size; |
|
| 3856 | - } |
|
| 3854 | + @fwrite($v_dest_file, $v_buffer, $v_read_size); |
|
| 3855 | + $v_size -= $v_read_size; |
|
| 3856 | + } |
|
| 3857 | 3857 | |
| 3858 | - // ----- Closing the destination file |
|
| 3859 | - fclose($v_dest_file); |
|
| 3858 | + // ----- Closing the destination file |
|
| 3859 | + fclose($v_dest_file); |
|
| 3860 | 3860 | |
| 3861 | - // ----- Change the file mtime |
|
| 3862 | - touch($p_entry['filename'], $p_entry['mtime']); |
|
| 3861 | + // ----- Change the file mtime |
|
| 3862 | + touch($p_entry['filename'], $p_entry['mtime']); |
|
| 3863 | 3863 | |
| 3864 | 3864 | |
| 3865 | - } |
|
| 3866 | - else { |
|
| 3867 | - // ----- TBC |
|
| 3868 | - // Need to be finished |
|
| 3869 | - if (($p_entry['flag'] & 1) == 1) { |
|
| 3870 | - PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION, 'File \''.$p_entry['filename'].'\' is encrypted. Encrypted files are not supported.'); |
|
| 3871 | - return PclZip::errorCode(); |
|
| 3872 | - } |
|
| 3865 | + } |
|
| 3866 | + else { |
|
| 3867 | + // ----- TBC |
|
| 3868 | + // Need to be finished |
|
| 3869 | + if (($p_entry['flag'] & 1) == 1) { |
|
| 3870 | + PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION, 'File \''.$p_entry['filename'].'\' is encrypted. Encrypted files are not supported.'); |
|
| 3871 | + return PclZip::errorCode(); |
|
| 3872 | + } |
|
| 3873 | 3873 | |
| 3874 | 3874 | |
| 3875 | - // ----- Look for using temporary file to unzip |
|
| 3876 | - if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) |
|
| 3877 | - && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON]) |
|
| 3878 | - || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]) |
|
| 3879 | - && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_entry['size'])) ) ) { |
|
| 3880 | - $v_result = $this->privExtractFileUsingTempFile($p_entry, $p_options); |
|
| 3881 | - if ($v_result < PCLZIP_ERR_NO_ERROR) { |
|
| 3882 | - return $v_result; |
|
| 3883 | - } |
|
| 3884 | - } |
|
| 3875 | + // ----- Look for using temporary file to unzip |
|
| 3876 | + if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) |
|
| 3877 | + && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON]) |
|
| 3878 | + || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]) |
|
| 3879 | + && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_entry['size'])) ) ) { |
|
| 3880 | + $v_result = $this->privExtractFileUsingTempFile($p_entry, $p_options); |
|
| 3881 | + if ($v_result < PCLZIP_ERR_NO_ERROR) { |
|
| 3882 | + return $v_result; |
|
| 3883 | + } |
|
| 3884 | + } |
|
| 3885 | 3885 | |
| 3886 | - // ----- Look for extract in memory |
|
| 3887 | - else { |
|
| 3886 | + // ----- Look for extract in memory |
|
| 3887 | + else { |
|
| 3888 | 3888 | |
| 3889 | 3889 | |
| 3890 | - // ----- Read the compressed file in a buffer (one shot) |
|
| 3891 | - $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']); |
|
| 3890 | + // ----- Read the compressed file in a buffer (one shot) |
|
| 3891 | + $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']); |
|
| 3892 | 3892 | |
| 3893 | - // ----- Decompress the file |
|
| 3894 | - $v_file_content = @gzinflate($v_buffer); |
|
| 3895 | - unset($v_buffer); |
|
| 3896 | - if ($v_file_content === FALSE) { |
|
| 3893 | + // ----- Decompress the file |
|
| 3894 | + $v_file_content = @gzinflate($v_buffer); |
|
| 3895 | + unset($v_buffer); |
|
| 3896 | + if ($v_file_content === FALSE) { |
|
| 3897 | 3897 | |
| 3898 | - // ----- Change the file status |
|
| 3899 | - // TBC |
|
| 3900 | - $p_entry['status'] = "error"; |
|
| 3898 | + // ----- Change the file status |
|
| 3899 | + // TBC |
|
| 3900 | + $p_entry['status'] = "error"; |
|
| 3901 | 3901 | |
| 3902 | - return $v_result; |
|
| 3903 | - } |
|
| 3902 | + return $v_result; |
|
| 3903 | + } |
|
| 3904 | 3904 | |
| 3905 | - // ----- Opening destination file |
|
| 3906 | - if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) { |
|
| 3905 | + // ----- Opening destination file |
|
| 3906 | + if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) { |
|
| 3907 | 3907 | |
| 3908 | - // ----- Change the file status |
|
| 3909 | - $p_entry['status'] = "write_error"; |
|
| 3908 | + // ----- Change the file status |
|
| 3909 | + $p_entry['status'] = "write_error"; |
|
| 3910 | 3910 | |
| 3911 | - return $v_result; |
|
| 3912 | - } |
|
| 3911 | + return $v_result; |
|
| 3912 | + } |
|
| 3913 | 3913 | |
| 3914 | - // ----- Write the uncompressed data |
|
| 3915 | - @fwrite($v_dest_file, $v_file_content, $p_entry['size']); |
|
| 3916 | - unset($v_file_content); |
|
| 3914 | + // ----- Write the uncompressed data |
|
| 3915 | + @fwrite($v_dest_file, $v_file_content, $p_entry['size']); |
|
| 3916 | + unset($v_file_content); |
|
| 3917 | 3917 | |
| 3918 | - // ----- Closing the destination file |
|
| 3919 | - @fclose($v_dest_file); |
|
| 3918 | + // ----- Closing the destination file |
|
| 3919 | + @fclose($v_dest_file); |
|
| 3920 | 3920 | |
| 3921 | - } |
|
| 3921 | + } |
|
| 3922 | 3922 | |
| 3923 | - // ----- Change the file mtime |
|
| 3924 | - @touch($p_entry['filename'], $p_entry['mtime']); |
|
| 3925 | - } |
|
| 3923 | + // ----- Change the file mtime |
|
| 3924 | + @touch($p_entry['filename'], $p_entry['mtime']); |
|
| 3925 | + } |
|
| 3926 | 3926 | |
| 3927 | - // ----- Look for chmod option |
|
| 3928 | - if (isset($p_options[PCLZIP_OPT_SET_CHMOD])) { |
|
| 3927 | + // ----- Look for chmod option |
|
| 3928 | + if (isset($p_options[PCLZIP_OPT_SET_CHMOD])) { |
|
| 3929 | 3929 | |
| 3930 | - // ----- Change the mode of the file |
|
| 3931 | - @chmod($p_entry['filename'], $p_options[PCLZIP_OPT_SET_CHMOD]); |
|
| 3932 | - } |
|
| 3930 | + // ----- Change the mode of the file |
|
| 3931 | + @chmod($p_entry['filename'], $p_options[PCLZIP_OPT_SET_CHMOD]); |
|
| 3932 | + } |
|
| 3933 | 3933 | |
| 3934 | - } |
|
| 3935 | - } |
|
| 3934 | + } |
|
| 3935 | + } |
|
| 3936 | 3936 | |
| 3937 | 3937 | // ----- Change abort status |
| 3938 | 3938 | if ($p_entry['status'] == "aborted") { |
| 3939 | - $p_entry['status'] = "skipped"; |
|
| 3939 | + $p_entry['status'] = "skipped"; |
|
| 3940 | 3940 | } |
| 3941 | 3941 | |
| 3942 | - // ----- Look for post-extract callback |
|
| 3943 | - elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) { |
|
| 3942 | + // ----- Look for post-extract callback |
|
| 3943 | + elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) { |
|
| 3944 | 3944 | |
| 3945 | - // ----- Generate a local information |
|
| 3946 | - $v_local_header = array(); |
|
| 3947 | - $this->privConvertHeader2FileInfo($p_entry, $v_local_header); |
|
| 3945 | + // ----- Generate a local information |
|
| 3946 | + $v_local_header = array(); |
|
| 3947 | + $this->privConvertHeader2FileInfo($p_entry, $v_local_header); |
|
| 3948 | 3948 | |
| 3949 | - // ----- Call the callback |
|
| 3950 | - // Here I do not use call_user_func() because I need to send a reference to the |
|
| 3951 | - // header. |
|
| 3949 | + // ----- Call the callback |
|
| 3950 | + // Here I do not use call_user_func() because I need to send a reference to the |
|
| 3951 | + // header. |
|
| 3952 | 3952 | // eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);'); |
| 3953 | - $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header); |
|
| 3953 | + $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header); |
|
| 3954 | 3954 | |
| 3955 | - // ----- Look for abort result |
|
| 3956 | - if ($v_result == 2) { |
|
| 3957 | - $v_result = PCLZIP_ERR_USER_ABORTED; |
|
| 3958 | - } |
|
| 3959 | - } |
|
| 3955 | + // ----- Look for abort result |
|
| 3956 | + if ($v_result == 2) { |
|
| 3957 | + $v_result = PCLZIP_ERR_USER_ABORTED; |
|
| 3958 | + } |
|
| 3959 | + } |
|
| 3960 | 3960 | |
| 3961 | - // ----- Return |
|
| 3962 | - return $v_result; |
|
| 3961 | + // ----- Return |
|
| 3962 | + return $v_result; |
|
| 3963 | 3963 | } |
| 3964 | 3964 | // -------------------------------------------------------------------------------- |
| 3965 | 3965 | |
@@ -3971,71 +3971,71 @@ discard block |
||
| 3971 | 3971 | // -------------------------------------------------------------------------------- |
| 3972 | 3972 | function privExtractFileUsingTempFile(&$p_entry, &$p_options) |
| 3973 | 3973 | { |
| 3974 | - $v_result=1; |
|
| 3974 | + $v_result=1; |
|
| 3975 | 3975 | |
| 3976 | - // ----- Creates a temporary file |
|
| 3977 | - $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz'; |
|
| 3978 | - if (($v_dest_file = @fopen($v_gzip_temp_name, "wb")) == 0) { |
|
| 3979 | - fclose($v_file); |
|
| 3980 | - PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode'); |
|
| 3981 | - return PclZip::errorCode(); |
|
| 3982 | - } |
|
| 3976 | + // ----- Creates a temporary file |
|
| 3977 | + $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz'; |
|
| 3978 | + if (($v_dest_file = @fopen($v_gzip_temp_name, "wb")) == 0) { |
|
| 3979 | + fclose($v_file); |
|
| 3980 | + PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode'); |
|
| 3981 | + return PclZip::errorCode(); |
|
| 3982 | + } |
|
| 3983 | 3983 | |
| 3984 | 3984 | |
| 3985 | - // ----- Write gz file format header |
|
| 3986 | - $v_binary_data = pack('va1a1Va1a1', 0x8b1f, Chr($p_entry['compression']), Chr(0x00), time(), Chr(0x00), Chr(3)); |
|
| 3987 | - @fwrite($v_dest_file, $v_binary_data, 10); |
|
| 3985 | + // ----- Write gz file format header |
|
| 3986 | + $v_binary_data = pack('va1a1Va1a1', 0x8b1f, Chr($p_entry['compression']), Chr(0x00), time(), Chr(0x00), Chr(3)); |
|
| 3987 | + @fwrite($v_dest_file, $v_binary_data, 10); |
|
| 3988 | 3988 | |
| 3989 | - // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks |
|
| 3990 | - $v_size = $p_entry['compressed_size']; |
|
| 3991 | - while ($v_size != 0) |
|
| 3992 | - { |
|
| 3993 | - $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 3994 | - $v_buffer = @fread($this->zip_fd, $v_read_size); |
|
| 3995 | - //$v_binary_data = pack('a'.$v_read_size, $v_buffer); |
|
| 3996 | - @fwrite($v_dest_file, $v_buffer, $v_read_size); |
|
| 3997 | - $v_size -= $v_read_size; |
|
| 3998 | - } |
|
| 3989 | + // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks |
|
| 3990 | + $v_size = $p_entry['compressed_size']; |
|
| 3991 | + while ($v_size != 0) |
|
| 3992 | + { |
|
| 3993 | + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 3994 | + $v_buffer = @fread($this->zip_fd, $v_read_size); |
|
| 3995 | + //$v_binary_data = pack('a'.$v_read_size, $v_buffer); |
|
| 3996 | + @fwrite($v_dest_file, $v_buffer, $v_read_size); |
|
| 3997 | + $v_size -= $v_read_size; |
|
| 3998 | + } |
|
| 3999 | 3999 | |
| 4000 | - // ----- Write gz file format footer |
|
| 4001 | - $v_binary_data = pack('VV', $p_entry['crc'], $p_entry['size']); |
|
| 4002 | - @fwrite($v_dest_file, $v_binary_data, 8); |
|
| 4000 | + // ----- Write gz file format footer |
|
| 4001 | + $v_binary_data = pack('VV', $p_entry['crc'], $p_entry['size']); |
|
| 4002 | + @fwrite($v_dest_file, $v_binary_data, 8); |
|
| 4003 | 4003 | |
| 4004 | - // ----- Close the temporary file |
|
| 4005 | - @fclose($v_dest_file); |
|
| 4004 | + // ----- Close the temporary file |
|
| 4005 | + @fclose($v_dest_file); |
|
| 4006 | 4006 | |
| 4007 | - // ----- Opening destination file |
|
| 4008 | - if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) { |
|
| 4009 | - $p_entry['status'] = "write_error"; |
|
| 4010 | - return $v_result; |
|
| 4011 | - } |
|
| 4007 | + // ----- Opening destination file |
|
| 4008 | + if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) { |
|
| 4009 | + $p_entry['status'] = "write_error"; |
|
| 4010 | + return $v_result; |
|
| 4011 | + } |
|
| 4012 | 4012 | |
| 4013 | - // ----- Open the temporary gz file |
|
| 4014 | - if (($v_src_file = @gzopen($v_gzip_temp_name, 'rb')) == 0) { |
|
| 4015 | - @fclose($v_dest_file); |
|
| 4016 | - $p_entry['status'] = "read_error"; |
|
| 4017 | - PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode'); |
|
| 4018 | - return PclZip::errorCode(); |
|
| 4019 | - } |
|
| 4013 | + // ----- Open the temporary gz file |
|
| 4014 | + if (($v_src_file = @gzopen($v_gzip_temp_name, 'rb')) == 0) { |
|
| 4015 | + @fclose($v_dest_file); |
|
| 4016 | + $p_entry['status'] = "read_error"; |
|
| 4017 | + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode'); |
|
| 4018 | + return PclZip::errorCode(); |
|
| 4019 | + } |
|
| 4020 | 4020 | |
| 4021 | 4021 | |
| 4022 | - // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks |
|
| 4023 | - $v_size = $p_entry['size']; |
|
| 4024 | - while ($v_size != 0) { |
|
| 4025 | - $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 4026 | - $v_buffer = @gzread($v_src_file, $v_read_size); |
|
| 4027 | - //$v_binary_data = pack('a'.$v_read_size, $v_buffer); |
|
| 4028 | - @fwrite($v_dest_file, $v_buffer, $v_read_size); |
|
| 4029 | - $v_size -= $v_read_size; |
|
| 4030 | - } |
|
| 4031 | - @fclose($v_dest_file); |
|
| 4032 | - @gzclose($v_src_file); |
|
| 4022 | + // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks |
|
| 4023 | + $v_size = $p_entry['size']; |
|
| 4024 | + while ($v_size != 0) { |
|
| 4025 | + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 4026 | + $v_buffer = @gzread($v_src_file, $v_read_size); |
|
| 4027 | + //$v_binary_data = pack('a'.$v_read_size, $v_buffer); |
|
| 4028 | + @fwrite($v_dest_file, $v_buffer, $v_read_size); |
|
| 4029 | + $v_size -= $v_read_size; |
|
| 4030 | + } |
|
| 4031 | + @fclose($v_dest_file); |
|
| 4032 | + @gzclose($v_src_file); |
|
| 4033 | 4033 | |
| 4034 | - // ----- Delete the temporary file |
|
| 4035 | - @unlink($v_gzip_temp_name); |
|
| 4034 | + // ----- Delete the temporary file |
|
| 4035 | + @unlink($v_gzip_temp_name); |
|
| 4036 | 4036 | |
| 4037 | - // ----- Return |
|
| 4038 | - return $v_result; |
|
| 4037 | + // ----- Return |
|
| 4038 | + return $v_result; |
|
| 4039 | 4039 | } |
| 4040 | 4040 | // -------------------------------------------------------------------------------- |
| 4041 | 4041 | |
@@ -4047,107 +4047,107 @@ discard block |
||
| 4047 | 4047 | // -------------------------------------------------------------------------------- |
| 4048 | 4048 | function privExtractFileInOutput(&$p_entry, &$p_options) |
| 4049 | 4049 | { |
| 4050 | - $v_result=1; |
|
| 4050 | + $v_result=1; |
|
| 4051 | 4051 | |
| 4052 | - // ----- Read the file header |
|
| 4053 | - if (($v_result = $this->privReadFileHeader($v_header)) != 1) { |
|
| 4054 | - return $v_result; |
|
| 4055 | - } |
|
| 4052 | + // ----- Read the file header |
|
| 4053 | + if (($v_result = $this->privReadFileHeader($v_header)) != 1) { |
|
| 4054 | + return $v_result; |
|
| 4055 | + } |
|
| 4056 | 4056 | |
| 4057 | 4057 | |
| 4058 | - // ----- Check that the file header is coherent with $p_entry info |
|
| 4059 | - if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) { |
|
| 4060 | - // TBC |
|
| 4061 | - } |
|
| 4058 | + // ----- Check that the file header is coherent with $p_entry info |
|
| 4059 | + if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) { |
|
| 4060 | + // TBC |
|
| 4061 | + } |
|
| 4062 | 4062 | |
| 4063 | - // ----- Look for pre-extract callback |
|
| 4064 | - if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) { |
|
| 4063 | + // ----- Look for pre-extract callback |
|
| 4064 | + if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) { |
|
| 4065 | 4065 | |
| 4066 | - // ----- Generate a local information |
|
| 4067 | - $v_local_header = array(); |
|
| 4068 | - $this->privConvertHeader2FileInfo($p_entry, $v_local_header); |
|
| 4066 | + // ----- Generate a local information |
|
| 4067 | + $v_local_header = array(); |
|
| 4068 | + $this->privConvertHeader2FileInfo($p_entry, $v_local_header); |
|
| 4069 | 4069 | |
| 4070 | - // ----- Call the callback |
|
| 4071 | - // Here I do not use call_user_func() because I need to send a reference to the |
|
| 4072 | - // header. |
|
| 4070 | + // ----- Call the callback |
|
| 4071 | + // Here I do not use call_user_func() because I need to send a reference to the |
|
| 4072 | + // header. |
|
| 4073 | 4073 | // eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);'); |
| 4074 | - $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header); |
|
| 4075 | - if ($v_result == 0) { |
|
| 4076 | - // ----- Change the file status |
|
| 4077 | - $p_entry['status'] = "skipped"; |
|
| 4078 | - $v_result = 1; |
|
| 4079 | - } |
|
| 4074 | + $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header); |
|
| 4075 | + if ($v_result == 0) { |
|
| 4076 | + // ----- Change the file status |
|
| 4077 | + $p_entry['status'] = "skipped"; |
|
| 4078 | + $v_result = 1; |
|
| 4079 | + } |
|
| 4080 | 4080 | |
| 4081 | - // ----- Look for abort result |
|
| 4082 | - if ($v_result == 2) { |
|
| 4083 | - // ----- This status is internal and will be changed in 'skipped' |
|
| 4084 | - $p_entry['status'] = "aborted"; |
|
| 4085 | - $v_result = PCLZIP_ERR_USER_ABORTED; |
|
| 4086 | - } |
|
| 4081 | + // ----- Look for abort result |
|
| 4082 | + if ($v_result == 2) { |
|
| 4083 | + // ----- This status is internal and will be changed in 'skipped' |
|
| 4084 | + $p_entry['status'] = "aborted"; |
|
| 4085 | + $v_result = PCLZIP_ERR_USER_ABORTED; |
|
| 4086 | + } |
|
| 4087 | 4087 | |
| 4088 | - // ----- Update the informations |
|
| 4089 | - // Only some fields can be modified |
|
| 4090 | - $p_entry['filename'] = $v_local_header['filename']; |
|
| 4091 | - } |
|
| 4088 | + // ----- Update the informations |
|
| 4089 | + // Only some fields can be modified |
|
| 4090 | + $p_entry['filename'] = $v_local_header['filename']; |
|
| 4091 | + } |
|
| 4092 | 4092 | |
| 4093 | - // ----- Trace |
|
| 4093 | + // ----- Trace |
|
| 4094 | 4094 | |
| 4095 | - // ----- Look if extraction should be done |
|
| 4096 | - if ($p_entry['status'] == 'ok') { |
|
| 4095 | + // ----- Look if extraction should be done |
|
| 4096 | + if ($p_entry['status'] == 'ok') { |
|
| 4097 | 4097 | |
| 4098 | - // ----- Do the extraction (if not a folder) |
|
| 4099 | - if (!(($p_entry['external']&0x00000010)==0x00000010)) { |
|
| 4100 | - // ----- Look for not compressed file |
|
| 4101 | - if ($p_entry['compressed_size'] == $p_entry['size']) { |
|
| 4098 | + // ----- Do the extraction (if not a folder) |
|
| 4099 | + if (!(($p_entry['external']&0x00000010)==0x00000010)) { |
|
| 4100 | + // ----- Look for not compressed file |
|
| 4101 | + if ($p_entry['compressed_size'] == $p_entry['size']) { |
|
| 4102 | 4102 | |
| 4103 | - // ----- Read the file in a buffer (one shot) |
|
| 4104 | - $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']); |
|
| 4103 | + // ----- Read the file in a buffer (one shot) |
|
| 4104 | + $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']); |
|
| 4105 | 4105 | |
| 4106 | - // ----- Send the file to the output |
|
| 4107 | - echo $v_buffer; |
|
| 4108 | - unset($v_buffer); |
|
| 4109 | - } |
|
| 4110 | - else { |
|
| 4106 | + // ----- Send the file to the output |
|
| 4107 | + echo $v_buffer; |
|
| 4108 | + unset($v_buffer); |
|
| 4109 | + } |
|
| 4110 | + else { |
|
| 4111 | 4111 | |
| 4112 | - // ----- Read the compressed file in a buffer (one shot) |
|
| 4113 | - $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']); |
|
| 4112 | + // ----- Read the compressed file in a buffer (one shot) |
|
| 4113 | + $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']); |
|
| 4114 | 4114 | |
| 4115 | - // ----- Decompress the file |
|
| 4116 | - $v_file_content = gzinflate($v_buffer); |
|
| 4117 | - unset($v_buffer); |
|
| 4118 | - |
|
| 4119 | - // ----- Send the file to the output |
|
| 4120 | - echo $v_file_content; |
|
| 4121 | - unset($v_file_content); |
|
| 4122 | - } |
|
| 4123 | - } |
|
| 4124 | - } |
|
| 4115 | + // ----- Decompress the file |
|
| 4116 | + $v_file_content = gzinflate($v_buffer); |
|
| 4117 | + unset($v_buffer); |
|
| 4118 | + |
|
| 4119 | + // ----- Send the file to the output |
|
| 4120 | + echo $v_file_content; |
|
| 4121 | + unset($v_file_content); |
|
| 4122 | + } |
|
| 4123 | + } |
|
| 4124 | + } |
|
| 4125 | 4125 | |
| 4126 | 4126 | // ----- Change abort status |
| 4127 | 4127 | if ($p_entry['status'] == "aborted") { |
| 4128 | - $p_entry['status'] = "skipped"; |
|
| 4128 | + $p_entry['status'] = "skipped"; |
|
| 4129 | 4129 | } |
| 4130 | 4130 | |
| 4131 | - // ----- Look for post-extract callback |
|
| 4132 | - elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) { |
|
| 4131 | + // ----- Look for post-extract callback |
|
| 4132 | + elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) { |
|
| 4133 | 4133 | |
| 4134 | - // ----- Generate a local information |
|
| 4135 | - $v_local_header = array(); |
|
| 4136 | - $this->privConvertHeader2FileInfo($p_entry, $v_local_header); |
|
| 4134 | + // ----- Generate a local information |
|
| 4135 | + $v_local_header = array(); |
|
| 4136 | + $this->privConvertHeader2FileInfo($p_entry, $v_local_header); |
|
| 4137 | 4137 | |
| 4138 | - // ----- Call the callback |
|
| 4139 | - // Here I do not use call_user_func() because I need to send a reference to the |
|
| 4140 | - // header. |
|
| 4138 | + // ----- Call the callback |
|
| 4139 | + // Here I do not use call_user_func() because I need to send a reference to the |
|
| 4140 | + // header. |
|
| 4141 | 4141 | // eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);'); |
| 4142 | - $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header); |
|
| 4142 | + $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header); |
|
| 4143 | 4143 | |
| 4144 | - // ----- Look for abort result |
|
| 4145 | - if ($v_result == 2) { |
|
| 4146 | - $v_result = PCLZIP_ERR_USER_ABORTED; |
|
| 4147 | - } |
|
| 4148 | - } |
|
| 4144 | + // ----- Look for abort result |
|
| 4145 | + if ($v_result == 2) { |
|
| 4146 | + $v_result = PCLZIP_ERR_USER_ABORTED; |
|
| 4147 | + } |
|
| 4148 | + } |
|
| 4149 | 4149 | |
| 4150 | - return $v_result; |
|
| 4150 | + return $v_result; |
|
| 4151 | 4151 | } |
| 4152 | 4152 | // -------------------------------------------------------------------------------- |
| 4153 | 4153 | |
@@ -4159,118 +4159,118 @@ discard block |
||
| 4159 | 4159 | // -------------------------------------------------------------------------------- |
| 4160 | 4160 | function privExtractFileAsString(&$p_entry, &$p_string, &$p_options) |
| 4161 | 4161 | { |
| 4162 | - $v_result=1; |
|
| 4163 | - |
|
| 4164 | - // ----- Read the file header |
|
| 4165 | - $v_header = array(); |
|
| 4166 | - if (($v_result = $this->privReadFileHeader($v_header)) != 1) |
|
| 4167 | - { |
|
| 4168 | - // ----- Return |
|
| 4169 | - return $v_result; |
|
| 4170 | - } |
|
| 4162 | + $v_result=1; |
|
| 4163 | + |
|
| 4164 | + // ----- Read the file header |
|
| 4165 | + $v_header = array(); |
|
| 4166 | + if (($v_result = $this->privReadFileHeader($v_header)) != 1) |
|
| 4167 | + { |
|
| 4168 | + // ----- Return |
|
| 4169 | + return $v_result; |
|
| 4170 | + } |
|
| 4171 | 4171 | |
| 4172 | 4172 | |
| 4173 | - // ----- Check that the file header is coherent with $p_entry info |
|
| 4174 | - if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) { |
|
| 4175 | - // TBC |
|
| 4176 | - } |
|
| 4173 | + // ----- Check that the file header is coherent with $p_entry info |
|
| 4174 | + if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) { |
|
| 4175 | + // TBC |
|
| 4176 | + } |
|
| 4177 | 4177 | |
| 4178 | - // ----- Look for pre-extract callback |
|
| 4179 | - if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) { |
|
| 4178 | + // ----- Look for pre-extract callback |
|
| 4179 | + if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) { |
|
| 4180 | 4180 | |
| 4181 | - // ----- Generate a local information |
|
| 4182 | - $v_local_header = array(); |
|
| 4183 | - $this->privConvertHeader2FileInfo($p_entry, $v_local_header); |
|
| 4181 | + // ----- Generate a local information |
|
| 4182 | + $v_local_header = array(); |
|
| 4183 | + $this->privConvertHeader2FileInfo($p_entry, $v_local_header); |
|
| 4184 | 4184 | |
| 4185 | - // ----- Call the callback |
|
| 4186 | - // Here I do not use call_user_func() because I need to send a reference to the |
|
| 4187 | - // header. |
|
| 4185 | + // ----- Call the callback |
|
| 4186 | + // Here I do not use call_user_func() because I need to send a reference to the |
|
| 4187 | + // header. |
|
| 4188 | 4188 | // eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);'); |
| 4189 | - $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header); |
|
| 4190 | - if ($v_result == 0) { |
|
| 4191 | - // ----- Change the file status |
|
| 4192 | - $p_entry['status'] = "skipped"; |
|
| 4193 | - $v_result = 1; |
|
| 4194 | - } |
|
| 4189 | + $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header); |
|
| 4190 | + if ($v_result == 0) { |
|
| 4191 | + // ----- Change the file status |
|
| 4192 | + $p_entry['status'] = "skipped"; |
|
| 4193 | + $v_result = 1; |
|
| 4194 | + } |
|
| 4195 | 4195 | |
| 4196 | - // ----- Look for abort result |
|
| 4197 | - if ($v_result == 2) { |
|
| 4198 | - // ----- This status is internal and will be changed in 'skipped' |
|
| 4199 | - $p_entry['status'] = "aborted"; |
|
| 4200 | - $v_result = PCLZIP_ERR_USER_ABORTED; |
|
| 4201 | - } |
|
| 4196 | + // ----- Look for abort result |
|
| 4197 | + if ($v_result == 2) { |
|
| 4198 | + // ----- This status is internal and will be changed in 'skipped' |
|
| 4199 | + $p_entry['status'] = "aborted"; |
|
| 4200 | + $v_result = PCLZIP_ERR_USER_ABORTED; |
|
| 4201 | + } |
|
| 4202 | 4202 | |
| 4203 | - // ----- Update the informations |
|
| 4204 | - // Only some fields can be modified |
|
| 4205 | - $p_entry['filename'] = $v_local_header['filename']; |
|
| 4206 | - } |
|
| 4203 | + // ----- Update the informations |
|
| 4204 | + // Only some fields can be modified |
|
| 4205 | + $p_entry['filename'] = $v_local_header['filename']; |
|
| 4206 | + } |
|
| 4207 | 4207 | |
| 4208 | 4208 | |
| 4209 | - // ----- Look if extraction should be done |
|
| 4210 | - if ($p_entry['status'] == 'ok') { |
|
| 4209 | + // ----- Look if extraction should be done |
|
| 4210 | + if ($p_entry['status'] == 'ok') { |
|
| 4211 | 4211 | |
| 4212 | - // ----- Do the extraction (if not a folder) |
|
| 4213 | - if (!(($p_entry['external']&0x00000010)==0x00000010)) { |
|
| 4214 | - // ----- Look for not compressed file |
|
| 4212 | + // ----- Do the extraction (if not a folder) |
|
| 4213 | + if (!(($p_entry['external']&0x00000010)==0x00000010)) { |
|
| 4214 | + // ----- Look for not compressed file |
|
| 4215 | 4215 | // if ($p_entry['compressed_size'] == $p_entry['size']) |
| 4216 | - if ($p_entry['compression'] == 0) { |
|
| 4216 | + if ($p_entry['compression'] == 0) { |
|
| 4217 | 4217 | |
| 4218 | - // ----- Reading the file |
|
| 4219 | - $p_string = @fread($this->zip_fd, $p_entry['compressed_size']); |
|
| 4220 | - } |
|
| 4221 | - else { |
|
| 4218 | + // ----- Reading the file |
|
| 4219 | + $p_string = @fread($this->zip_fd, $p_entry['compressed_size']); |
|
| 4220 | + } |
|
| 4221 | + else { |
|
| 4222 | 4222 | |
| 4223 | - // ----- Reading the file |
|
| 4224 | - $v_data = @fread($this->zip_fd, $p_entry['compressed_size']); |
|
| 4223 | + // ----- Reading the file |
|
| 4224 | + $v_data = @fread($this->zip_fd, $p_entry['compressed_size']); |
|
| 4225 | 4225 | |
| 4226 | - // ----- Decompress the file |
|
| 4227 | - if (($p_string = @gzinflate($v_data)) === FALSE) { |
|
| 4228 | - // TBC |
|
| 4229 | - } |
|
| 4230 | - } |
|
| 4226 | + // ----- Decompress the file |
|
| 4227 | + if (($p_string = @gzinflate($v_data)) === FALSE) { |
|
| 4228 | + // TBC |
|
| 4229 | + } |
|
| 4230 | + } |
|
| 4231 | 4231 | |
| 4232 | - // ----- Trace |
|
| 4233 | - } |
|
| 4234 | - else { |
|
| 4235 | - // TBC : error : can not extract a folder in a string |
|
| 4236 | - } |
|
| 4232 | + // ----- Trace |
|
| 4233 | + } |
|
| 4234 | + else { |
|
| 4235 | + // TBC : error : can not extract a folder in a string |
|
| 4236 | + } |
|
| 4237 | 4237 | |
| 4238 | - } |
|
| 4238 | + } |
|
| 4239 | 4239 | |
| 4240 | 4240 | // ----- Change abort status |
| 4241 | 4241 | if ($p_entry['status'] == "aborted") { |
| 4242 | - $p_entry['status'] = "skipped"; |
|
| 4242 | + $p_entry['status'] = "skipped"; |
|
| 4243 | 4243 | } |
| 4244 | 4244 | |
| 4245 | - // ----- Look for post-extract callback |
|
| 4246 | - elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) { |
|
| 4245 | + // ----- Look for post-extract callback |
|
| 4246 | + elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) { |
|
| 4247 | 4247 | |
| 4248 | - // ----- Generate a local information |
|
| 4249 | - $v_local_header = array(); |
|
| 4250 | - $this->privConvertHeader2FileInfo($p_entry, $v_local_header); |
|
| 4248 | + // ----- Generate a local information |
|
| 4249 | + $v_local_header = array(); |
|
| 4250 | + $this->privConvertHeader2FileInfo($p_entry, $v_local_header); |
|
| 4251 | 4251 | |
| 4252 | - // ----- Swap the content to header |
|
| 4253 | - $v_local_header['content'] = $p_string; |
|
| 4254 | - $p_string = ''; |
|
| 4252 | + // ----- Swap the content to header |
|
| 4253 | + $v_local_header['content'] = $p_string; |
|
| 4254 | + $p_string = ''; |
|
| 4255 | 4255 | |
| 4256 | - // ----- Call the callback |
|
| 4257 | - // Here I do not use call_user_func() because I need to send a reference to the |
|
| 4258 | - // header. |
|
| 4256 | + // ----- Call the callback |
|
| 4257 | + // Here I do not use call_user_func() because I need to send a reference to the |
|
| 4258 | + // header. |
|
| 4259 | 4259 | // eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);'); |
| 4260 | - $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header); |
|
| 4260 | + $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header); |
|
| 4261 | 4261 | |
| 4262 | - // ----- Swap back the content to header |
|
| 4263 | - $p_string = $v_local_header['content']; |
|
| 4264 | - unset($v_local_header['content']); |
|
| 4262 | + // ----- Swap back the content to header |
|
| 4263 | + $p_string = $v_local_header['content']; |
|
| 4264 | + unset($v_local_header['content']); |
|
| 4265 | 4265 | |
| 4266 | - // ----- Look for abort result |
|
| 4267 | - if ($v_result == 2) { |
|
| 4268 | - $v_result = PCLZIP_ERR_USER_ABORTED; |
|
| 4269 | - } |
|
| 4270 | - } |
|
| 4266 | + // ----- Look for abort result |
|
| 4267 | + if ($v_result == 2) { |
|
| 4268 | + $v_result = PCLZIP_ERR_USER_ABORTED; |
|
| 4269 | + } |
|
| 4270 | + } |
|
| 4271 | 4271 | |
| 4272 | - // ----- Return |
|
| 4273 | - return $v_result; |
|
| 4272 | + // ----- Return |
|
| 4273 | + return $v_result; |
|
| 4274 | 4274 | } |
| 4275 | 4275 | // -------------------------------------------------------------------------------- |
| 4276 | 4276 | |
@@ -4282,98 +4282,98 @@ discard block |
||
| 4282 | 4282 | // -------------------------------------------------------------------------------- |
| 4283 | 4283 | function privReadFileHeader(&$p_header) |
| 4284 | 4284 | { |
| 4285 | - $v_result=1; |
|
| 4285 | + $v_result=1; |
|
| 4286 | 4286 | |
| 4287 | - // ----- Read the 4 bytes signature |
|
| 4288 | - $v_binary_data = @fread($this->zip_fd, 4); |
|
| 4289 | - $v_data = unpack('Vid', $v_binary_data); |
|
| 4287 | + // ----- Read the 4 bytes signature |
|
| 4288 | + $v_binary_data = @fread($this->zip_fd, 4); |
|
| 4289 | + $v_data = unpack('Vid', $v_binary_data); |
|
| 4290 | 4290 | |
| 4291 | - // ----- Check signature |
|
| 4292 | - if ($v_data['id'] != 0x04034b50) |
|
| 4293 | - { |
|
| 4291 | + // ----- Check signature |
|
| 4292 | + if ($v_data['id'] != 0x04034b50) |
|
| 4293 | + { |
|
| 4294 | 4294 | |
| 4295 | - // ----- Error log |
|
| 4296 | - PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure'); |
|
| 4295 | + // ----- Error log |
|
| 4296 | + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure'); |
|
| 4297 | 4297 | |
| 4298 | - // ----- Return |
|
| 4299 | - return PclZip::errorCode(); |
|
| 4300 | - } |
|
| 4298 | + // ----- Return |
|
| 4299 | + return PclZip::errorCode(); |
|
| 4300 | + } |
|
| 4301 | 4301 | |
| 4302 | - // ----- Read the first 42 bytes of the header |
|
| 4303 | - $v_binary_data = fread($this->zip_fd, 26); |
|
| 4302 | + // ----- Read the first 42 bytes of the header |
|
| 4303 | + $v_binary_data = fread($this->zip_fd, 26); |
|
| 4304 | 4304 | |
| 4305 | - // ----- Look for invalid block size |
|
| 4306 | - if (strlen($v_binary_data) != 26) |
|
| 4307 | - { |
|
| 4308 | - $p_header['filename'] = ""; |
|
| 4309 | - $p_header['status'] = "invalid_header"; |
|
| 4305 | + // ----- Look for invalid block size |
|
| 4306 | + if (strlen($v_binary_data) != 26) |
|
| 4307 | + { |
|
| 4308 | + $p_header['filename'] = ""; |
|
| 4309 | + $p_header['status'] = "invalid_header"; |
|
| 4310 | 4310 | |
| 4311 | - // ----- Error log |
|
| 4312 | - PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data)); |
|
| 4311 | + // ----- Error log |
|
| 4312 | + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data)); |
|
| 4313 | 4313 | |
| 4314 | - // ----- Return |
|
| 4315 | - return PclZip::errorCode(); |
|
| 4316 | - } |
|
| 4314 | + // ----- Return |
|
| 4315 | + return PclZip::errorCode(); |
|
| 4316 | + } |
|
| 4317 | 4317 | |
| 4318 | - // ----- Extract the values |
|
| 4319 | - $v_data = unpack('vversion/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len', $v_binary_data); |
|
| 4318 | + // ----- Extract the values |
|
| 4319 | + $v_data = unpack('vversion/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len', $v_binary_data); |
|
| 4320 | 4320 | |
| 4321 | - // ----- Get filename |
|
| 4322 | - $p_header['filename'] = fread($this->zip_fd, $v_data['filename_len']); |
|
| 4321 | + // ----- Get filename |
|
| 4322 | + $p_header['filename'] = fread($this->zip_fd, $v_data['filename_len']); |
|
| 4323 | 4323 | |
| 4324 | - // ----- Get extra_fields |
|
| 4325 | - if ($v_data['extra_len'] != 0) { |
|
| 4326 | - $p_header['extra'] = fread($this->zip_fd, $v_data['extra_len']); |
|
| 4327 | - } |
|
| 4328 | - else { |
|
| 4329 | - $p_header['extra'] = ''; |
|
| 4330 | - } |
|
| 4324 | + // ----- Get extra_fields |
|
| 4325 | + if ($v_data['extra_len'] != 0) { |
|
| 4326 | + $p_header['extra'] = fread($this->zip_fd, $v_data['extra_len']); |
|
| 4327 | + } |
|
| 4328 | + else { |
|
| 4329 | + $p_header['extra'] = ''; |
|
| 4330 | + } |
|
| 4331 | 4331 | |
| 4332 | - // ----- Extract properties |
|
| 4333 | - $p_header['version_extracted'] = $v_data['version']; |
|
| 4334 | - $p_header['compression'] = $v_data['compression']; |
|
| 4335 | - $p_header['size'] = $v_data['size']; |
|
| 4336 | - $p_header['compressed_size'] = $v_data['compressed_size']; |
|
| 4337 | - $p_header['crc'] = $v_data['crc']; |
|
| 4338 | - $p_header['flag'] = $v_data['flag']; |
|
| 4339 | - $p_header['filename_len'] = $v_data['filename_len']; |
|
| 4340 | - |
|
| 4341 | - // ----- Recuperate date in UNIX format |
|
| 4342 | - $p_header['mdate'] = $v_data['mdate']; |
|
| 4343 | - $p_header['mtime'] = $v_data['mtime']; |
|
| 4344 | - if ($p_header['mdate'] && $p_header['mtime']) |
|
| 4345 | - { |
|
| 4346 | - // ----- Extract time |
|
| 4347 | - $v_hour = ($p_header['mtime'] & 0xF800) >> 11; |
|
| 4348 | - $v_minute = ($p_header['mtime'] & 0x07E0) >> 5; |
|
| 4349 | - $v_seconde = ($p_header['mtime'] & 0x001F)*2; |
|
| 4350 | - |
|
| 4351 | - // ----- Extract date |
|
| 4352 | - $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980; |
|
| 4353 | - $v_month = ($p_header['mdate'] & 0x01E0) >> 5; |
|
| 4354 | - $v_day = $p_header['mdate'] & 0x001F; |
|
| 4355 | - |
|
| 4356 | - // ----- Get UNIX date format |
|
| 4357 | - $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year); |
|
| 4332 | + // ----- Extract properties |
|
| 4333 | + $p_header['version_extracted'] = $v_data['version']; |
|
| 4334 | + $p_header['compression'] = $v_data['compression']; |
|
| 4335 | + $p_header['size'] = $v_data['size']; |
|
| 4336 | + $p_header['compressed_size'] = $v_data['compressed_size']; |
|
| 4337 | + $p_header['crc'] = $v_data['crc']; |
|
| 4338 | + $p_header['flag'] = $v_data['flag']; |
|
| 4339 | + $p_header['filename_len'] = $v_data['filename_len']; |
|
| 4340 | + |
|
| 4341 | + // ----- Recuperate date in UNIX format |
|
| 4342 | + $p_header['mdate'] = $v_data['mdate']; |
|
| 4343 | + $p_header['mtime'] = $v_data['mtime']; |
|
| 4344 | + if ($p_header['mdate'] && $p_header['mtime']) |
|
| 4345 | + { |
|
| 4346 | + // ----- Extract time |
|
| 4347 | + $v_hour = ($p_header['mtime'] & 0xF800) >> 11; |
|
| 4348 | + $v_minute = ($p_header['mtime'] & 0x07E0) >> 5; |
|
| 4349 | + $v_seconde = ($p_header['mtime'] & 0x001F)*2; |
|
| 4350 | + |
|
| 4351 | + // ----- Extract date |
|
| 4352 | + $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980; |
|
| 4353 | + $v_month = ($p_header['mdate'] & 0x01E0) >> 5; |
|
| 4354 | + $v_day = $p_header['mdate'] & 0x001F; |
|
| 4355 | + |
|
| 4356 | + // ----- Get UNIX date format |
|
| 4357 | + $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year); |
|
| 4358 | 4358 | |
| 4359 | - } |
|
| 4360 | - else |
|
| 4361 | - { |
|
| 4362 | - $p_header['mtime'] = time(); |
|
| 4363 | - } |
|
| 4359 | + } |
|
| 4360 | + else |
|
| 4361 | + { |
|
| 4362 | + $p_header['mtime'] = time(); |
|
| 4363 | + } |
|
| 4364 | 4364 | |
| 4365 | - // TBC |
|
| 4366 | - //for(reset($v_data); $key = key($v_data); next($v_data)) { |
|
| 4367 | - //} |
|
| 4365 | + // TBC |
|
| 4366 | + //for(reset($v_data); $key = key($v_data); next($v_data)) { |
|
| 4367 | + //} |
|
| 4368 | 4368 | |
| 4369 | - // ----- Set the stored filename |
|
| 4370 | - $p_header['stored_filename'] = $p_header['filename']; |
|
| 4369 | + // ----- Set the stored filename |
|
| 4370 | + $p_header['stored_filename'] = $p_header['filename']; |
|
| 4371 | 4371 | |
| 4372 | - // ----- Set the status field |
|
| 4373 | - $p_header['status'] = "ok"; |
|
| 4372 | + // ----- Set the status field |
|
| 4373 | + $p_header['status'] = "ok"; |
|
| 4374 | 4374 | |
| 4375 | - // ----- Return |
|
| 4376 | - return $v_result; |
|
| 4375 | + // ----- Return |
|
| 4376 | + return $v_result; |
|
| 4377 | 4377 | } |
| 4378 | 4378 | // -------------------------------------------------------------------------------- |
| 4379 | 4379 | |
@@ -4385,101 +4385,101 @@ discard block |
||
| 4385 | 4385 | // -------------------------------------------------------------------------------- |
| 4386 | 4386 | function privReadCentralFileHeader(&$p_header) |
| 4387 | 4387 | { |
| 4388 | - $v_result=1; |
|
| 4388 | + $v_result=1; |
|
| 4389 | 4389 | |
| 4390 | - // ----- Read the 4 bytes signature |
|
| 4391 | - $v_binary_data = @fread($this->zip_fd, 4); |
|
| 4392 | - $v_data = unpack('Vid', $v_binary_data); |
|
| 4390 | + // ----- Read the 4 bytes signature |
|
| 4391 | + $v_binary_data = @fread($this->zip_fd, 4); |
|
| 4392 | + $v_data = unpack('Vid', $v_binary_data); |
|
| 4393 | 4393 | |
| 4394 | - // ----- Check signature |
|
| 4395 | - if ($v_data['id'] != 0x02014b50) |
|
| 4396 | - { |
|
| 4394 | + // ----- Check signature |
|
| 4395 | + if ($v_data['id'] != 0x02014b50) |
|
| 4396 | + { |
|
| 4397 | 4397 | |
| 4398 | - // ----- Error log |
|
| 4399 | - PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure'); |
|
| 4398 | + // ----- Error log |
|
| 4399 | + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure'); |
|
| 4400 | 4400 | |
| 4401 | - // ----- Return |
|
| 4402 | - return PclZip::errorCode(); |
|
| 4403 | - } |
|
| 4401 | + // ----- Return |
|
| 4402 | + return PclZip::errorCode(); |
|
| 4403 | + } |
|
| 4404 | 4404 | |
| 4405 | - // ----- Read the first 42 bytes of the header |
|
| 4406 | - $v_binary_data = fread($this->zip_fd, 42); |
|
| 4405 | + // ----- Read the first 42 bytes of the header |
|
| 4406 | + $v_binary_data = fread($this->zip_fd, 42); |
|
| 4407 | 4407 | |
| 4408 | - // ----- Look for invalid block size |
|
| 4409 | - if (strlen($v_binary_data) != 42) |
|
| 4410 | - { |
|
| 4411 | - $p_header['filename'] = ""; |
|
| 4412 | - $p_header['status'] = "invalid_header"; |
|
| 4408 | + // ----- Look for invalid block size |
|
| 4409 | + if (strlen($v_binary_data) != 42) |
|
| 4410 | + { |
|
| 4411 | + $p_header['filename'] = ""; |
|
| 4412 | + $p_header['status'] = "invalid_header"; |
|
| 4413 | 4413 | |
| 4414 | - // ----- Error log |
|
| 4415 | - PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data)); |
|
| 4414 | + // ----- Error log |
|
| 4415 | + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data)); |
|
| 4416 | 4416 | |
| 4417 | - // ----- Return |
|
| 4418 | - return PclZip::errorCode(); |
|
| 4419 | - } |
|
| 4417 | + // ----- Return |
|
| 4418 | + return PclZip::errorCode(); |
|
| 4419 | + } |
|
| 4420 | 4420 | |
| 4421 | - // ----- Extract the values |
|
| 4422 | - $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); |
|
| 4423 | - |
|
| 4424 | - // ----- Get filename |
|
| 4425 | - if ($p_header['filename_len'] != 0) |
|
| 4426 | - $p_header['filename'] = fread($this->zip_fd, $p_header['filename_len']); |
|
| 4427 | - else |
|
| 4428 | - $p_header['filename'] = ''; |
|
| 4429 | - |
|
| 4430 | - // ----- Get extra |
|
| 4431 | - if ($p_header['extra_len'] != 0) |
|
| 4432 | - $p_header['extra'] = fread($this->zip_fd, $p_header['extra_len']); |
|
| 4433 | - else |
|
| 4434 | - $p_header['extra'] = ''; |
|
| 4435 | - |
|
| 4436 | - // ----- Get comment |
|
| 4437 | - if ($p_header['comment_len'] != 0) |
|
| 4438 | - $p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']); |
|
| 4439 | - else |
|
| 4440 | - $p_header['comment'] = ''; |
|
| 4441 | - |
|
| 4442 | - // ----- Extract properties |
|
| 4443 | - |
|
| 4444 | - // ----- Recuperate date in UNIX format |
|
| 4445 | - //if ($p_header['mdate'] && $p_header['mtime']) |
|
| 4446 | - // TBC : bug : this was ignoring time with 0/0/0 |
|
| 4447 | - if (1) |
|
| 4448 | - { |
|
| 4449 | - // ----- Extract time |
|
| 4450 | - $v_hour = ($p_header['mtime'] & 0xF800) >> 11; |
|
| 4451 | - $v_minute = ($p_header['mtime'] & 0x07E0) >> 5; |
|
| 4452 | - $v_seconde = ($p_header['mtime'] & 0x001F)*2; |
|
| 4453 | - |
|
| 4454 | - // ----- Extract date |
|
| 4455 | - $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980; |
|
| 4456 | - $v_month = ($p_header['mdate'] & 0x01E0) >> 5; |
|
| 4457 | - $v_day = $p_header['mdate'] & 0x001F; |
|
| 4458 | - |
|
| 4459 | - // ----- Get UNIX date format |
|
| 4460 | - $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year); |
|
| 4421 | + // ----- Extract the values |
|
| 4422 | + $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); |
|
| 4423 | + |
|
| 4424 | + // ----- Get filename |
|
| 4425 | + if ($p_header['filename_len'] != 0) |
|
| 4426 | + $p_header['filename'] = fread($this->zip_fd, $p_header['filename_len']); |
|
| 4427 | + else |
|
| 4428 | + $p_header['filename'] = ''; |
|
| 4429 | + |
|
| 4430 | + // ----- Get extra |
|
| 4431 | + if ($p_header['extra_len'] != 0) |
|
| 4432 | + $p_header['extra'] = fread($this->zip_fd, $p_header['extra_len']); |
|
| 4433 | + else |
|
| 4434 | + $p_header['extra'] = ''; |
|
| 4435 | + |
|
| 4436 | + // ----- Get comment |
|
| 4437 | + if ($p_header['comment_len'] != 0) |
|
| 4438 | + $p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']); |
|
| 4439 | + else |
|
| 4440 | + $p_header['comment'] = ''; |
|
| 4441 | + |
|
| 4442 | + // ----- Extract properties |
|
| 4443 | + |
|
| 4444 | + // ----- Recuperate date in UNIX format |
|
| 4445 | + //if ($p_header['mdate'] && $p_header['mtime']) |
|
| 4446 | + // TBC : bug : this was ignoring time with 0/0/0 |
|
| 4447 | + if (1) |
|
| 4448 | + { |
|
| 4449 | + // ----- Extract time |
|
| 4450 | + $v_hour = ($p_header['mtime'] & 0xF800) >> 11; |
|
| 4451 | + $v_minute = ($p_header['mtime'] & 0x07E0) >> 5; |
|
| 4452 | + $v_seconde = ($p_header['mtime'] & 0x001F)*2; |
|
| 4453 | + |
|
| 4454 | + // ----- Extract date |
|
| 4455 | + $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980; |
|
| 4456 | + $v_month = ($p_header['mdate'] & 0x01E0) >> 5; |
|
| 4457 | + $v_day = $p_header['mdate'] & 0x001F; |
|
| 4458 | + |
|
| 4459 | + // ----- Get UNIX date format |
|
| 4460 | + $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year); |
|
| 4461 | 4461 | |
| 4462 | - } |
|
| 4463 | - else |
|
| 4464 | - { |
|
| 4465 | - $p_header['mtime'] = time(); |
|
| 4466 | - } |
|
| 4462 | + } |
|
| 4463 | + else |
|
| 4464 | + { |
|
| 4465 | + $p_header['mtime'] = time(); |
|
| 4466 | + } |
|
| 4467 | 4467 | |
| 4468 | - // ----- Set the stored filename |
|
| 4469 | - $p_header['stored_filename'] = $p_header['filename']; |
|
| 4468 | + // ----- Set the stored filename |
|
| 4469 | + $p_header['stored_filename'] = $p_header['filename']; |
|
| 4470 | 4470 | |
| 4471 | - // ----- Set default status to ok |
|
| 4472 | - $p_header['status'] = 'ok'; |
|
| 4471 | + // ----- Set default status to ok |
|
| 4472 | + $p_header['status'] = 'ok'; |
|
| 4473 | 4473 | |
| 4474 | - // ----- Look if it is a directory |
|
| 4475 | - if (substr($p_header['filename'], -1) == '/') { |
|
| 4476 | - //$p_header['external'] = 0x41FF0010; |
|
| 4477 | - $p_header['external'] = 0x00000010; |
|
| 4478 | - } |
|
| 4474 | + // ----- Look if it is a directory |
|
| 4475 | + if (substr($p_header['filename'], -1) == '/') { |
|
| 4476 | + //$p_header['external'] = 0x41FF0010; |
|
| 4477 | + $p_header['external'] = 0x00000010; |
|
| 4478 | + } |
|
| 4479 | 4479 | |
| 4480 | 4480 | |
| 4481 | - // ----- Return |
|
| 4482 | - return $v_result; |
|
| 4481 | + // ----- Return |
|
| 4482 | + return $v_result; |
|
| 4483 | 4483 | } |
| 4484 | 4484 | // -------------------------------------------------------------------------------- |
| 4485 | 4485 | |
@@ -4493,7 +4493,7 @@ discard block |
||
| 4493 | 4493 | // -------------------------------------------------------------------------------- |
| 4494 | 4494 | function privCheckFileHeaders(&$p_local_header, &$p_central_header) |
| 4495 | 4495 | { |
| 4496 | - $v_result=1; |
|
| 4496 | + $v_result=1; |
|
| 4497 | 4497 | |
| 4498 | 4498 | // ----- Check the static values |
| 4499 | 4499 | // TBC |
@@ -4512,13 +4512,13 @@ discard block |
||
| 4512 | 4512 | |
| 4513 | 4513 | // ----- Look for flag bit 3 |
| 4514 | 4514 | if (($p_local_header['flag'] & 8) == 8) { |
| 4515 | - $p_local_header['size'] = $p_central_header['size']; |
|
| 4516 | - $p_local_header['compressed_size'] = $p_central_header['compressed_size']; |
|
| 4517 | - $p_local_header['crc'] = $p_central_header['crc']; |
|
| 4515 | + $p_local_header['size'] = $p_central_header['size']; |
|
| 4516 | + $p_local_header['compressed_size'] = $p_central_header['compressed_size']; |
|
| 4517 | + $p_local_header['crc'] = $p_central_header['crc']; |
|
| 4518 | 4518 | } |
| 4519 | 4519 | |
| 4520 | - // ----- Return |
|
| 4521 | - return $v_result; |
|
| 4520 | + // ----- Return |
|
| 4521 | + return $v_result; |
|
| 4522 | 4522 | } |
| 4523 | 4523 | // -------------------------------------------------------------------------------- |
| 4524 | 4524 | |
@@ -4530,152 +4530,152 @@ discard block |
||
| 4530 | 4530 | // -------------------------------------------------------------------------------- |
| 4531 | 4531 | function privReadEndCentralDir(&$p_central_dir) |
| 4532 | 4532 | { |
| 4533 | - $v_result=1; |
|
| 4534 | - |
|
| 4535 | - // ----- Go to the end of the zip file |
|
| 4536 | - $v_size = filesize($this->zipname); |
|
| 4537 | - @fseek($this->zip_fd, $v_size); |
|
| 4538 | - if (@ftell($this->zip_fd) != $v_size) |
|
| 4539 | - { |
|
| 4540 | - // ----- Error log |
|
| 4541 | - PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to go to the end of the archive \''.$this->zipname.'\''); |
|
| 4542 | - |
|
| 4543 | - // ----- Return |
|
| 4544 | - return PclZip::errorCode(); |
|
| 4545 | - } |
|
| 4533 | + $v_result=1; |
|
| 4534 | + |
|
| 4535 | + // ----- Go to the end of the zip file |
|
| 4536 | + $v_size = filesize($this->zipname); |
|
| 4537 | + @fseek($this->zip_fd, $v_size); |
|
| 4538 | + if (@ftell($this->zip_fd) != $v_size) |
|
| 4539 | + { |
|
| 4540 | + // ----- Error log |
|
| 4541 | + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to go to the end of the archive \''.$this->zipname.'\''); |
|
| 4542 | + |
|
| 4543 | + // ----- Return |
|
| 4544 | + return PclZip::errorCode(); |
|
| 4545 | + } |
|
| 4546 | 4546 | |
| 4547 | - // ----- First try : look if this is an archive with no commentaries (most of the time) |
|
| 4548 | - // in this case the end of central dir is at 22 bytes of the file end |
|
| 4549 | - $v_found = 0; |
|
| 4550 | - if ($v_size > 26) { |
|
| 4551 | - @fseek($this->zip_fd, $v_size-22); |
|
| 4552 | - if (($v_pos = @ftell($this->zip_fd)) != ($v_size-22)) |
|
| 4553 | - { |
|
| 4554 | - // ----- Error log |
|
| 4555 | - PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\''); |
|
| 4556 | - |
|
| 4557 | - // ----- Return |
|
| 4558 | - return PclZip::errorCode(); |
|
| 4559 | - } |
|
| 4547 | + // ----- First try : look if this is an archive with no commentaries (most of the time) |
|
| 4548 | + // in this case the end of central dir is at 22 bytes of the file end |
|
| 4549 | + $v_found = 0; |
|
| 4550 | + if ($v_size > 26) { |
|
| 4551 | + @fseek($this->zip_fd, $v_size-22); |
|
| 4552 | + if (($v_pos = @ftell($this->zip_fd)) != ($v_size-22)) |
|
| 4553 | + { |
|
| 4554 | + // ----- Error log |
|
| 4555 | + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\''); |
|
| 4556 | + |
|
| 4557 | + // ----- Return |
|
| 4558 | + return PclZip::errorCode(); |
|
| 4559 | + } |
|
| 4560 | 4560 | |
| 4561 | - // ----- Read for bytes |
|
| 4562 | - $v_binary_data = @fread($this->zip_fd, 4); |
|
| 4563 | - $v_data = @unpack('Vid', $v_binary_data); |
|
| 4561 | + // ----- Read for bytes |
|
| 4562 | + $v_binary_data = @fread($this->zip_fd, 4); |
|
| 4563 | + $v_data = @unpack('Vid', $v_binary_data); |
|
| 4564 | 4564 | |
| 4565 | - // ----- Check signature |
|
| 4566 | - if ($v_data['id'] == 0x06054b50) { |
|
| 4567 | - $v_found = 1; |
|
| 4568 | - } |
|
| 4565 | + // ----- Check signature |
|
| 4566 | + if ($v_data['id'] == 0x06054b50) { |
|
| 4567 | + $v_found = 1; |
|
| 4568 | + } |
|
| 4569 | 4569 | |
| 4570 | - $v_pos = ftell($this->zip_fd); |
|
| 4571 | - } |
|
| 4570 | + $v_pos = ftell($this->zip_fd); |
|
| 4571 | + } |
|
| 4572 | 4572 | |
| 4573 | - // ----- Go back to the maximum possible size of the Central Dir End Record |
|
| 4574 | - if (!$v_found) { |
|
| 4575 | - $v_maximum_size = 65557; // 0xFFFF + 22; |
|
| 4576 | - if ($v_maximum_size > $v_size) |
|
| 4577 | - $v_maximum_size = $v_size; |
|
| 4578 | - @fseek($this->zip_fd, $v_size-$v_maximum_size); |
|
| 4579 | - if (@ftell($this->zip_fd) != ($v_size-$v_maximum_size)) |
|
| 4580 | - { |
|
| 4581 | - // ----- Error log |
|
| 4582 | - PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\''); |
|
| 4583 | - |
|
| 4584 | - // ----- Return |
|
| 4585 | - return PclZip::errorCode(); |
|
| 4586 | - } |
|
| 4573 | + // ----- Go back to the maximum possible size of the Central Dir End Record |
|
| 4574 | + if (!$v_found) { |
|
| 4575 | + $v_maximum_size = 65557; // 0xFFFF + 22; |
|
| 4576 | + if ($v_maximum_size > $v_size) |
|
| 4577 | + $v_maximum_size = $v_size; |
|
| 4578 | + @fseek($this->zip_fd, $v_size-$v_maximum_size); |
|
| 4579 | + if (@ftell($this->zip_fd) != ($v_size-$v_maximum_size)) |
|
| 4580 | + { |
|
| 4581 | + // ----- Error log |
|
| 4582 | + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\''); |
|
| 4583 | + |
|
| 4584 | + // ----- Return |
|
| 4585 | + return PclZip::errorCode(); |
|
| 4586 | + } |
|
| 4587 | 4587 | |
| 4588 | - // ----- Read byte per byte in order to find the signature |
|
| 4589 | - $v_pos = ftell($this->zip_fd); |
|
| 4590 | - $v_bytes = 0x00000000; |
|
| 4591 | - while ($v_pos < $v_size) |
|
| 4592 | - { |
|
| 4593 | - // ----- Read a byte |
|
| 4594 | - $v_byte = @fread($this->zip_fd, 1); |
|
| 4595 | - |
|
| 4596 | - // ----- Add the byte |
|
| 4597 | - //$v_bytes = ($v_bytes << 8) | Ord($v_byte); |
|
| 4598 | - // Note we mask the old value down such that once shifted we can never end up with more than a 32bit number |
|
| 4599 | - // Otherwise on systems where we have 64bit integers the check below for the magic number will fail. |
|
| 4600 | - $v_bytes = ( ($v_bytes & 0xFFFFFF) << 8) | Ord($v_byte); |
|
| 4601 | - |
|
| 4602 | - // ----- Compare the bytes |
|
| 4603 | - if ($v_bytes == 0x504b0506) |
|
| 4604 | - { |
|
| 4605 | - $v_pos++; |
|
| 4606 | - break; |
|
| 4607 | - } |
|
| 4608 | - |
|
| 4609 | - $v_pos++; |
|
| 4610 | - } |
|
| 4588 | + // ----- Read byte per byte in order to find the signature |
|
| 4589 | + $v_pos = ftell($this->zip_fd); |
|
| 4590 | + $v_bytes = 0x00000000; |
|
| 4591 | + while ($v_pos < $v_size) |
|
| 4592 | + { |
|
| 4593 | + // ----- Read a byte |
|
| 4594 | + $v_byte = @fread($this->zip_fd, 1); |
|
| 4595 | + |
|
| 4596 | + // ----- Add the byte |
|
| 4597 | + //$v_bytes = ($v_bytes << 8) | Ord($v_byte); |
|
| 4598 | + // Note we mask the old value down such that once shifted we can never end up with more than a 32bit number |
|
| 4599 | + // Otherwise on systems where we have 64bit integers the check below for the magic number will fail. |
|
| 4600 | + $v_bytes = ( ($v_bytes & 0xFFFFFF) << 8) | Ord($v_byte); |
|
| 4601 | + |
|
| 4602 | + // ----- Compare the bytes |
|
| 4603 | + if ($v_bytes == 0x504b0506) |
|
| 4604 | + { |
|
| 4605 | + $v_pos++; |
|
| 4606 | + break; |
|
| 4607 | + } |
|
| 4608 | + |
|
| 4609 | + $v_pos++; |
|
| 4610 | + } |
|
| 4611 | 4611 | |
| 4612 | - // ----- Look if not found end of central dir |
|
| 4613 | - if ($v_pos == $v_size) |
|
| 4614 | - { |
|
| 4612 | + // ----- Look if not found end of central dir |
|
| 4613 | + if ($v_pos == $v_size) |
|
| 4614 | + { |
|
| 4615 | 4615 | |
| 4616 | - // ----- Error log |
|
| 4617 | - PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Unable to find End of Central Dir Record signature"); |
|
| 4616 | + // ----- Error log |
|
| 4617 | + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Unable to find End of Central Dir Record signature"); |
|
| 4618 | 4618 | |
| 4619 | - // ----- Return |
|
| 4620 | - return PclZip::errorCode(); |
|
| 4621 | - } |
|
| 4622 | - } |
|
| 4619 | + // ----- Return |
|
| 4620 | + return PclZip::errorCode(); |
|
| 4621 | + } |
|
| 4622 | + } |
|
| 4623 | 4623 | |
| 4624 | - // ----- Read the first 18 bytes of the header |
|
| 4625 | - $v_binary_data = fread($this->zip_fd, 18); |
|
| 4624 | + // ----- Read the first 18 bytes of the header |
|
| 4625 | + $v_binary_data = fread($this->zip_fd, 18); |
|
| 4626 | 4626 | |
| 4627 | - // ----- Look for invalid block size |
|
| 4628 | - if (strlen($v_binary_data) != 18) |
|
| 4629 | - { |
|
| 4627 | + // ----- Look for invalid block size |
|
| 4628 | + if (strlen($v_binary_data) != 18) |
|
| 4629 | + { |
|
| 4630 | 4630 | |
| 4631 | - // ----- Error log |
|
| 4632 | - PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid End of Central Dir Record size : ".strlen($v_binary_data)); |
|
| 4631 | + // ----- Error log |
|
| 4632 | + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid End of Central Dir Record size : ".strlen($v_binary_data)); |
|
| 4633 | 4633 | |
| 4634 | - // ----- Return |
|
| 4635 | - return PclZip::errorCode(); |
|
| 4636 | - } |
|
| 4634 | + // ----- Return |
|
| 4635 | + return PclZip::errorCode(); |
|
| 4636 | + } |
|
| 4637 | 4637 | |
| 4638 | - // ----- Extract the values |
|
| 4639 | - $v_data = unpack('vdisk/vdisk_start/vdisk_entries/ventries/Vsize/Voffset/vcomment_size', $v_binary_data); |
|
| 4638 | + // ----- Extract the values |
|
| 4639 | + $v_data = unpack('vdisk/vdisk_start/vdisk_entries/ventries/Vsize/Voffset/vcomment_size', $v_binary_data); |
|
| 4640 | 4640 | |
| 4641 | - // ----- Check the global size |
|
| 4642 | - if (($v_pos + $v_data['comment_size'] + 18) != $v_size) { |
|
| 4641 | + // ----- Check the global size |
|
| 4642 | + if (($v_pos + $v_data['comment_size'] + 18) != $v_size) { |
|
| 4643 | 4643 | |
| 4644 | 4644 | // ----- Removed in release 2.2 see readme file |
| 4645 | 4645 | // The check of the file size is a little too strict. |
| 4646 | 4646 | // Some bugs where found when a zip is encrypted/decrypted with 'crypt'. |
| 4647 | 4647 | // While decrypted, zip has training 0 bytes |
| 4648 | 4648 | if (0) { |
| 4649 | - // ----- Error log |
|
| 4650 | - PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, |
|
| 4651 | - 'The central dir is not at the end of the archive.' |
|
| 4649 | + // ----- Error log |
|
| 4650 | + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, |
|
| 4651 | + 'The central dir is not at the end of the archive.' |
|
| 4652 | 4652 | .' Some trailing bytes exists after the archive.'); |
| 4653 | 4653 | |
| 4654 | - // ----- Return |
|
| 4655 | - return PclZip::errorCode(); |
|
| 4654 | + // ----- Return |
|
| 4655 | + return PclZip::errorCode(); |
|
| 4656 | 4656 | } |
| 4657 | - } |
|
| 4657 | + } |
|
| 4658 | 4658 | |
| 4659 | - // ----- Get comment |
|
| 4660 | - if ($v_data['comment_size'] != 0) { |
|
| 4661 | - $p_central_dir['comment'] = fread($this->zip_fd, $v_data['comment_size']); |
|
| 4662 | - } |
|
| 4663 | - else |
|
| 4664 | - $p_central_dir['comment'] = ''; |
|
| 4665 | - |
|
| 4666 | - $p_central_dir['entries'] = $v_data['entries']; |
|
| 4667 | - $p_central_dir['disk_entries'] = $v_data['disk_entries']; |
|
| 4668 | - $p_central_dir['offset'] = $v_data['offset']; |
|
| 4669 | - $p_central_dir['size'] = $v_data['size']; |
|
| 4670 | - $p_central_dir['disk'] = $v_data['disk']; |
|
| 4671 | - $p_central_dir['disk_start'] = $v_data['disk_start']; |
|
| 4672 | - |
|
| 4673 | - // TBC |
|
| 4674 | - //for(reset($p_central_dir); $key = key($p_central_dir); next($p_central_dir)) { |
|
| 4675 | - //} |
|
| 4676 | - |
|
| 4677 | - // ----- Return |
|
| 4678 | - return $v_result; |
|
| 4659 | + // ----- Get comment |
|
| 4660 | + if ($v_data['comment_size'] != 0) { |
|
| 4661 | + $p_central_dir['comment'] = fread($this->zip_fd, $v_data['comment_size']); |
|
| 4662 | + } |
|
| 4663 | + else |
|
| 4664 | + $p_central_dir['comment'] = ''; |
|
| 4665 | + |
|
| 4666 | + $p_central_dir['entries'] = $v_data['entries']; |
|
| 4667 | + $p_central_dir['disk_entries'] = $v_data['disk_entries']; |
|
| 4668 | + $p_central_dir['offset'] = $v_data['offset']; |
|
| 4669 | + $p_central_dir['size'] = $v_data['size']; |
|
| 4670 | + $p_central_dir['disk'] = $v_data['disk']; |
|
| 4671 | + $p_central_dir['disk_start'] = $v_data['disk_start']; |
|
| 4672 | + |
|
| 4673 | + // TBC |
|
| 4674 | + //for(reset($p_central_dir); $key = key($p_central_dir); next($p_central_dir)) { |
|
| 4675 | + //} |
|
| 4676 | + |
|
| 4677 | + // ----- Return |
|
| 4678 | + return $v_result; |
|
| 4679 | 4679 | } |
| 4680 | 4680 | // -------------------------------------------------------------------------------- |
| 4681 | 4681 | |
@@ -4687,96 +4687,96 @@ discard block |
||
| 4687 | 4687 | // -------------------------------------------------------------------------------- |
| 4688 | 4688 | function privDeleteByRule(&$p_result_list, &$p_options) |
| 4689 | 4689 | { |
| 4690 | - $v_result=1; |
|
| 4691 | - $v_list_detail = array(); |
|
| 4692 | - |
|
| 4693 | - // ----- Open the zip file |
|
| 4694 | - if (($v_result=$this->privOpenFd('rb')) != 1) |
|
| 4695 | - { |
|
| 4696 | - // ----- Return |
|
| 4697 | - return $v_result; |
|
| 4698 | - } |
|
| 4690 | + $v_result=1; |
|
| 4691 | + $v_list_detail = array(); |
|
| 4692 | + |
|
| 4693 | + // ----- Open the zip file |
|
| 4694 | + if (($v_result=$this->privOpenFd('rb')) != 1) |
|
| 4695 | + { |
|
| 4696 | + // ----- Return |
|
| 4697 | + return $v_result; |
|
| 4698 | + } |
|
| 4699 | 4699 | |
| 4700 | - // ----- Read the central directory informations |
|
| 4701 | - $v_central_dir = array(); |
|
| 4702 | - if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) |
|
| 4703 | - { |
|
| 4704 | - $this->privCloseFd(); |
|
| 4705 | - return $v_result; |
|
| 4706 | - } |
|
| 4700 | + // ----- Read the central directory informations |
|
| 4701 | + $v_central_dir = array(); |
|
| 4702 | + if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) |
|
| 4703 | + { |
|
| 4704 | + $this->privCloseFd(); |
|
| 4705 | + return $v_result; |
|
| 4706 | + } |
|
| 4707 | 4707 | |
| 4708 | - // ----- Go to beginning of File |
|
| 4709 | - @rewind($this->zip_fd); |
|
| 4708 | + // ----- Go to beginning of File |
|
| 4709 | + @rewind($this->zip_fd); |
|
| 4710 | 4710 | |
| 4711 | - // ----- Scan all the files |
|
| 4712 | - // ----- Start at beginning of Central Dir |
|
| 4713 | - $v_pos_entry = $v_central_dir['offset']; |
|
| 4714 | - @rewind($this->zip_fd); |
|
| 4715 | - if (@fseek($this->zip_fd, $v_pos_entry)) |
|
| 4716 | - { |
|
| 4717 | - // ----- Close the zip file |
|
| 4718 | - $this->privCloseFd(); |
|
| 4711 | + // ----- Scan all the files |
|
| 4712 | + // ----- Start at beginning of Central Dir |
|
| 4713 | + $v_pos_entry = $v_central_dir['offset']; |
|
| 4714 | + @rewind($this->zip_fd); |
|
| 4715 | + if (@fseek($this->zip_fd, $v_pos_entry)) |
|
| 4716 | + { |
|
| 4717 | + // ----- Close the zip file |
|
| 4718 | + $this->privCloseFd(); |
|
| 4719 | 4719 | |
| 4720 | - // ----- Error log |
|
| 4721 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); |
|
| 4720 | + // ----- Error log |
|
| 4721 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); |
|
| 4722 | 4722 | |
| 4723 | - // ----- Return |
|
| 4724 | - return PclZip::errorCode(); |
|
| 4725 | - } |
|
| 4723 | + // ----- Return |
|
| 4724 | + return PclZip::errorCode(); |
|
| 4725 | + } |
|
| 4726 | 4726 | |
| 4727 | - // ----- Read each entry |
|
| 4728 | - $v_header_list = array(); |
|
| 4729 | - $j_start = 0; |
|
| 4730 | - for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++) |
|
| 4731 | - { |
|
| 4727 | + // ----- Read each entry |
|
| 4728 | + $v_header_list = array(); |
|
| 4729 | + $j_start = 0; |
|
| 4730 | + for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++) |
|
| 4731 | + { |
|
| 4732 | 4732 | |
| 4733 | - // ----- Read the file header |
|
| 4734 | - $v_header_list[$v_nb_extracted] = array(); |
|
| 4735 | - if (($v_result = $this->privReadCentralFileHeader($v_header_list[$v_nb_extracted])) != 1) |
|
| 4736 | - { |
|
| 4737 | - // ----- Close the zip file |
|
| 4738 | - $this->privCloseFd(); |
|
| 4733 | + // ----- Read the file header |
|
| 4734 | + $v_header_list[$v_nb_extracted] = array(); |
|
| 4735 | + if (($v_result = $this->privReadCentralFileHeader($v_header_list[$v_nb_extracted])) != 1) |
|
| 4736 | + { |
|
| 4737 | + // ----- Close the zip file |
|
| 4738 | + $this->privCloseFd(); |
|
| 4739 | 4739 | |
| 4740 | - return $v_result; |
|
| 4741 | - } |
|
| 4740 | + return $v_result; |
|
| 4741 | + } |
|
| 4742 | 4742 | |
| 4743 | 4743 | |
| 4744 | - // ----- Store the index |
|
| 4745 | - $v_header_list[$v_nb_extracted]['index'] = $i; |
|
| 4746 | - |
|
| 4747 | - // ----- Look for the specific extract rules |
|
| 4748 | - $v_found = false; |
|
| 4749 | - |
|
| 4750 | - // ----- Look for extract by name rule |
|
| 4751 | - if ( (isset($p_options[PCLZIP_OPT_BY_NAME])) |
|
| 4752 | - && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) { |
|
| 4753 | - |
|
| 4754 | - // ----- Look if the filename is in the list |
|
| 4755 | - for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_found); $j++) { |
|
| 4756 | - |
|
| 4757 | - // ----- Look for a directory |
|
| 4758 | - if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") { |
|
| 4759 | - |
|
| 4760 | - // ----- Look if the directory is in the filename path |
|
| 4761 | - if ( (strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) |
|
| 4762 | - && (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])) { |
|
| 4763 | - $v_found = true; |
|
| 4764 | - } |
|
| 4765 | - elseif ( (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */ |
|
| 4766 | - && ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_options[PCLZIP_OPT_BY_NAME][$j])) { |
|
| 4767 | - $v_found = true; |
|
| 4768 | - } |
|
| 4769 | - } |
|
| 4770 | - // ----- Look for a filename |
|
| 4771 | - elseif ($v_header_list[$v_nb_extracted]['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) { |
|
| 4772 | - $v_found = true; |
|
| 4773 | - } |
|
| 4774 | - } |
|
| 4775 | - } |
|
| 4744 | + // ----- Store the index |
|
| 4745 | + $v_header_list[$v_nb_extracted]['index'] = $i; |
|
| 4746 | + |
|
| 4747 | + // ----- Look for the specific extract rules |
|
| 4748 | + $v_found = false; |
|
| 4749 | + |
|
| 4750 | + // ----- Look for extract by name rule |
|
| 4751 | + if ( (isset($p_options[PCLZIP_OPT_BY_NAME])) |
|
| 4752 | + && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) { |
|
| 4753 | + |
|
| 4754 | + // ----- Look if the filename is in the list |
|
| 4755 | + for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_found); $j++) { |
|
| 4756 | + |
|
| 4757 | + // ----- Look for a directory |
|
| 4758 | + if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") { |
|
| 4759 | + |
|
| 4760 | + // ----- Look if the directory is in the filename path |
|
| 4761 | + if ( (strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) |
|
| 4762 | + && (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])) { |
|
| 4763 | + $v_found = true; |
|
| 4764 | + } |
|
| 4765 | + elseif ( (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */ |
|
| 4766 | + && ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_options[PCLZIP_OPT_BY_NAME][$j])) { |
|
| 4767 | + $v_found = true; |
|
| 4768 | + } |
|
| 4769 | + } |
|
| 4770 | + // ----- Look for a filename |
|
| 4771 | + elseif ($v_header_list[$v_nb_extracted]['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) { |
|
| 4772 | + $v_found = true; |
|
| 4773 | + } |
|
| 4774 | + } |
|
| 4775 | + } |
|
| 4776 | 4776 | |
| 4777 | - // ----- Look for extract by ereg rule |
|
| 4778 | - // ereg() is deprecated with PHP 5.3 |
|
| 4779 | - /* |
|
| 4777 | + // ----- Look for extract by ereg rule |
|
| 4778 | + // ereg() is deprecated with PHP 5.3 |
|
| 4779 | + /* |
|
| 4780 | 4780 | else if ( (isset($p_options[PCLZIP_OPT_BY_EREG])) |
| 4781 | 4781 | && ($p_options[PCLZIP_OPT_BY_EREG] != "")) { |
| 4782 | 4782 | |
@@ -4786,201 +4786,201 @@ discard block |
||
| 4786 | 4786 | } |
| 4787 | 4787 | */ |
| 4788 | 4788 | |
| 4789 | - // ----- Look for extract by preg rule |
|
| 4790 | - else if ( (isset($p_options[PCLZIP_OPT_BY_PREG])) |
|
| 4791 | - && ($p_options[PCLZIP_OPT_BY_PREG] != "")) { |
|
| 4789 | + // ----- Look for extract by preg rule |
|
| 4790 | + else if ( (isset($p_options[PCLZIP_OPT_BY_PREG])) |
|
| 4791 | + && ($p_options[PCLZIP_OPT_BY_PREG] != "")) { |
|
| 4792 | 4792 | |
| 4793 | - if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header_list[$v_nb_extracted]['stored_filename'])) { |
|
| 4794 | - $v_found = true; |
|
| 4795 | - } |
|
| 4796 | - } |
|
| 4793 | + if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header_list[$v_nb_extracted]['stored_filename'])) { |
|
| 4794 | + $v_found = true; |
|
| 4795 | + } |
|
| 4796 | + } |
|
| 4797 | 4797 | |
| 4798 | - // ----- Look for extract by index rule |
|
| 4799 | - else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX])) |
|
| 4800 | - && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) { |
|
| 4798 | + // ----- Look for extract by index rule |
|
| 4799 | + else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX])) |
|
| 4800 | + && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) { |
|
| 4801 | 4801 | |
| 4802 | - // ----- Look if the index is in the list |
|
| 4803 | - for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_found); $j++) { |
|
| 4802 | + // ----- Look if the index is in the list |
|
| 4803 | + for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_found); $j++) { |
|
| 4804 | 4804 | |
| 4805 | - if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) { |
|
| 4806 | - $v_found = true; |
|
| 4807 | - } |
|
| 4808 | - if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) { |
|
| 4809 | - $j_start = $j+1; |
|
| 4810 | - } |
|
| 4805 | + if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) { |
|
| 4806 | + $v_found = true; |
|
| 4807 | + } |
|
| 4808 | + if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) { |
|
| 4809 | + $j_start = $j+1; |
|
| 4810 | + } |
|
| 4811 | 4811 | |
| 4812 | - if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) { |
|
| 4813 | - break; |
|
| 4814 | - } |
|
| 4815 | - } |
|
| 4816 | - } |
|
| 4817 | - else { |
|
| 4818 | - $v_found = true; |
|
| 4819 | - } |
|
| 4812 | + if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) { |
|
| 4813 | + break; |
|
| 4814 | + } |
|
| 4815 | + } |
|
| 4816 | + } |
|
| 4817 | + else { |
|
| 4818 | + $v_found = true; |
|
| 4819 | + } |
|
| 4820 | 4820 | |
| 4821 | - // ----- Look for deletion |
|
| 4822 | - if ($v_found) |
|
| 4823 | - { |
|
| 4824 | - unset($v_header_list[$v_nb_extracted]); |
|
| 4825 | - } |
|
| 4826 | - else |
|
| 4827 | - { |
|
| 4828 | - $v_nb_extracted++; |
|
| 4829 | - } |
|
| 4830 | - } |
|
| 4821 | + // ----- Look for deletion |
|
| 4822 | + if ($v_found) |
|
| 4823 | + { |
|
| 4824 | + unset($v_header_list[$v_nb_extracted]); |
|
| 4825 | + } |
|
| 4826 | + else |
|
| 4827 | + { |
|
| 4828 | + $v_nb_extracted++; |
|
| 4829 | + } |
|
| 4830 | + } |
|
| 4831 | 4831 | |
| 4832 | - // ----- Look if something need to be deleted |
|
| 4833 | - if ($v_nb_extracted > 0) { |
|
| 4832 | + // ----- Look if something need to be deleted |
|
| 4833 | + if ($v_nb_extracted > 0) { |
|
| 4834 | 4834 | |
| 4835 | - // ----- Creates a temporay file |
|
| 4836 | - $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp'; |
|
| 4835 | + // ----- Creates a temporay file |
|
| 4836 | + $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp'; |
|
| 4837 | 4837 | |
| 4838 | - // ----- Creates a temporary zip archive |
|
| 4839 | - $v_temp_zip = new PclZip($v_zip_temp_name); |
|
| 4838 | + // ----- Creates a temporary zip archive |
|
| 4839 | + $v_temp_zip = new PclZip($v_zip_temp_name); |
|
| 4840 | 4840 | |
| 4841 | - // ----- Open the temporary zip file in write mode |
|
| 4842 | - if (($v_result = $v_temp_zip->privOpenFd('wb')) != 1) { |
|
| 4843 | - $this->privCloseFd(); |
|
| 4841 | + // ----- Open the temporary zip file in write mode |
|
| 4842 | + if (($v_result = $v_temp_zip->privOpenFd('wb')) != 1) { |
|
| 4843 | + $this->privCloseFd(); |
|
| 4844 | 4844 | |
| 4845 | - // ----- Return |
|
| 4846 | - return $v_result; |
|
| 4847 | - } |
|
| 4845 | + // ----- Return |
|
| 4846 | + return $v_result; |
|
| 4847 | + } |
|
| 4848 | 4848 | |
| 4849 | - // ----- Look which file need to be kept |
|
| 4850 | - for ($i=0; $i<sizeof($v_header_list); $i++) { |
|
| 4849 | + // ----- Look which file need to be kept |
|
| 4850 | + for ($i=0; $i<sizeof($v_header_list); $i++) { |
|
| 4851 | 4851 | |
| 4852 | - // ----- Calculate the position of the header |
|
| 4853 | - @rewind($this->zip_fd); |
|
| 4854 | - if (@fseek($this->zip_fd, $v_header_list[$i]['offset'])) { |
|
| 4855 | - // ----- Close the zip file |
|
| 4856 | - $this->privCloseFd(); |
|
| 4857 | - $v_temp_zip->privCloseFd(); |
|
| 4858 | - @unlink($v_zip_temp_name); |
|
| 4852 | + // ----- Calculate the position of the header |
|
| 4853 | + @rewind($this->zip_fd); |
|
| 4854 | + if (@fseek($this->zip_fd, $v_header_list[$i]['offset'])) { |
|
| 4855 | + // ----- Close the zip file |
|
| 4856 | + $this->privCloseFd(); |
|
| 4857 | + $v_temp_zip->privCloseFd(); |
|
| 4858 | + @unlink($v_zip_temp_name); |
|
| 4859 | 4859 | |
| 4860 | - // ----- Error log |
|
| 4861 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); |
|
| 4860 | + // ----- Error log |
|
| 4861 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); |
|
| 4862 | 4862 | |
| 4863 | - // ----- Return |
|
| 4864 | - return PclZip::errorCode(); |
|
| 4865 | - } |
|
| 4863 | + // ----- Return |
|
| 4864 | + return PclZip::errorCode(); |
|
| 4865 | + } |
|
| 4866 | 4866 | |
| 4867 | - // ----- Read the file header |
|
| 4868 | - $v_local_header = array(); |
|
| 4869 | - if (($v_result = $this->privReadFileHeader($v_local_header)) != 1) { |
|
| 4870 | - // ----- Close the zip file |
|
| 4871 | - $this->privCloseFd(); |
|
| 4872 | - $v_temp_zip->privCloseFd(); |
|
| 4873 | - @unlink($v_zip_temp_name); |
|
| 4867 | + // ----- Read the file header |
|
| 4868 | + $v_local_header = array(); |
|
| 4869 | + if (($v_result = $this->privReadFileHeader($v_local_header)) != 1) { |
|
| 4870 | + // ----- Close the zip file |
|
| 4871 | + $this->privCloseFd(); |
|
| 4872 | + $v_temp_zip->privCloseFd(); |
|
| 4873 | + @unlink($v_zip_temp_name); |
|
| 4874 | 4874 | |
| 4875 | - // ----- Return |
|
| 4876 | - return $v_result; |
|
| 4877 | - } |
|
| 4875 | + // ----- Return |
|
| 4876 | + return $v_result; |
|
| 4877 | + } |
|
| 4878 | 4878 | |
| 4879 | - // ----- Check that local file header is same as central file header |
|
| 4880 | - if ($this->privCheckFileHeaders($v_local_header, |
|
| 4881 | - $v_header_list[$i]) != 1) { |
|
| 4882 | - // TBC |
|
| 4883 | - } |
|
| 4884 | - unset($v_local_header); |
|
| 4885 | - |
|
| 4886 | - // ----- Write the file header |
|
| 4887 | - if (($v_result = $v_temp_zip->privWriteFileHeader($v_header_list[$i])) != 1) { |
|
| 4888 | - // ----- Close the zip file |
|
| 4889 | - $this->privCloseFd(); |
|
| 4890 | - $v_temp_zip->privCloseFd(); |
|
| 4891 | - @unlink($v_zip_temp_name); |
|
| 4892 | - |
|
| 4893 | - // ----- Return |
|
| 4894 | - return $v_result; |
|
| 4895 | - } |
|
| 4896 | - |
|
| 4897 | - // ----- Read/write the data block |
|
| 4898 | - if (($v_result = PclZipUtilCopyBlock($this->zip_fd, $v_temp_zip->zip_fd, $v_header_list[$i]['compressed_size'])) != 1) { |
|
| 4899 | - // ----- Close the zip file |
|
| 4900 | - $this->privCloseFd(); |
|
| 4901 | - $v_temp_zip->privCloseFd(); |
|
| 4902 | - @unlink($v_zip_temp_name); |
|
| 4903 | - |
|
| 4904 | - // ----- Return |
|
| 4905 | - return $v_result; |
|
| 4906 | - } |
|
| 4907 | - } |
|
| 4908 | - |
|
| 4909 | - // ----- Store the offset of the central dir |
|
| 4910 | - $v_offset = @ftell($v_temp_zip->zip_fd); |
|
| 4911 | - |
|
| 4912 | - // ----- Re-Create the Central Dir files header |
|
| 4913 | - for ($i=0; $i<sizeof($v_header_list); $i++) { |
|
| 4914 | - // ----- Create the file header |
|
| 4915 | - if (($v_result = $v_temp_zip->privWriteCentralFileHeader($v_header_list[$i])) != 1) { |
|
| 4916 | - $v_temp_zip->privCloseFd(); |
|
| 4917 | - $this->privCloseFd(); |
|
| 4918 | - @unlink($v_zip_temp_name); |
|
| 4919 | - |
|
| 4920 | - // ----- Return |
|
| 4921 | - return $v_result; |
|
| 4922 | - } |
|
| 4923 | - |
|
| 4924 | - // ----- Transform the header to a 'usable' info |
|
| 4925 | - $v_temp_zip->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]); |
|
| 4926 | - } |
|
| 4927 | - |
|
| 4928 | - |
|
| 4929 | - // ----- Zip file comment |
|
| 4930 | - $v_comment = ''; |
|
| 4931 | - if (isset($p_options[PCLZIP_OPT_COMMENT])) { |
|
| 4932 | - $v_comment = $p_options[PCLZIP_OPT_COMMENT]; |
|
| 4933 | - } |
|
| 4934 | - |
|
| 4935 | - // ----- Calculate the size of the central header |
|
| 4936 | - $v_size = @ftell($v_temp_zip->zip_fd)-$v_offset; |
|
| 4937 | - |
|
| 4938 | - // ----- Create the central dir footer |
|
| 4939 | - if (($v_result = $v_temp_zip->privWriteCentralHeader(sizeof($v_header_list), $v_size, $v_offset, $v_comment)) != 1) { |
|
| 4940 | - // ----- Reset the file list |
|
| 4941 | - unset($v_header_list); |
|
| 4942 | - $v_temp_zip->privCloseFd(); |
|
| 4943 | - $this->privCloseFd(); |
|
| 4944 | - @unlink($v_zip_temp_name); |
|
| 4945 | - |
|
| 4946 | - // ----- Return |
|
| 4947 | - return $v_result; |
|
| 4948 | - } |
|
| 4949 | - |
|
| 4950 | - // ----- Close |
|
| 4951 | - $v_temp_zip->privCloseFd(); |
|
| 4952 | - $this->privCloseFd(); |
|
| 4953 | - |
|
| 4954 | - // ----- Delete the zip file |
|
| 4955 | - // TBC : I should test the result ... |
|
| 4956 | - @unlink($this->zipname); |
|
| 4957 | - |
|
| 4958 | - // ----- Rename the temporary file |
|
| 4959 | - // TBC : I should test the result ... |
|
| 4960 | - //@rename($v_zip_temp_name, $this->zipname); |
|
| 4961 | - PclZipUtilRename($v_zip_temp_name, $this->zipname); |
|
| 4879 | + // ----- Check that local file header is same as central file header |
|
| 4880 | + if ($this->privCheckFileHeaders($v_local_header, |
|
| 4881 | + $v_header_list[$i]) != 1) { |
|
| 4882 | + // TBC |
|
| 4883 | + } |
|
| 4884 | + unset($v_local_header); |
|
| 4885 | + |
|
| 4886 | + // ----- Write the file header |
|
| 4887 | + if (($v_result = $v_temp_zip->privWriteFileHeader($v_header_list[$i])) != 1) { |
|
| 4888 | + // ----- Close the zip file |
|
| 4889 | + $this->privCloseFd(); |
|
| 4890 | + $v_temp_zip->privCloseFd(); |
|
| 4891 | + @unlink($v_zip_temp_name); |
|
| 4892 | + |
|
| 4893 | + // ----- Return |
|
| 4894 | + return $v_result; |
|
| 4895 | + } |
|
| 4896 | + |
|
| 4897 | + // ----- Read/write the data block |
|
| 4898 | + if (($v_result = PclZipUtilCopyBlock($this->zip_fd, $v_temp_zip->zip_fd, $v_header_list[$i]['compressed_size'])) != 1) { |
|
| 4899 | + // ----- Close the zip file |
|
| 4900 | + $this->privCloseFd(); |
|
| 4901 | + $v_temp_zip->privCloseFd(); |
|
| 4902 | + @unlink($v_zip_temp_name); |
|
| 4903 | + |
|
| 4904 | + // ----- Return |
|
| 4905 | + return $v_result; |
|
| 4906 | + } |
|
| 4907 | + } |
|
| 4908 | + |
|
| 4909 | + // ----- Store the offset of the central dir |
|
| 4910 | + $v_offset = @ftell($v_temp_zip->zip_fd); |
|
| 4911 | + |
|
| 4912 | + // ----- Re-Create the Central Dir files header |
|
| 4913 | + for ($i=0; $i<sizeof($v_header_list); $i++) { |
|
| 4914 | + // ----- Create the file header |
|
| 4915 | + if (($v_result = $v_temp_zip->privWriteCentralFileHeader($v_header_list[$i])) != 1) { |
|
| 4916 | + $v_temp_zip->privCloseFd(); |
|
| 4917 | + $this->privCloseFd(); |
|
| 4918 | + @unlink($v_zip_temp_name); |
|
| 4919 | + |
|
| 4920 | + // ----- Return |
|
| 4921 | + return $v_result; |
|
| 4922 | + } |
|
| 4923 | + |
|
| 4924 | + // ----- Transform the header to a 'usable' info |
|
| 4925 | + $v_temp_zip->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]); |
|
| 4926 | + } |
|
| 4927 | + |
|
| 4928 | + |
|
| 4929 | + // ----- Zip file comment |
|
| 4930 | + $v_comment = ''; |
|
| 4931 | + if (isset($p_options[PCLZIP_OPT_COMMENT])) { |
|
| 4932 | + $v_comment = $p_options[PCLZIP_OPT_COMMENT]; |
|
| 4933 | + } |
|
| 4934 | + |
|
| 4935 | + // ----- Calculate the size of the central header |
|
| 4936 | + $v_size = @ftell($v_temp_zip->zip_fd)-$v_offset; |
|
| 4937 | + |
|
| 4938 | + // ----- Create the central dir footer |
|
| 4939 | + if (($v_result = $v_temp_zip->privWriteCentralHeader(sizeof($v_header_list), $v_size, $v_offset, $v_comment)) != 1) { |
|
| 4940 | + // ----- Reset the file list |
|
| 4941 | + unset($v_header_list); |
|
| 4942 | + $v_temp_zip->privCloseFd(); |
|
| 4943 | + $this->privCloseFd(); |
|
| 4944 | + @unlink($v_zip_temp_name); |
|
| 4945 | + |
|
| 4946 | + // ----- Return |
|
| 4947 | + return $v_result; |
|
| 4948 | + } |
|
| 4949 | + |
|
| 4950 | + // ----- Close |
|
| 4951 | + $v_temp_zip->privCloseFd(); |
|
| 4952 | + $this->privCloseFd(); |
|
| 4953 | + |
|
| 4954 | + // ----- Delete the zip file |
|
| 4955 | + // TBC : I should test the result ... |
|
| 4956 | + @unlink($this->zipname); |
|
| 4957 | + |
|
| 4958 | + // ----- Rename the temporary file |
|
| 4959 | + // TBC : I should test the result ... |
|
| 4960 | + //@rename($v_zip_temp_name, $this->zipname); |
|
| 4961 | + PclZipUtilRename($v_zip_temp_name, $this->zipname); |
|
| 4962 | 4962 | |
| 4963 | - // ----- Destroy the temporary archive |
|
| 4964 | - unset($v_temp_zip); |
|
| 4965 | - } |
|
| 4963 | + // ----- Destroy the temporary archive |
|
| 4964 | + unset($v_temp_zip); |
|
| 4965 | + } |
|
| 4966 | 4966 | |
| 4967 | - // ----- Remove every files : reset the file |
|
| 4968 | - else if ($v_central_dir['entries'] != 0) { |
|
| 4969 | - $this->privCloseFd(); |
|
| 4967 | + // ----- Remove every files : reset the file |
|
| 4968 | + else if ($v_central_dir['entries'] != 0) { |
|
| 4969 | + $this->privCloseFd(); |
|
| 4970 | 4970 | |
| 4971 | - if (($v_result = $this->privOpenFd('wb')) != 1) { |
|
| 4972 | - return $v_result; |
|
| 4973 | - } |
|
| 4971 | + if (($v_result = $this->privOpenFd('wb')) != 1) { |
|
| 4972 | + return $v_result; |
|
| 4973 | + } |
|
| 4974 | 4974 | |
| 4975 | - if (($v_result = $this->privWriteCentralHeader(0, 0, 0, '')) != 1) { |
|
| 4976 | - return $v_result; |
|
| 4977 | - } |
|
| 4975 | + if (($v_result = $this->privWriteCentralHeader(0, 0, 0, '')) != 1) { |
|
| 4976 | + return $v_result; |
|
| 4977 | + } |
|
| 4978 | 4978 | |
| 4979 | - $this->privCloseFd(); |
|
| 4980 | - } |
|
| 4979 | + $this->privCloseFd(); |
|
| 4980 | + } |
|
| 4981 | 4981 | |
| 4982 | - // ----- Return |
|
| 4983 | - return $v_result; |
|
| 4982 | + // ----- Return |
|
| 4983 | + return $v_result; |
|
| 4984 | 4984 | } |
| 4985 | 4985 | // -------------------------------------------------------------------------------- |
| 4986 | 4986 | |
@@ -4997,49 +4997,49 @@ discard block |
||
| 4997 | 4997 | // -------------------------------------------------------------------------------- |
| 4998 | 4998 | function privDirCheck($p_dir, $p_is_dir=false) |
| 4999 | 4999 | { |
| 5000 | - $v_result = 1; |
|
| 5000 | + $v_result = 1; |
|
| 5001 | 5001 | |
| 5002 | 5002 | |
| 5003 | - // ----- Remove the final '/' |
|
| 5004 | - if (($p_is_dir) && (substr($p_dir, -1)=='/')) |
|
| 5005 | - { |
|
| 5006 | - $p_dir = substr($p_dir, 0, strlen($p_dir)-1); |
|
| 5007 | - } |
|
| 5003 | + // ----- Remove the final '/' |
|
| 5004 | + if (($p_is_dir) && (substr($p_dir, -1)=='/')) |
|
| 5005 | + { |
|
| 5006 | + $p_dir = substr($p_dir, 0, strlen($p_dir)-1); |
|
| 5007 | + } |
|
| 5008 | 5008 | |
| 5009 | - // ----- Check the directory availability |
|
| 5010 | - if ((is_dir($p_dir)) || ($p_dir == "")) |
|
| 5011 | - { |
|
| 5012 | - return 1; |
|
| 5013 | - } |
|
| 5009 | + // ----- Check the directory availability |
|
| 5010 | + if ((is_dir($p_dir)) || ($p_dir == "")) |
|
| 5011 | + { |
|
| 5012 | + return 1; |
|
| 5013 | + } |
|
| 5014 | 5014 | |
| 5015 | - // ----- Extract parent directory |
|
| 5016 | - $p_parent_dir = dirname($p_dir); |
|
| 5017 | - |
|
| 5018 | - // ----- Just a check |
|
| 5019 | - if ($p_parent_dir != $p_dir) |
|
| 5020 | - { |
|
| 5021 | - // ----- Look for parent directory |
|
| 5022 | - if ($p_parent_dir != "") |
|
| 5023 | - { |
|
| 5024 | - if (($v_result = $this->privDirCheck($p_parent_dir)) != 1) |
|
| 5025 | - { |
|
| 5026 | - return $v_result; |
|
| 5027 | - } |
|
| 5028 | - } |
|
| 5029 | - } |
|
| 5015 | + // ----- Extract parent directory |
|
| 5016 | + $p_parent_dir = dirname($p_dir); |
|
| 5017 | + |
|
| 5018 | + // ----- Just a check |
|
| 5019 | + if ($p_parent_dir != $p_dir) |
|
| 5020 | + { |
|
| 5021 | + // ----- Look for parent directory |
|
| 5022 | + if ($p_parent_dir != "") |
|
| 5023 | + { |
|
| 5024 | + if (($v_result = $this->privDirCheck($p_parent_dir)) != 1) |
|
| 5025 | + { |
|
| 5026 | + return $v_result; |
|
| 5027 | + } |
|
| 5028 | + } |
|
| 5029 | + } |
|
| 5030 | 5030 | |
| 5031 | - // ----- Create the directory |
|
| 5032 | - if (!@mkdir($p_dir, 0777)) |
|
| 5033 | - { |
|
| 5034 | - // ----- Error log |
|
| 5035 | - PclZip::privErrorLog(PCLZIP_ERR_DIR_CREATE_FAIL, "Unable to create directory '$p_dir'"); |
|
| 5031 | + // ----- Create the directory |
|
| 5032 | + if (!@mkdir($p_dir, 0777)) |
|
| 5033 | + { |
|
| 5034 | + // ----- Error log |
|
| 5035 | + PclZip::privErrorLog(PCLZIP_ERR_DIR_CREATE_FAIL, "Unable to create directory '$p_dir'"); |
|
| 5036 | 5036 | |
| 5037 | - // ----- Return |
|
| 5038 | - return PclZip::errorCode(); |
|
| 5039 | - } |
|
| 5037 | + // ----- Return |
|
| 5038 | + return PclZip::errorCode(); |
|
| 5039 | + } |
|
| 5040 | 5040 | |
| 5041 | - // ----- Return |
|
| 5042 | - return $v_result; |
|
| 5041 | + // ----- Return |
|
| 5042 | + return $v_result; |
|
| 5043 | 5043 | } |
| 5044 | 5044 | // -------------------------------------------------------------------------------- |
| 5045 | 5045 | |
@@ -5052,180 +5052,180 @@ discard block |
||
| 5052 | 5052 | // -------------------------------------------------------------------------------- |
| 5053 | 5053 | function privMerge(&$p_archive_to_add) |
| 5054 | 5054 | { |
| 5055 | - $v_result=1; |
|
| 5055 | + $v_result=1; |
|
| 5056 | 5056 | |
| 5057 | - // ----- Look if the archive_to_add exists |
|
| 5058 | - if (!is_file($p_archive_to_add->zipname)) |
|
| 5059 | - { |
|
| 5057 | + // ----- Look if the archive_to_add exists |
|
| 5058 | + if (!is_file($p_archive_to_add->zipname)) |
|
| 5059 | + { |
|
| 5060 | 5060 | |
| 5061 | - // ----- Nothing to merge, so merge is a success |
|
| 5062 | - $v_result = 1; |
|
| 5061 | + // ----- Nothing to merge, so merge is a success |
|
| 5062 | + $v_result = 1; |
|
| 5063 | 5063 | |
| 5064 | - // ----- Return |
|
| 5065 | - return $v_result; |
|
| 5066 | - } |
|
| 5064 | + // ----- Return |
|
| 5065 | + return $v_result; |
|
| 5066 | + } |
|
| 5067 | 5067 | |
| 5068 | - // ----- Look if the archive exists |
|
| 5069 | - if (!is_file($this->zipname)) |
|
| 5070 | - { |
|
| 5068 | + // ----- Look if the archive exists |
|
| 5069 | + if (!is_file($this->zipname)) |
|
| 5070 | + { |
|
| 5071 | 5071 | |
| 5072 | - // ----- Do a duplicate |
|
| 5073 | - $v_result = $this->privDuplicate($p_archive_to_add->zipname); |
|
| 5072 | + // ----- Do a duplicate |
|
| 5073 | + $v_result = $this->privDuplicate($p_archive_to_add->zipname); |
|
| 5074 | 5074 | |
| 5075 | - // ----- Return |
|
| 5076 | - return $v_result; |
|
| 5077 | - } |
|
| 5075 | + // ----- Return |
|
| 5076 | + return $v_result; |
|
| 5077 | + } |
|
| 5078 | 5078 | |
| 5079 | - // ----- Open the zip file |
|
| 5080 | - if (($v_result=$this->privOpenFd('rb')) != 1) |
|
| 5081 | - { |
|
| 5082 | - // ----- Return |
|
| 5083 | - return $v_result; |
|
| 5084 | - } |
|
| 5079 | + // ----- Open the zip file |
|
| 5080 | + if (($v_result=$this->privOpenFd('rb')) != 1) |
|
| 5081 | + { |
|
| 5082 | + // ----- Return |
|
| 5083 | + return $v_result; |
|
| 5084 | + } |
|
| 5085 | 5085 | |
| 5086 | - // ----- Read the central directory informations |
|
| 5087 | - $v_central_dir = array(); |
|
| 5088 | - if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) |
|
| 5089 | - { |
|
| 5090 | - $this->privCloseFd(); |
|
| 5091 | - return $v_result; |
|
| 5092 | - } |
|
| 5086 | + // ----- Read the central directory informations |
|
| 5087 | + $v_central_dir = array(); |
|
| 5088 | + if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) |
|
| 5089 | + { |
|
| 5090 | + $this->privCloseFd(); |
|
| 5091 | + return $v_result; |
|
| 5092 | + } |
|
| 5093 | 5093 | |
| 5094 | - // ----- Go to beginning of File |
|
| 5095 | - @rewind($this->zip_fd); |
|
| 5094 | + // ----- Go to beginning of File |
|
| 5095 | + @rewind($this->zip_fd); |
|
| 5096 | 5096 | |
| 5097 | - // ----- Open the archive_to_add file |
|
| 5098 | - if (($v_result=$p_archive_to_add->privOpenFd('rb')) != 1) |
|
| 5099 | - { |
|
| 5100 | - $this->privCloseFd(); |
|
| 5097 | + // ----- Open the archive_to_add file |
|
| 5098 | + if (($v_result=$p_archive_to_add->privOpenFd('rb')) != 1) |
|
| 5099 | + { |
|
| 5100 | + $this->privCloseFd(); |
|
| 5101 | 5101 | |
| 5102 | - // ----- Return |
|
| 5103 | - return $v_result; |
|
| 5104 | - } |
|
| 5102 | + // ----- Return |
|
| 5103 | + return $v_result; |
|
| 5104 | + } |
|
| 5105 | 5105 | |
| 5106 | - // ----- Read the central directory informations |
|
| 5107 | - $v_central_dir_to_add = array(); |
|
| 5108 | - if (($v_result = $p_archive_to_add->privReadEndCentralDir($v_central_dir_to_add)) != 1) |
|
| 5109 | - { |
|
| 5110 | - $this->privCloseFd(); |
|
| 5111 | - $p_archive_to_add->privCloseFd(); |
|
| 5106 | + // ----- Read the central directory informations |
|
| 5107 | + $v_central_dir_to_add = array(); |
|
| 5108 | + if (($v_result = $p_archive_to_add->privReadEndCentralDir($v_central_dir_to_add)) != 1) |
|
| 5109 | + { |
|
| 5110 | + $this->privCloseFd(); |
|
| 5111 | + $p_archive_to_add->privCloseFd(); |
|
| 5112 | 5112 | |
| 5113 | - return $v_result; |
|
| 5114 | - } |
|
| 5113 | + return $v_result; |
|
| 5114 | + } |
|
| 5115 | 5115 | |
| 5116 | - // ----- Go to beginning of File |
|
| 5117 | - @rewind($p_archive_to_add->zip_fd); |
|
| 5116 | + // ----- Go to beginning of File |
|
| 5117 | + @rewind($p_archive_to_add->zip_fd); |
|
| 5118 | 5118 | |
| 5119 | - // ----- Creates a temporay file |
|
| 5120 | - $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp'; |
|
| 5119 | + // ----- Creates a temporay file |
|
| 5120 | + $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp'; |
|
| 5121 | 5121 | |
| 5122 | - // ----- Open the temporary file in write mode |
|
| 5123 | - if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0) |
|
| 5124 | - { |
|
| 5125 | - $this->privCloseFd(); |
|
| 5126 | - $p_archive_to_add->privCloseFd(); |
|
| 5122 | + // ----- Open the temporary file in write mode |
|
| 5123 | + if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0) |
|
| 5124 | + { |
|
| 5125 | + $this->privCloseFd(); |
|
| 5126 | + $p_archive_to_add->privCloseFd(); |
|
| 5127 | 5127 | |
| 5128 | - PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode'); |
|
| 5128 | + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode'); |
|
| 5129 | 5129 | |
| 5130 | - // ----- Return |
|
| 5131 | - return PclZip::errorCode(); |
|
| 5132 | - } |
|
| 5130 | + // ----- Return |
|
| 5131 | + return PclZip::errorCode(); |
|
| 5132 | + } |
|
| 5133 | 5133 | |
| 5134 | - // ----- Copy the files from the archive to the temporary file |
|
| 5135 | - // TBC : Here I should better append the file and go back to erase the central dir |
|
| 5136 | - $v_size = $v_central_dir['offset']; |
|
| 5137 | - while ($v_size != 0) |
|
| 5138 | - { |
|
| 5139 | - $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 5140 | - $v_buffer = fread($this->zip_fd, $v_read_size); |
|
| 5141 | - @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); |
|
| 5142 | - $v_size -= $v_read_size; |
|
| 5143 | - } |
|
| 5134 | + // ----- Copy the files from the archive to the temporary file |
|
| 5135 | + // TBC : Here I should better append the file and go back to erase the central dir |
|
| 5136 | + $v_size = $v_central_dir['offset']; |
|
| 5137 | + while ($v_size != 0) |
|
| 5138 | + { |
|
| 5139 | + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 5140 | + $v_buffer = fread($this->zip_fd, $v_read_size); |
|
| 5141 | + @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); |
|
| 5142 | + $v_size -= $v_read_size; |
|
| 5143 | + } |
|
| 5144 | 5144 | |
| 5145 | - // ----- Copy the files from the archive_to_add into the temporary file |
|
| 5146 | - $v_size = $v_central_dir_to_add['offset']; |
|
| 5147 | - while ($v_size != 0) |
|
| 5148 | - { |
|
| 5149 | - $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 5150 | - $v_buffer = fread($p_archive_to_add->zip_fd, $v_read_size); |
|
| 5151 | - @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); |
|
| 5152 | - $v_size -= $v_read_size; |
|
| 5153 | - } |
|
| 5145 | + // ----- Copy the files from the archive_to_add into the temporary file |
|
| 5146 | + $v_size = $v_central_dir_to_add['offset']; |
|
| 5147 | + while ($v_size != 0) |
|
| 5148 | + { |
|
| 5149 | + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 5150 | + $v_buffer = fread($p_archive_to_add->zip_fd, $v_read_size); |
|
| 5151 | + @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); |
|
| 5152 | + $v_size -= $v_read_size; |
|
| 5153 | + } |
|
| 5154 | 5154 | |
| 5155 | - // ----- Store the offset of the central dir |
|
| 5156 | - $v_offset = @ftell($v_zip_temp_fd); |
|
| 5157 | - |
|
| 5158 | - // ----- Copy the block of file headers from the old archive |
|
| 5159 | - $v_size = $v_central_dir['size']; |
|
| 5160 | - while ($v_size != 0) |
|
| 5161 | - { |
|
| 5162 | - $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 5163 | - $v_buffer = @fread($this->zip_fd, $v_read_size); |
|
| 5164 | - @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); |
|
| 5165 | - $v_size -= $v_read_size; |
|
| 5166 | - } |
|
| 5155 | + // ----- Store the offset of the central dir |
|
| 5156 | + $v_offset = @ftell($v_zip_temp_fd); |
|
| 5157 | + |
|
| 5158 | + // ----- Copy the block of file headers from the old archive |
|
| 5159 | + $v_size = $v_central_dir['size']; |
|
| 5160 | + while ($v_size != 0) |
|
| 5161 | + { |
|
| 5162 | + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 5163 | + $v_buffer = @fread($this->zip_fd, $v_read_size); |
|
| 5164 | + @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); |
|
| 5165 | + $v_size -= $v_read_size; |
|
| 5166 | + } |
|
| 5167 | 5167 | |
| 5168 | - // ----- Copy the block of file headers from the archive_to_add |
|
| 5169 | - $v_size = $v_central_dir_to_add['size']; |
|
| 5170 | - while ($v_size != 0) |
|
| 5171 | - { |
|
| 5172 | - $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 5173 | - $v_buffer = @fread($p_archive_to_add->zip_fd, $v_read_size); |
|
| 5174 | - @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); |
|
| 5175 | - $v_size -= $v_read_size; |
|
| 5176 | - } |
|
| 5168 | + // ----- Copy the block of file headers from the archive_to_add |
|
| 5169 | + $v_size = $v_central_dir_to_add['size']; |
|
| 5170 | + while ($v_size != 0) |
|
| 5171 | + { |
|
| 5172 | + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 5173 | + $v_buffer = @fread($p_archive_to_add->zip_fd, $v_read_size); |
|
| 5174 | + @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); |
|
| 5175 | + $v_size -= $v_read_size; |
|
| 5176 | + } |
|
| 5177 | 5177 | |
| 5178 | - // ----- Merge the file comments |
|
| 5179 | - $v_comment = $v_central_dir['comment'].' '.$v_central_dir_to_add['comment']; |
|
| 5178 | + // ----- Merge the file comments |
|
| 5179 | + $v_comment = $v_central_dir['comment'].' '.$v_central_dir_to_add['comment']; |
|
| 5180 | 5180 | |
| 5181 | - // ----- Calculate the size of the (new) central header |
|
| 5182 | - $v_size = @ftell($v_zip_temp_fd)-$v_offset; |
|
| 5181 | + // ----- Calculate the size of the (new) central header |
|
| 5182 | + $v_size = @ftell($v_zip_temp_fd)-$v_offset; |
|
| 5183 | 5183 | |
| 5184 | - // ----- Swap the file descriptor |
|
| 5185 | - // Here is a trick : I swap the temporary fd with the zip fd, in order to use |
|
| 5186 | - // the following methods on the temporary fil and not the real archive fd |
|
| 5187 | - $v_swap = $this->zip_fd; |
|
| 5188 | - $this->zip_fd = $v_zip_temp_fd; |
|
| 5189 | - $v_zip_temp_fd = $v_swap; |
|
| 5184 | + // ----- Swap the file descriptor |
|
| 5185 | + // Here is a trick : I swap the temporary fd with the zip fd, in order to use |
|
| 5186 | + // the following methods on the temporary fil and not the real archive fd |
|
| 5187 | + $v_swap = $this->zip_fd; |
|
| 5188 | + $this->zip_fd = $v_zip_temp_fd; |
|
| 5189 | + $v_zip_temp_fd = $v_swap; |
|
| 5190 | 5190 | |
| 5191 | - // ----- Create the central dir footer |
|
| 5192 | - if (($v_result = $this->privWriteCentralHeader($v_central_dir['entries']+$v_central_dir_to_add['entries'], $v_size, $v_offset, $v_comment)) != 1) |
|
| 5193 | - { |
|
| 5194 | - $this->privCloseFd(); |
|
| 5195 | - $p_archive_to_add->privCloseFd(); |
|
| 5196 | - @fclose($v_zip_temp_fd); |
|
| 5197 | - $this->zip_fd = null; |
|
| 5191 | + // ----- Create the central dir footer |
|
| 5192 | + if (($v_result = $this->privWriteCentralHeader($v_central_dir['entries']+$v_central_dir_to_add['entries'], $v_size, $v_offset, $v_comment)) != 1) |
|
| 5193 | + { |
|
| 5194 | + $this->privCloseFd(); |
|
| 5195 | + $p_archive_to_add->privCloseFd(); |
|
| 5196 | + @fclose($v_zip_temp_fd); |
|
| 5197 | + $this->zip_fd = null; |
|
| 5198 | 5198 | |
| 5199 | - // ----- Reset the file list |
|
| 5200 | - unset($v_header_list); |
|
| 5199 | + // ----- Reset the file list |
|
| 5200 | + unset($v_header_list); |
|
| 5201 | 5201 | |
| 5202 | - // ----- Return |
|
| 5203 | - return $v_result; |
|
| 5204 | - } |
|
| 5202 | + // ----- Return |
|
| 5203 | + return $v_result; |
|
| 5204 | + } |
|
| 5205 | 5205 | |
| 5206 | - // ----- Swap back the file descriptor |
|
| 5207 | - $v_swap = $this->zip_fd; |
|
| 5208 | - $this->zip_fd = $v_zip_temp_fd; |
|
| 5209 | - $v_zip_temp_fd = $v_swap; |
|
| 5206 | + // ----- Swap back the file descriptor |
|
| 5207 | + $v_swap = $this->zip_fd; |
|
| 5208 | + $this->zip_fd = $v_zip_temp_fd; |
|
| 5209 | + $v_zip_temp_fd = $v_swap; |
|
| 5210 | 5210 | |
| 5211 | - // ----- Close |
|
| 5212 | - $this->privCloseFd(); |
|
| 5213 | - $p_archive_to_add->privCloseFd(); |
|
| 5211 | + // ----- Close |
|
| 5212 | + $this->privCloseFd(); |
|
| 5213 | + $p_archive_to_add->privCloseFd(); |
|
| 5214 | 5214 | |
| 5215 | - // ----- Close the temporary file |
|
| 5216 | - @fclose($v_zip_temp_fd); |
|
| 5215 | + // ----- Close the temporary file |
|
| 5216 | + @fclose($v_zip_temp_fd); |
|
| 5217 | 5217 | |
| 5218 | - // ----- Delete the zip file |
|
| 5219 | - // TBC : I should test the result ... |
|
| 5220 | - @unlink($this->zipname); |
|
| 5218 | + // ----- Delete the zip file |
|
| 5219 | + // TBC : I should test the result ... |
|
| 5220 | + @unlink($this->zipname); |
|
| 5221 | 5221 | |
| 5222 | - // ----- Rename the temporary file |
|
| 5223 | - // TBC : I should test the result ... |
|
| 5224 | - //@rename($v_zip_temp_name, $this->zipname); |
|
| 5225 | - PclZipUtilRename($v_zip_temp_name, $this->zipname); |
|
| 5222 | + // ----- Rename the temporary file |
|
| 5223 | + // TBC : I should test the result ... |
|
| 5224 | + //@rename($v_zip_temp_name, $this->zipname); |
|
| 5225 | + PclZipUtilRename($v_zip_temp_name, $this->zipname); |
|
| 5226 | 5226 | |
| 5227 | - // ----- Return |
|
| 5228 | - return $v_result; |
|
| 5227 | + // ----- Return |
|
| 5228 | + return $v_result; |
|
| 5229 | 5229 | } |
| 5230 | 5230 | // -------------------------------------------------------------------------------- |
| 5231 | 5231 | |
@@ -5237,56 +5237,56 @@ discard block |
||
| 5237 | 5237 | // -------------------------------------------------------------------------------- |
| 5238 | 5238 | function privDuplicate($p_archive_filename) |
| 5239 | 5239 | { |
| 5240 | - $v_result=1; |
|
| 5240 | + $v_result=1; |
|
| 5241 | 5241 | |
| 5242 | - // ----- Look if the $p_archive_filename exists |
|
| 5243 | - if (!is_file($p_archive_filename)) |
|
| 5244 | - { |
|
| 5242 | + // ----- Look if the $p_archive_filename exists |
|
| 5243 | + if (!is_file($p_archive_filename)) |
|
| 5244 | + { |
|
| 5245 | 5245 | |
| 5246 | - // ----- Nothing to duplicate, so duplicate is a success. |
|
| 5247 | - $v_result = 1; |
|
| 5246 | + // ----- Nothing to duplicate, so duplicate is a success. |
|
| 5247 | + $v_result = 1; |
|
| 5248 | 5248 | |
| 5249 | - // ----- Return |
|
| 5250 | - return $v_result; |
|
| 5251 | - } |
|
| 5249 | + // ----- Return |
|
| 5250 | + return $v_result; |
|
| 5251 | + } |
|
| 5252 | 5252 | |
| 5253 | - // ----- Open the zip file |
|
| 5254 | - if (($v_result=$this->privOpenFd('wb')) != 1) |
|
| 5255 | - { |
|
| 5256 | - // ----- Return |
|
| 5257 | - return $v_result; |
|
| 5258 | - } |
|
| 5253 | + // ----- Open the zip file |
|
| 5254 | + if (($v_result=$this->privOpenFd('wb')) != 1) |
|
| 5255 | + { |
|
| 5256 | + // ----- Return |
|
| 5257 | + return $v_result; |
|
| 5258 | + } |
|
| 5259 | 5259 | |
| 5260 | - // ----- Open the temporary file in write mode |
|
| 5261 | - if (($v_zip_temp_fd = @fopen($p_archive_filename, 'rb')) == 0) |
|
| 5262 | - { |
|
| 5263 | - $this->privCloseFd(); |
|
| 5260 | + // ----- Open the temporary file in write mode |
|
| 5261 | + if (($v_zip_temp_fd = @fopen($p_archive_filename, 'rb')) == 0) |
|
| 5262 | + { |
|
| 5263 | + $this->privCloseFd(); |
|
| 5264 | 5264 | |
| 5265 | - PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive file \''.$p_archive_filename.'\' in binary write mode'); |
|
| 5265 | + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive file \''.$p_archive_filename.'\' in binary write mode'); |
|
| 5266 | 5266 | |
| 5267 | - // ----- Return |
|
| 5268 | - return PclZip::errorCode(); |
|
| 5269 | - } |
|
| 5267 | + // ----- Return |
|
| 5268 | + return PclZip::errorCode(); |
|
| 5269 | + } |
|
| 5270 | 5270 | |
| 5271 | - // ----- Copy the files from the archive to the temporary file |
|
| 5272 | - // TBC : Here I should better append the file and go back to erase the central dir |
|
| 5273 | - $v_size = filesize($p_archive_filename); |
|
| 5274 | - while ($v_size != 0) |
|
| 5275 | - { |
|
| 5276 | - $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 5277 | - $v_buffer = fread($v_zip_temp_fd, $v_read_size); |
|
| 5278 | - @fwrite($this->zip_fd, $v_buffer, $v_read_size); |
|
| 5279 | - $v_size -= $v_read_size; |
|
| 5280 | - } |
|
| 5271 | + // ----- Copy the files from the archive to the temporary file |
|
| 5272 | + // TBC : Here I should better append the file and go back to erase the central dir |
|
| 5273 | + $v_size = filesize($p_archive_filename); |
|
| 5274 | + while ($v_size != 0) |
|
| 5275 | + { |
|
| 5276 | + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 5277 | + $v_buffer = fread($v_zip_temp_fd, $v_read_size); |
|
| 5278 | + @fwrite($this->zip_fd, $v_buffer, $v_read_size); |
|
| 5279 | + $v_size -= $v_read_size; |
|
| 5280 | + } |
|
| 5281 | 5281 | |
| 5282 | - // ----- Close |
|
| 5283 | - $this->privCloseFd(); |
|
| 5282 | + // ----- Close |
|
| 5283 | + $this->privCloseFd(); |
|
| 5284 | 5284 | |
| 5285 | - // ----- Close the temporary file |
|
| 5286 | - @fclose($v_zip_temp_fd); |
|
| 5285 | + // ----- Close the temporary file |
|
| 5286 | + @fclose($v_zip_temp_fd); |
|
| 5287 | 5287 | |
| 5288 | - // ----- Return |
|
| 5289 | - return $v_result; |
|
| 5288 | + // ----- Return |
|
| 5289 | + return $v_result; |
|
| 5290 | 5290 | } |
| 5291 | 5291 | // -------------------------------------------------------------------------------- |
| 5292 | 5292 | |
@@ -5297,13 +5297,13 @@ discard block |
||
| 5297 | 5297 | // -------------------------------------------------------------------------------- |
| 5298 | 5298 | function privErrorLog($p_error_code=0, $p_error_string='') |
| 5299 | 5299 | { |
| 5300 | - if (PCLZIP_ERROR_EXTERNAL == 1) { |
|
| 5301 | - PclError($p_error_code, $p_error_string); |
|
| 5302 | - } |
|
| 5303 | - else { |
|
| 5304 | - $this->error_code = $p_error_code; |
|
| 5305 | - $this->error_string = $p_error_string; |
|
| 5306 | - } |
|
| 5300 | + if (PCLZIP_ERROR_EXTERNAL == 1) { |
|
| 5301 | + PclError($p_error_code, $p_error_string); |
|
| 5302 | + } |
|
| 5303 | + else { |
|
| 5304 | + $this->error_code = $p_error_code; |
|
| 5305 | + $this->error_string = $p_error_string; |
|
| 5306 | + } |
|
| 5307 | 5307 | } |
| 5308 | 5308 | // -------------------------------------------------------------------------------- |
| 5309 | 5309 | |
@@ -5314,13 +5314,13 @@ discard block |
||
| 5314 | 5314 | // -------------------------------------------------------------------------------- |
| 5315 | 5315 | function privErrorReset() |
| 5316 | 5316 | { |
| 5317 | - if (PCLZIP_ERROR_EXTERNAL == 1) { |
|
| 5318 | - PclErrorReset(); |
|
| 5319 | - } |
|
| 5320 | - else { |
|
| 5321 | - $this->error_code = 0; |
|
| 5322 | - $this->error_string = ''; |
|
| 5323 | - } |
|
| 5317 | + if (PCLZIP_ERROR_EXTERNAL == 1) { |
|
| 5318 | + PclErrorReset(); |
|
| 5319 | + } |
|
| 5320 | + else { |
|
| 5321 | + $this->error_code = 0; |
|
| 5322 | + $this->error_string = ''; |
|
| 5323 | + } |
|
| 5324 | 5324 | } |
| 5325 | 5325 | // -------------------------------------------------------------------------------- |
| 5326 | 5326 | |
@@ -5332,17 +5332,17 @@ discard block |
||
| 5332 | 5332 | // -------------------------------------------------------------------------------- |
| 5333 | 5333 | function privDisableMagicQuotes() |
| 5334 | 5334 | { |
| 5335 | - $v_result=1; |
|
| 5335 | + $v_result=1; |
|
| 5336 | 5336 | |
| 5337 | - // ----- Look if function exists |
|
| 5338 | - if ( (!function_exists("get_magic_quotes_runtime")) |
|
| 5339 | - || (!function_exists("set_magic_quotes_runtime"))) { |
|
| 5340 | - return $v_result; |
|
| 5337 | + // ----- Look if function exists |
|
| 5338 | + if ( (!function_exists("get_magic_quotes_runtime")) |
|
| 5339 | + || (!function_exists("set_magic_quotes_runtime"))) { |
|
| 5340 | + return $v_result; |
|
| 5341 | 5341 | } |
| 5342 | 5342 | |
| 5343 | - // ----- Look if already done |
|
| 5344 | - if ($this->magic_quotes_status != -1) { |
|
| 5345 | - return $v_result; |
|
| 5343 | + // ----- Look if already done |
|
| 5344 | + if ($this->magic_quotes_status != -1) { |
|
| 5345 | + return $v_result; |
|
| 5346 | 5346 | } |
| 5347 | 5347 | |
| 5348 | 5348 | // ----- Get and memorize the magic_quote value |
@@ -5353,8 +5353,8 @@ discard block |
||
| 5353 | 5353 | @set_magic_quotes_runtime(0); |
| 5354 | 5354 | } |
| 5355 | 5355 | |
| 5356 | - // ----- Return |
|
| 5357 | - return $v_result; |
|
| 5356 | + // ----- Return |
|
| 5357 | + return $v_result; |
|
| 5358 | 5358 | } |
| 5359 | 5359 | // -------------------------------------------------------------------------------- |
| 5360 | 5360 | |
@@ -5366,17 +5366,17 @@ discard block |
||
| 5366 | 5366 | // -------------------------------------------------------------------------------- |
| 5367 | 5367 | function privSwapBackMagicQuotes() |
| 5368 | 5368 | { |
| 5369 | - $v_result=1; |
|
| 5369 | + $v_result=1; |
|
| 5370 | 5370 | |
| 5371 | - // ----- Look if function exists |
|
| 5372 | - if ( (!function_exists("get_magic_quotes_runtime")) |
|
| 5373 | - || (!function_exists("set_magic_quotes_runtime"))) { |
|
| 5374 | - return $v_result; |
|
| 5371 | + // ----- Look if function exists |
|
| 5372 | + if ( (!function_exists("get_magic_quotes_runtime")) |
|
| 5373 | + || (!function_exists("set_magic_quotes_runtime"))) { |
|
| 5374 | + return $v_result; |
|
| 5375 | 5375 | } |
| 5376 | 5376 | |
| 5377 | - // ----- Look if something to do |
|
| 5378 | - if ($this->magic_quotes_status != -1) { |
|
| 5379 | - return $v_result; |
|
| 5377 | + // ----- Look if something to do |
|
| 5378 | + if ($this->magic_quotes_status != -1) { |
|
| 5379 | + return $v_result; |
|
| 5380 | 5380 | } |
| 5381 | 5381 | |
| 5382 | 5382 | // ----- Swap back magic_quotes |
@@ -5384,8 +5384,8 @@ discard block |
||
| 5384 | 5384 | @set_magic_quotes_runtime($this->magic_quotes_status); |
| 5385 | 5385 | } |
| 5386 | 5386 | |
| 5387 | - // ----- Return |
|
| 5388 | - return $v_result; |
|
| 5387 | + // ----- Return |
|
| 5388 | + return $v_result; |
|
| 5389 | 5389 | } |
| 5390 | 5390 | // -------------------------------------------------------------------------------- |
| 5391 | 5391 | |
@@ -5401,67 +5401,67 @@ discard block |
||
| 5401 | 5401 | // -------------------------------------------------------------------------------- |
| 5402 | 5402 | function PclZipUtilPathReduction($p_dir) |
| 5403 | 5403 | { |
| 5404 | - $v_result = ""; |
|
| 5405 | - |
|
| 5406 | - // ----- Look for not empty path |
|
| 5407 | - if ($p_dir != "") { |
|
| 5408 | - // ----- Explode path by directory names |
|
| 5409 | - $v_list = explode("/", $p_dir); |
|
| 5410 | - |
|
| 5411 | - // ----- Study directories from last to first |
|
| 5412 | - $v_skip = 0; |
|
| 5413 | - for ($i=sizeof($v_list)-1; $i>=0; $i--) { |
|
| 5414 | - // ----- Look for current path |
|
| 5415 | - if ($v_list[$i] == ".") { |
|
| 5416 | - // ----- Ignore this directory |
|
| 5417 | - // Should be the first $i=0, but no check is done |
|
| 5418 | - } |
|
| 5419 | - else if ($v_list[$i] == "..") { |
|
| 5404 | + $v_result = ""; |
|
| 5405 | + |
|
| 5406 | + // ----- Look for not empty path |
|
| 5407 | + if ($p_dir != "") { |
|
| 5408 | + // ----- Explode path by directory names |
|
| 5409 | + $v_list = explode("/", $p_dir); |
|
| 5410 | + |
|
| 5411 | + // ----- Study directories from last to first |
|
| 5412 | + $v_skip = 0; |
|
| 5413 | + for ($i=sizeof($v_list)-1; $i>=0; $i--) { |
|
| 5414 | + // ----- Look for current path |
|
| 5415 | + if ($v_list[$i] == ".") { |
|
| 5416 | + // ----- Ignore this directory |
|
| 5417 | + // Should be the first $i=0, but no check is done |
|
| 5418 | + } |
|
| 5419 | + else if ($v_list[$i] == "..") { |
|
| 5420 | 5420 | $v_skip++; |
| 5421 | - } |
|
| 5422 | - else if ($v_list[$i] == "") { |
|
| 5421 | + } |
|
| 5422 | + else if ($v_list[$i] == "") { |
|
| 5423 | 5423 | // ----- First '/' i.e. root slash |
| 5424 | 5424 | if ($i == 0) { |
| 5425 | - $v_result = "/".$v_result; |
|
| 5426 | - if ($v_skip > 0) { |
|
| 5427 | - // ----- It is an invalid path, so the path is not modified |
|
| 5428 | - // TBC |
|
| 5429 | - $v_result = $p_dir; |
|
| 5430 | - $v_skip = 0; |
|
| 5431 | - } |
|
| 5425 | + $v_result = "/".$v_result; |
|
| 5426 | + if ($v_skip > 0) { |
|
| 5427 | + // ----- It is an invalid path, so the path is not modified |
|
| 5428 | + // TBC |
|
| 5429 | + $v_result = $p_dir; |
|
| 5430 | + $v_skip = 0; |
|
| 5431 | + } |
|
| 5432 | 5432 | } |
| 5433 | 5433 | // ----- Last '/' i.e. indicates a directory |
| 5434 | 5434 | else if ($i == (sizeof($v_list)-1)) { |
| 5435 | - $v_result = $v_list[$i]; |
|
| 5435 | + $v_result = $v_list[$i]; |
|
| 5436 | 5436 | } |
| 5437 | 5437 | // ----- Double '/' inside the path |
| 5438 | 5438 | else { |
| 5439 | - // ----- Ignore only the double '//' in path, |
|
| 5440 | - // but not the first and last '/' |
|
| 5439 | + // ----- Ignore only the double '//' in path, |
|
| 5440 | + // but not the first and last '/' |
|
| 5441 | 5441 | } |
| 5442 | - } |
|
| 5443 | - else { |
|
| 5442 | + } |
|
| 5443 | + else { |
|
| 5444 | 5444 | // ----- Look for item to skip |
| 5445 | 5445 | if ($v_skip > 0) { |
| 5446 | - $v_skip--; |
|
| 5446 | + $v_skip--; |
|
| 5447 | 5447 | } |
| 5448 | 5448 | else { |
| 5449 | - $v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:""); |
|
| 5449 | + $v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:""); |
|
| 5450 | 5450 | } |
| 5451 | - } |
|
| 5452 | - } |
|
| 5451 | + } |
|
| 5452 | + } |
|
| 5453 | 5453 | |
| 5454 | - // ----- Look for skip |
|
| 5455 | - if ($v_skip > 0) { |
|
| 5456 | - while ($v_skip > 0) { |
|
| 5457 | - $v_result = '../'.$v_result; |
|
| 5458 | - $v_skip--; |
|
| 5459 | - } |
|
| 5460 | - } |
|
| 5461 | - } |
|
| 5454 | + // ----- Look for skip |
|
| 5455 | + if ($v_skip > 0) { |
|
| 5456 | + while ($v_skip > 0) { |
|
| 5457 | + $v_result = '../'.$v_result; |
|
| 5458 | + $v_skip--; |
|
| 5459 | + } |
|
| 5460 | + } |
|
| 5461 | + } |
|
| 5462 | 5462 | |
| 5463 | - // ----- Return |
|
| 5464 | - return $v_result; |
|
| 5463 | + // ----- Return |
|
| 5464 | + return $v_result; |
|
| 5465 | 5465 | } |
| 5466 | 5466 | // -------------------------------------------------------------------------------- |
| 5467 | 5467 | |
@@ -5482,67 +5482,67 @@ discard block |
||
| 5482 | 5482 | // -------------------------------------------------------------------------------- |
| 5483 | 5483 | function PclZipUtilPathInclusion($p_dir, $p_path) |
| 5484 | 5484 | { |
| 5485 | - $v_result = 1; |
|
| 5485 | + $v_result = 1; |
|
| 5486 | 5486 | |
| 5487 | - // ----- Look for path beginning by ./ |
|
| 5488 | - if ( ($p_dir == '.') |
|
| 5489 | - || ((strlen($p_dir) >=2) && (substr($p_dir, 0, 2) == './'))) { |
|
| 5490 | - $p_dir = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_dir, 1); |
|
| 5491 | - } |
|
| 5492 | - if ( ($p_path == '.') |
|
| 5493 | - || ((strlen($p_path) >=2) && (substr($p_path, 0, 2) == './'))) { |
|
| 5494 | - $p_path = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_path, 1); |
|
| 5495 | - } |
|
| 5487 | + // ----- Look for path beginning by ./ |
|
| 5488 | + if ( ($p_dir == '.') |
|
| 5489 | + || ((strlen($p_dir) >=2) && (substr($p_dir, 0, 2) == './'))) { |
|
| 5490 | + $p_dir = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_dir, 1); |
|
| 5491 | + } |
|
| 5492 | + if ( ($p_path == '.') |
|
| 5493 | + || ((strlen($p_path) >=2) && (substr($p_path, 0, 2) == './'))) { |
|
| 5494 | + $p_path = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_path, 1); |
|
| 5495 | + } |
|
| 5496 | 5496 | |
| 5497 | - // ----- Explode dir and path by directory separator |
|
| 5498 | - $v_list_dir = explode("/", $p_dir); |
|
| 5499 | - $v_list_dir_size = sizeof($v_list_dir); |
|
| 5500 | - $v_list_path = explode("/", $p_path); |
|
| 5501 | - $v_list_path_size = sizeof($v_list_path); |
|
| 5502 | - |
|
| 5503 | - // ----- Study directories paths |
|
| 5504 | - $i = 0; |
|
| 5505 | - $j = 0; |
|
| 5506 | - while (($i < $v_list_dir_size) && ($j < $v_list_path_size) && ($v_result)) { |
|
| 5507 | - |
|
| 5508 | - // ----- Look for empty dir (path reduction) |
|
| 5509 | - if ($v_list_dir[$i] == '') { |
|
| 5510 | - $i++; |
|
| 5511 | - continue; |
|
| 5512 | - } |
|
| 5513 | - if ($v_list_path[$j] == '') { |
|
| 5514 | - $j++; |
|
| 5515 | - continue; |
|
| 5516 | - } |
|
| 5497 | + // ----- Explode dir and path by directory separator |
|
| 5498 | + $v_list_dir = explode("/", $p_dir); |
|
| 5499 | + $v_list_dir_size = sizeof($v_list_dir); |
|
| 5500 | + $v_list_path = explode("/", $p_path); |
|
| 5501 | + $v_list_path_size = sizeof($v_list_path); |
|
| 5502 | + |
|
| 5503 | + // ----- Study directories paths |
|
| 5504 | + $i = 0; |
|
| 5505 | + $j = 0; |
|
| 5506 | + while (($i < $v_list_dir_size) && ($j < $v_list_path_size) && ($v_result)) { |
|
| 5507 | + |
|
| 5508 | + // ----- Look for empty dir (path reduction) |
|
| 5509 | + if ($v_list_dir[$i] == '') { |
|
| 5510 | + $i++; |
|
| 5511 | + continue; |
|
| 5512 | + } |
|
| 5513 | + if ($v_list_path[$j] == '') { |
|
| 5514 | + $j++; |
|
| 5515 | + continue; |
|
| 5516 | + } |
|
| 5517 | 5517 | |
| 5518 | - // ----- Compare the items |
|
| 5519 | - if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ( $v_list_path[$j] != '')) { |
|
| 5520 | - $v_result = 0; |
|
| 5521 | - } |
|
| 5518 | + // ----- Compare the items |
|
| 5519 | + if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ( $v_list_path[$j] != '')) { |
|
| 5520 | + $v_result = 0; |
|
| 5521 | + } |
|
| 5522 | 5522 | |
| 5523 | - // ----- Next items |
|
| 5524 | - $i++; |
|
| 5525 | - $j++; |
|
| 5526 | - } |
|
| 5523 | + // ----- Next items |
|
| 5524 | + $i++; |
|
| 5525 | + $j++; |
|
| 5526 | + } |
|
| 5527 | 5527 | |
| 5528 | - // ----- Look if everything seems to be the same |
|
| 5529 | - if ($v_result) { |
|
| 5530 | - // ----- Skip all the empty items |
|
| 5531 | - while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) $j++; |
|
| 5532 | - while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) $i++; |
|
| 5528 | + // ----- Look if everything seems to be the same |
|
| 5529 | + if ($v_result) { |
|
| 5530 | + // ----- Skip all the empty items |
|
| 5531 | + while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) $j++; |
|
| 5532 | + while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) $i++; |
|
| 5533 | 5533 | |
| 5534 | - if (($i >= $v_list_dir_size) && ($j >= $v_list_path_size)) { |
|
| 5535 | - // ----- There are exactly the same |
|
| 5536 | - $v_result = 2; |
|
| 5537 | - } |
|
| 5538 | - else if ($i < $v_list_dir_size) { |
|
| 5539 | - // ----- The path is shorter than the dir |
|
| 5540 | - $v_result = 0; |
|
| 5541 | - } |
|
| 5542 | - } |
|
| 5534 | + if (($i >= $v_list_dir_size) && ($j >= $v_list_path_size)) { |
|
| 5535 | + // ----- There are exactly the same |
|
| 5536 | + $v_result = 2; |
|
| 5537 | + } |
|
| 5538 | + else if ($i < $v_list_dir_size) { |
|
| 5539 | + // ----- The path is shorter than the dir |
|
| 5540 | + $v_result = 0; |
|
| 5541 | + } |
|
| 5542 | + } |
|
| 5543 | 5543 | |
| 5544 | - // ----- Return |
|
| 5545 | - return $v_result; |
|
| 5544 | + // ----- Return |
|
| 5545 | + return $v_result; |
|
| 5546 | 5546 | } |
| 5547 | 5547 | // -------------------------------------------------------------------------------- |
| 5548 | 5548 | |
@@ -5559,51 +5559,51 @@ discard block |
||
| 5559 | 5559 | // -------------------------------------------------------------------------------- |
| 5560 | 5560 | function PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode=0) |
| 5561 | 5561 | { |
| 5562 | - $v_result = 1; |
|
| 5563 | - |
|
| 5564 | - if ($p_mode==0) |
|
| 5565 | - { |
|
| 5566 | - while ($p_size != 0) |
|
| 5567 | - { |
|
| 5568 | - $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 5569 | - $v_buffer = @fread($p_src, $v_read_size); |
|
| 5570 | - @fwrite($p_dest, $v_buffer, $v_read_size); |
|
| 5571 | - $p_size -= $v_read_size; |
|
| 5572 | - } |
|
| 5573 | - } |
|
| 5574 | - else if ($p_mode==1) |
|
| 5575 | - { |
|
| 5576 | - while ($p_size != 0) |
|
| 5577 | - { |
|
| 5578 | - $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 5579 | - $v_buffer = @gzread($p_src, $v_read_size); |
|
| 5580 | - @fwrite($p_dest, $v_buffer, $v_read_size); |
|
| 5581 | - $p_size -= $v_read_size; |
|
| 5582 | - } |
|
| 5583 | - } |
|
| 5584 | - else if ($p_mode==2) |
|
| 5585 | - { |
|
| 5586 | - while ($p_size != 0) |
|
| 5587 | - { |
|
| 5588 | - $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 5589 | - $v_buffer = @fread($p_src, $v_read_size); |
|
| 5590 | - @gzwrite($p_dest, $v_buffer, $v_read_size); |
|
| 5591 | - $p_size -= $v_read_size; |
|
| 5592 | - } |
|
| 5593 | - } |
|
| 5594 | - else if ($p_mode==3) |
|
| 5595 | - { |
|
| 5596 | - while ($p_size != 0) |
|
| 5597 | - { |
|
| 5598 | - $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 5599 | - $v_buffer = @gzread($p_src, $v_read_size); |
|
| 5600 | - @gzwrite($p_dest, $v_buffer, $v_read_size); |
|
| 5601 | - $p_size -= $v_read_size; |
|
| 5602 | - } |
|
| 5603 | - } |
|
| 5562 | + $v_result = 1; |
|
| 5563 | + |
|
| 5564 | + if ($p_mode==0) |
|
| 5565 | + { |
|
| 5566 | + while ($p_size != 0) |
|
| 5567 | + { |
|
| 5568 | + $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 5569 | + $v_buffer = @fread($p_src, $v_read_size); |
|
| 5570 | + @fwrite($p_dest, $v_buffer, $v_read_size); |
|
| 5571 | + $p_size -= $v_read_size; |
|
| 5572 | + } |
|
| 5573 | + } |
|
| 5574 | + else if ($p_mode==1) |
|
| 5575 | + { |
|
| 5576 | + while ($p_size != 0) |
|
| 5577 | + { |
|
| 5578 | + $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 5579 | + $v_buffer = @gzread($p_src, $v_read_size); |
|
| 5580 | + @fwrite($p_dest, $v_buffer, $v_read_size); |
|
| 5581 | + $p_size -= $v_read_size; |
|
| 5582 | + } |
|
| 5583 | + } |
|
| 5584 | + else if ($p_mode==2) |
|
| 5585 | + { |
|
| 5586 | + while ($p_size != 0) |
|
| 5587 | + { |
|
| 5588 | + $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 5589 | + $v_buffer = @fread($p_src, $v_read_size); |
|
| 5590 | + @gzwrite($p_dest, $v_buffer, $v_read_size); |
|
| 5591 | + $p_size -= $v_read_size; |
|
| 5592 | + } |
|
| 5593 | + } |
|
| 5594 | + else if ($p_mode==3) |
|
| 5595 | + { |
|
| 5596 | + while ($p_size != 0) |
|
| 5597 | + { |
|
| 5598 | + $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 5599 | + $v_buffer = @gzread($p_src, $v_read_size); |
|
| 5600 | + @gzwrite($p_dest, $v_buffer, $v_read_size); |
|
| 5601 | + $p_size -= $v_read_size; |
|
| 5602 | + } |
|
| 5603 | + } |
|
| 5604 | 5604 | |
| 5605 | - // ----- Return |
|
| 5606 | - return $v_result; |
|
| 5605 | + // ----- Return |
|
| 5606 | + return $v_result; |
|
| 5607 | 5607 | } |
| 5608 | 5608 | // -------------------------------------------------------------------------------- |
| 5609 | 5609 | |
@@ -5621,22 +5621,22 @@ discard block |
||
| 5621 | 5621 | // -------------------------------------------------------------------------------- |
| 5622 | 5622 | function PclZipUtilRename($p_src, $p_dest) |
| 5623 | 5623 | { |
| 5624 | - $v_result = 1; |
|
| 5624 | + $v_result = 1; |
|
| 5625 | 5625 | |
| 5626 | - // ----- Try to rename the files |
|
| 5627 | - if (!@rename($p_src, $p_dest)) { |
|
| 5626 | + // ----- Try to rename the files |
|
| 5627 | + if (!@rename($p_src, $p_dest)) { |
|
| 5628 | 5628 | |
| 5629 | - // ----- Try to copy & unlink the src |
|
| 5630 | - if (!@copy($p_src, $p_dest)) { |
|
| 5631 | - $v_result = 0; |
|
| 5632 | - } |
|
| 5633 | - else if (!@unlink($p_src)) { |
|
| 5634 | - $v_result = 0; |
|
| 5635 | - } |
|
| 5636 | - } |
|
| 5629 | + // ----- Try to copy & unlink the src |
|
| 5630 | + if (!@copy($p_src, $p_dest)) { |
|
| 5631 | + $v_result = 0; |
|
| 5632 | + } |
|
| 5633 | + else if (!@unlink($p_src)) { |
|
| 5634 | + $v_result = 0; |
|
| 5635 | + } |
|
| 5636 | + } |
|
| 5637 | 5637 | |
| 5638 | - // ----- Return |
|
| 5639 | - return $v_result; |
|
| 5638 | + // ----- Return |
|
| 5639 | + return $v_result; |
|
| 5640 | 5640 | } |
| 5641 | 5641 | // -------------------------------------------------------------------------------- |
| 5642 | 5642 | |
@@ -5652,20 +5652,20 @@ discard block |
||
| 5652 | 5652 | function PclZipUtilOptionText($p_option) |
| 5653 | 5653 | { |
| 5654 | 5654 | |
| 5655 | - $v_list = get_defined_constants(); |
|
| 5656 | - for (reset($v_list); $v_key = key($v_list); next($v_list)) { |
|
| 5657 | - $v_prefix = substr($v_key, 0, 10); |
|
| 5658 | - if (( ($v_prefix == 'PCLZIP_OPT') |
|
| 5659 | - || ($v_prefix == 'PCLZIP_CB_') |
|
| 5660 | - || ($v_prefix == 'PCLZIP_ATT')) |
|
| 5661 | - && ($v_list[$v_key] == $p_option)) { |
|
| 5662 | - return $v_key; |
|
| 5663 | - } |
|
| 5664 | - } |
|
| 5655 | + $v_list = get_defined_constants(); |
|
| 5656 | + for (reset($v_list); $v_key = key($v_list); next($v_list)) { |
|
| 5657 | + $v_prefix = substr($v_key, 0, 10); |
|
| 5658 | + if (( ($v_prefix == 'PCLZIP_OPT') |
|
| 5659 | + || ($v_prefix == 'PCLZIP_CB_') |
|
| 5660 | + || ($v_prefix == 'PCLZIP_ATT')) |
|
| 5661 | + && ($v_list[$v_key] == $p_option)) { |
|
| 5662 | + return $v_key; |
|
| 5663 | + } |
|
| 5664 | + } |
|
| 5665 | 5665 | |
| 5666 | - $v_result = 'Unknown'; |
|
| 5666 | + $v_result = 'Unknown'; |
|
| 5667 | 5667 | |
| 5668 | - return $v_result; |
|
| 5668 | + return $v_result; |
|
| 5669 | 5669 | } |
| 5670 | 5670 | // -------------------------------------------------------------------------------- |
| 5671 | 5671 | |
@@ -5682,17 +5682,17 @@ discard block |
||
| 5682 | 5682 | // -------------------------------------------------------------------------------- |
| 5683 | 5683 | function PclZipUtilTranslateWinPath($p_path, $p_remove_disk_letter=true) |
| 5684 | 5684 | { |
| 5685 | - if (stristr(php_uname(), 'windows')) { |
|
| 5686 | - // ----- Look for potential disk letter |
|
| 5687 | - if (($p_remove_disk_letter) && (($v_position = strpos($p_path, ':')) != false)) { |
|
| 5688 | - $p_path = substr($p_path, $v_position+1); |
|
| 5689 | - } |
|
| 5690 | - // ----- Change potential windows directory separator |
|
| 5691 | - if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) { |
|
| 5692 | - $p_path = strtr($p_path, '\\', '/'); |
|
| 5693 | - } |
|
| 5694 | - } |
|
| 5695 | - return $p_path; |
|
| 5685 | + if (stristr(php_uname(), 'windows')) { |
|
| 5686 | + // ----- Look for potential disk letter |
|
| 5687 | + if (($p_remove_disk_letter) && (($v_position = strpos($p_path, ':')) != false)) { |
|
| 5688 | + $p_path = substr($p_path, $v_position+1); |
|
| 5689 | + } |
|
| 5690 | + // ----- Change potential windows directory separator |
|
| 5691 | + if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) { |
|
| 5692 | + $p_path = strtr($p_path, '\\', '/'); |
|
| 5693 | + } |
|
| 5694 | + } |
|
| 5695 | + return $p_path; |
|
| 5696 | 5696 | } |
| 5697 | 5697 | // -------------------------------------------------------------------------------- |
| 5698 | 5698 | |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) exit; |
|
| 2 | 2 | // -------------------------------------------------------------------------------- |
| 3 | 3 | // PhpConcept Library - Zip Module 2.8.2 |
| 4 | 4 | // -------------------------------------------------------------------------------- |
@@ -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 | // -------------------------------------------------------------------------------- |
@@ -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 ); |
@@ -220,9 +220,9 @@ discard block |
||
| 220 | 220 | { |
| 221 | 221 | if (!function_exists('gzopen') |
| 222 | 222 | && function_exists('gzopen64')) { |
| 223 | - function gzopen($filename , $mode = 'r', $use_include_path = 0 ) |
|
| 223 | + function gzopen($filename, $mode = 'r', $use_include_path = 0) |
|
| 224 | 224 | { |
| 225 | - return gzopen64($filename , $mode, $use_include_path); |
|
| 225 | + return gzopen64($filename, $mode, $use_include_path); |
|
| 226 | 226 | } |
| 227 | 227 | } |
| 228 | 228 | } |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | // -------------------------------------------------------------------------------- |
| 277 | 277 | function create($p_filelist) |
| 278 | 278 | { |
| 279 | - $v_result=1; |
|
| 279 | + $v_result = 1; |
|
| 280 | 280 | |
| 281 | 281 | // ----- Reset the error handler |
| 282 | 282 | $this->privErrorReset(); |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | |
| 303 | 303 | // ----- Parse the options |
| 304 | 304 | $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, |
| 305 | - array (PCLZIP_OPT_REMOVE_PATH => 'optional', |
|
| 305 | + array(PCLZIP_OPT_REMOVE_PATH => 'optional', |
|
| 306 | 306 | PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', |
| 307 | 307 | PCLZIP_OPT_ADD_PATH => 'optional', |
| 308 | 308 | PCLZIP_CB_PRE_ADD => 'optional', |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | |
| 389 | 389 | // ----- For each file in the list check the attributes |
| 390 | 390 | $v_supported_attributes |
| 391 | - = array ( PCLZIP_ATT_FILE_NAME => 'mandatory' |
|
| 391 | + = array(PCLZIP_ATT_FILE_NAME => 'mandatory' |
|
| 392 | 392 | ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional' |
| 393 | 393 | ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional' |
| 394 | 394 | ,PCLZIP_ATT_FILE_MTIME => 'optional' |
@@ -459,7 +459,7 @@ discard block |
||
| 459 | 459 | // -------------------------------------------------------------------------------- |
| 460 | 460 | function add($p_filelist) |
| 461 | 461 | { |
| 462 | - $v_result=1; |
|
| 462 | + $v_result = 1; |
|
| 463 | 463 | |
| 464 | 464 | // ----- Reset the error handler |
| 465 | 465 | $this->privErrorReset(); |
@@ -485,7 +485,7 @@ discard block |
||
| 485 | 485 | |
| 486 | 486 | // ----- Parse the options |
| 487 | 487 | $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, |
| 488 | - array (PCLZIP_OPT_REMOVE_PATH => 'optional', |
|
| 488 | + array(PCLZIP_OPT_REMOVE_PATH => 'optional', |
|
| 489 | 489 | PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', |
| 490 | 490 | PCLZIP_OPT_ADD_PATH => 'optional', |
| 491 | 491 | PCLZIP_CB_PRE_ADD => 'optional', |
@@ -558,7 +558,7 @@ discard block |
||
| 558 | 558 | |
| 559 | 559 | // ----- Invalid variable type for $p_filelist |
| 560 | 560 | else { |
| 561 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type '".gettype($p_filelist)."' for p_filelist"); |
|
| 561 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type '" . gettype($p_filelist) . "' for p_filelist"); |
|
| 562 | 562 | return 0; |
| 563 | 563 | } |
| 564 | 564 | |
@@ -571,7 +571,7 @@ discard block |
||
| 571 | 571 | |
| 572 | 572 | // ----- For each file in the list check the attributes |
| 573 | 573 | $v_supported_attributes |
| 574 | - = array ( PCLZIP_ATT_FILE_NAME => 'mandatory' |
|
| 574 | + = array(PCLZIP_ATT_FILE_NAME => 'mandatory' |
|
| 575 | 575 | ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional' |
| 576 | 576 | ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional' |
| 577 | 577 | ,PCLZIP_ATT_FILE_MTIME => 'optional' |
@@ -648,7 +648,7 @@ discard block |
||
| 648 | 648 | // -------------------------------------------------------------------------------- |
| 649 | 649 | function listContent() |
| 650 | 650 | { |
| 651 | - $v_result=1; |
|
| 651 | + $v_result = 1; |
|
| 652 | 652 | |
| 653 | 653 | // ----- Reset the error handler |
| 654 | 654 | $this->privErrorReset(); |
@@ -705,7 +705,7 @@ discard block |
||
| 705 | 705 | // -------------------------------------------------------------------------------- |
| 706 | 706 | function extract() |
| 707 | 707 | { |
| 708 | - $v_result=1; |
|
| 708 | + $v_result = 1; |
|
| 709 | 709 | |
| 710 | 710 | // ----- Reset the error handler |
| 711 | 711 | $this->privErrorReset(); |
@@ -738,7 +738,7 @@ discard block |
||
| 738 | 738 | |
| 739 | 739 | // ----- Parse the options |
| 740 | 740 | $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, |
| 741 | - array (PCLZIP_OPT_PATH => 'optional', |
|
| 741 | + array(PCLZIP_OPT_PATH => 'optional', |
|
| 742 | 742 | PCLZIP_OPT_REMOVE_PATH => 'optional', |
| 743 | 743 | PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', |
| 744 | 744 | PCLZIP_OPT_ADD_PATH => 'optional', |
@@ -862,7 +862,7 @@ discard block |
||
| 862 | 862 | //function extractByIndex($p_index, options...) |
| 863 | 863 | function extractByIndex($p_index) |
| 864 | 864 | { |
| 865 | - $v_result=1; |
|
| 865 | + $v_result = 1; |
|
| 866 | 866 | |
| 867 | 867 | // ----- Reset the error handler |
| 868 | 868 | $this->privErrorReset(); |
@@ -899,7 +899,7 @@ discard block |
||
| 899 | 899 | |
| 900 | 900 | // ----- Parse the options |
| 901 | 901 | $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, |
| 902 | - array (PCLZIP_OPT_PATH => 'optional', |
|
| 902 | + array(PCLZIP_OPT_PATH => 'optional', |
|
| 903 | 903 | PCLZIP_OPT_REMOVE_PATH => 'optional', |
| 904 | 904 | PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', |
| 905 | 905 | PCLZIP_OPT_EXTRACT_AS_STRING => 'optional', |
@@ -969,10 +969,10 @@ discard block |
||
| 969 | 969 | // ----- Trick |
| 970 | 970 | // Here I want to reuse extractByRule(), so I need to parse the $p_index |
| 971 | 971 | // with privParseOptions() |
| 972 | - $v_arg_trick = array (PCLZIP_OPT_BY_INDEX, $p_index); |
|
| 972 | + $v_arg_trick = array(PCLZIP_OPT_BY_INDEX, $p_index); |
|
| 973 | 973 | $v_options_trick = array(); |
| 974 | 974 | $v_result = $this->privParseOptions($v_arg_trick, sizeof($v_arg_trick), $v_options_trick, |
| 975 | - array (PCLZIP_OPT_BY_INDEX => 'optional' )); |
|
| 975 | + array(PCLZIP_OPT_BY_INDEX => 'optional')); |
|
| 976 | 976 | if ($v_result != 1) { |
| 977 | 977 | return 0; |
| 978 | 978 | } |
@@ -1011,7 +1011,7 @@ discard block |
||
| 1011 | 1011 | // -------------------------------------------------------------------------------- |
| 1012 | 1012 | function delete() |
| 1013 | 1013 | { |
| 1014 | - $v_result=1; |
|
| 1014 | + $v_result = 1; |
|
| 1015 | 1015 | |
| 1016 | 1016 | // ----- Reset the error handler |
| 1017 | 1017 | $this->privErrorReset(); |
@@ -1034,10 +1034,10 @@ discard block |
||
| 1034 | 1034 | |
| 1035 | 1035 | // ----- Parse the options |
| 1036 | 1036 | $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, |
| 1037 | - array (PCLZIP_OPT_BY_NAME => 'optional', |
|
| 1037 | + array(PCLZIP_OPT_BY_NAME => 'optional', |
|
| 1038 | 1038 | PCLZIP_OPT_BY_EREG => 'optional', |
| 1039 | 1039 | PCLZIP_OPT_BY_PREG => 'optional', |
| 1040 | - PCLZIP_OPT_BY_INDEX => 'optional' )); |
|
| 1040 | + PCLZIP_OPT_BY_INDEX => 'optional')); |
|
| 1041 | 1041 | if ($v_result != 1) { |
| 1042 | 1042 | return 0; |
| 1043 | 1043 | } |
@@ -1122,7 +1122,7 @@ discard block |
||
| 1122 | 1122 | $this->privSwapBackMagicQuotes(); |
| 1123 | 1123 | |
| 1124 | 1124 | // ----- Error log |
| 1125 | - PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode'); |
|
| 1125 | + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \'' . $this->zipname . '\' in binary read mode'); |
|
| 1126 | 1126 | |
| 1127 | 1127 | // ----- Return |
| 1128 | 1128 | return 0; |
@@ -1188,7 +1188,7 @@ discard block |
||
| 1188 | 1188 | // TBC : Should also check the archive format |
| 1189 | 1189 | if (!is_file($p_archive)) { |
| 1190 | 1190 | // ----- Error log |
| 1191 | - PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "No file with filename '".$p_archive."'"); |
|
| 1191 | + PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "No file with filename '" . $p_archive . "'"); |
|
| 1192 | 1192 | $v_result = PCLZIP_ERR_MISSING_FILE; |
| 1193 | 1193 | } |
| 1194 | 1194 | else { |
@@ -1291,9 +1291,9 @@ discard block |
||
| 1291 | 1291 | // Description : |
| 1292 | 1292 | // Parameters : |
| 1293 | 1293 | // -------------------------------------------------------------------------------- |
| 1294 | - function errorName($p_with_code=false) |
|
| 1294 | + function errorName($p_with_code = false) |
|
| 1295 | 1295 | { |
| 1296 | - $v_name = array ( PCLZIP_ERR_NO_ERROR => 'PCLZIP_ERR_NO_ERROR', |
|
| 1296 | + $v_name = array(PCLZIP_ERR_NO_ERROR => 'PCLZIP_ERR_NO_ERROR', |
|
| 1297 | 1297 | PCLZIP_ERR_WRITE_OPEN_FAIL => 'PCLZIP_ERR_WRITE_OPEN_FAIL', |
| 1298 | 1298 | PCLZIP_ERR_READ_OPEN_FAIL => 'PCLZIP_ERR_READ_OPEN_FAIL', |
| 1299 | 1299 | PCLZIP_ERR_INVALID_PARAMETER => 'PCLZIP_ERR_INVALID_PARAMETER', |
@@ -1324,7 +1324,7 @@ discard block |
||
| 1324 | 1324 | } |
| 1325 | 1325 | |
| 1326 | 1326 | if ($p_with_code) { |
| 1327 | - return($v_value.' ('.$this->error_code.')'); |
|
| 1327 | + return($v_value . ' (' . $this->error_code . ')'); |
|
| 1328 | 1328 | } |
| 1329 | 1329 | else { |
| 1330 | 1330 | return($v_value); |
@@ -1337,17 +1337,17 @@ discard block |
||
| 1337 | 1337 | // Description : |
| 1338 | 1338 | // Parameters : |
| 1339 | 1339 | // -------------------------------------------------------------------------------- |
| 1340 | - function errorInfo($p_full=false) |
|
| 1340 | + function errorInfo($p_full = false) |
|
| 1341 | 1341 | { |
| 1342 | 1342 | if (PCLZIP_ERROR_EXTERNAL == 1) { |
| 1343 | 1343 | return(PclErrorString()); |
| 1344 | 1344 | } |
| 1345 | 1345 | else { |
| 1346 | 1346 | if ($p_full) { |
| 1347 | - return($this->errorName(true)." : ".$this->error_string); |
|
| 1347 | + return($this->errorName(true) . " : " . $this->error_string); |
|
| 1348 | 1348 | } |
| 1349 | 1349 | else { |
| 1350 | - return($this->error_string." [code ".$this->error_code."]"); |
|
| 1350 | + return($this->error_string . " [code " . $this->error_code . "]"); |
|
| 1351 | 1351 | } |
| 1352 | 1352 | } |
| 1353 | 1353 | } |
@@ -1376,7 +1376,7 @@ discard block |
||
| 1376 | 1376 | // true on success, |
| 1377 | 1377 | // false on error, the error code is set. |
| 1378 | 1378 | // -------------------------------------------------------------------------------- |
| 1379 | - function privCheckFormat($p_level=0) |
|
| 1379 | + function privCheckFormat($p_level = 0) |
|
| 1380 | 1380 | { |
| 1381 | 1381 | $v_result = true; |
| 1382 | 1382 | |
@@ -1389,14 +1389,14 @@ discard block |
||
| 1389 | 1389 | // ----- Look if the file exits |
| 1390 | 1390 | if (!is_file($this->zipname)) { |
| 1391 | 1391 | // ----- Error log |
| 1392 | - PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "Missing archive file '".$this->zipname."'"); |
|
| 1392 | + PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "Missing archive file '" . $this->zipname . "'"); |
|
| 1393 | 1393 | return(false); |
| 1394 | 1394 | } |
| 1395 | 1395 | |
| 1396 | 1396 | // ----- Check that the file is readeable |
| 1397 | 1397 | if (!is_readable($this->zipname)) { |
| 1398 | 1398 | // ----- Error log |
| 1399 | - PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to read archive '".$this->zipname."'"); |
|
| 1399 | + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to read archive '" . $this->zipname . "'"); |
|
| 1400 | 1400 | return(false); |
| 1401 | 1401 | } |
| 1402 | 1402 | |
@@ -1429,18 +1429,18 @@ discard block |
||
| 1429 | 1429 | // 1 on success. |
| 1430 | 1430 | // 0 on failure. |
| 1431 | 1431 | // -------------------------------------------------------------------------------- |
| 1432 | - function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_requested_options=false) |
|
| 1432 | + function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_requested_options = false) |
|
| 1433 | 1433 | { |
| 1434 | - $v_result=1; |
|
| 1434 | + $v_result = 1; |
|
| 1435 | 1435 | |
| 1436 | 1436 | // ----- Read the options |
| 1437 | - $i=0; |
|
| 1438 | - while ($i<$p_size) { |
|
| 1437 | + $i = 0; |
|
| 1438 | + while ($i < $p_size) { |
|
| 1439 | 1439 | |
| 1440 | 1440 | // ----- Check if the option is supported |
| 1441 | 1441 | if (!isset($v_requested_options[$p_options_list[$i]])) { |
| 1442 | 1442 | // ----- Error log |
| 1443 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid optional parameter '".$p_options_list[$i]."' for this method"); |
|
| 1443 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid optional parameter '" . $p_options_list[$i] . "' for this method"); |
|
| 1444 | 1444 | |
| 1445 | 1445 | // ----- Return |
| 1446 | 1446 | return PclZip::errorCode(); |
@@ -1453,48 +1453,48 @@ discard block |
||
| 1453 | 1453 | case PCLZIP_OPT_REMOVE_PATH : |
| 1454 | 1454 | case PCLZIP_OPT_ADD_PATH : |
| 1455 | 1455 | // ----- Check the number of parameters |
| 1456 | - if (($i+1) >= $p_size) { |
|
| 1456 | + if (($i + 1) >= $p_size) { |
|
| 1457 | 1457 | // ----- Error log |
| 1458 | - PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1458 | + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '" . PclZipUtilOptionText($p_options_list[$i]) . "'"); |
|
| 1459 | 1459 | |
| 1460 | 1460 | // ----- Return |
| 1461 | 1461 | return PclZip::errorCode(); |
| 1462 | 1462 | } |
| 1463 | 1463 | |
| 1464 | 1464 | // ----- Get the value |
| 1465 | - $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE); |
|
| 1465 | + $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i + 1], FALSE); |
|
| 1466 | 1466 | $i++; |
| 1467 | 1467 | break; |
| 1468 | 1468 | |
| 1469 | 1469 | case PCLZIP_OPT_TEMP_FILE_THRESHOLD : |
| 1470 | 1470 | // ----- Check the number of parameters |
| 1471 | - if (($i+1) >= $p_size) { |
|
| 1472 | - PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1471 | + if (($i + 1) >= $p_size) { |
|
| 1472 | + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '" . PclZipUtilOptionText($p_options_list[$i]) . "'"); |
|
| 1473 | 1473 | return PclZip::errorCode(); |
| 1474 | 1474 | } |
| 1475 | 1475 | |
| 1476 | 1476 | // ----- Check for incompatible options |
| 1477 | 1477 | if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) { |
| 1478 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'"); |
|
| 1478 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '" . PclZipUtilOptionText($p_options_list[$i]) . "' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'"); |
|
| 1479 | 1479 | return PclZip::errorCode(); |
| 1480 | 1480 | } |
| 1481 | 1481 | |
| 1482 | 1482 | // ----- Check the value |
| 1483 | - $v_value = $p_options_list[$i+1]; |
|
| 1484 | - if ((!is_integer($v_value)) || ($v_value<0)) { |
|
| 1485 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Integer expected for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1483 | + $v_value = $p_options_list[$i + 1]; |
|
| 1484 | + if ((!is_integer($v_value)) || ($v_value < 0)) { |
|
| 1485 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Integer expected for option '" . PclZipUtilOptionText($p_options_list[$i]) . "'"); |
|
| 1486 | 1486 | return PclZip::errorCode(); |
| 1487 | 1487 | } |
| 1488 | 1488 | |
| 1489 | 1489 | // ----- Get the value (and convert it in bytes) |
| 1490 | - $v_result_list[$p_options_list[$i]] = $v_value*1048576; |
|
| 1490 | + $v_result_list[$p_options_list[$i]] = $v_value * 1048576; |
|
| 1491 | 1491 | $i++; |
| 1492 | 1492 | break; |
| 1493 | 1493 | |
| 1494 | 1494 | case PCLZIP_OPT_TEMP_FILE_ON : |
| 1495 | 1495 | // ----- Check for incompatible options |
| 1496 | 1496 | if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) { |
| 1497 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'"); |
|
| 1497 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '" . PclZipUtilOptionText($p_options_list[$i]) . "' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'"); |
|
| 1498 | 1498 | return PclZip::errorCode(); |
| 1499 | 1499 | } |
| 1500 | 1500 | |
@@ -1504,12 +1504,12 @@ discard block |
||
| 1504 | 1504 | case PCLZIP_OPT_TEMP_FILE_OFF : |
| 1505 | 1505 | // ----- Check for incompatible options |
| 1506 | 1506 | if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_ON])) { |
| 1507 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_ON'"); |
|
| 1507 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '" . PclZipUtilOptionText($p_options_list[$i]) . "' can not be used with option 'PCLZIP_OPT_TEMP_FILE_ON'"); |
|
| 1508 | 1508 | return PclZip::errorCode(); |
| 1509 | 1509 | } |
| 1510 | 1510 | // ----- Check for incompatible options |
| 1511 | 1511 | if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) { |
| 1512 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_THRESHOLD'"); |
|
| 1512 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '" . PclZipUtilOptionText($p_options_list[$i]) . "' can not be used with option 'PCLZIP_OPT_TEMP_FILE_THRESHOLD'"); |
|
| 1513 | 1513 | return PclZip::errorCode(); |
| 1514 | 1514 | } |
| 1515 | 1515 | |
@@ -1518,18 +1518,18 @@ discard block |
||
| 1518 | 1518 | |
| 1519 | 1519 | case PCLZIP_OPT_EXTRACT_DIR_RESTRICTION : |
| 1520 | 1520 | // ----- Check the number of parameters |
| 1521 | - if (($i+1) >= $p_size) { |
|
| 1521 | + if (($i + 1) >= $p_size) { |
|
| 1522 | 1522 | // ----- Error log |
| 1523 | - PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1523 | + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '" . PclZipUtilOptionText($p_options_list[$i]) . "'"); |
|
| 1524 | 1524 | |
| 1525 | 1525 | // ----- Return |
| 1526 | 1526 | return PclZip::errorCode(); |
| 1527 | 1527 | } |
| 1528 | 1528 | |
| 1529 | 1529 | // ----- Get the value |
| 1530 | - if ( is_string($p_options_list[$i+1]) |
|
| 1531 | - && ($p_options_list[$i+1] != '')) { |
|
| 1532 | - $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE); |
|
| 1530 | + if (is_string($p_options_list[$i + 1]) |
|
| 1531 | + && ($p_options_list[$i + 1] != '')) { |
|
| 1532 | + $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i + 1], FALSE); |
|
| 1533 | 1533 | $i++; |
| 1534 | 1534 | } |
| 1535 | 1535 | else { |
@@ -1539,24 +1539,24 @@ discard block |
||
| 1539 | 1539 | // ----- Look for options that request an array of string for value |
| 1540 | 1540 | case PCLZIP_OPT_BY_NAME : |
| 1541 | 1541 | // ----- Check the number of parameters |
| 1542 | - if (($i+1) >= $p_size) { |
|
| 1542 | + if (($i + 1) >= $p_size) { |
|
| 1543 | 1543 | // ----- Error log |
| 1544 | - PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1544 | + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '" . PclZipUtilOptionText($p_options_list[$i]) . "'"); |
|
| 1545 | 1545 | |
| 1546 | 1546 | // ----- Return |
| 1547 | 1547 | return PclZip::errorCode(); |
| 1548 | 1548 | } |
| 1549 | 1549 | |
| 1550 | 1550 | // ----- Get the value |
| 1551 | - if (is_string($p_options_list[$i+1])) { |
|
| 1552 | - $v_result_list[$p_options_list[$i]][0] = $p_options_list[$i+1]; |
|
| 1551 | + if (is_string($p_options_list[$i + 1])) { |
|
| 1552 | + $v_result_list[$p_options_list[$i]][0] = $p_options_list[$i + 1]; |
|
| 1553 | 1553 | } |
| 1554 | - else if (is_array($p_options_list[$i+1])) { |
|
| 1555 | - $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; |
|
| 1554 | + else if (is_array($p_options_list[$i + 1])) { |
|
| 1555 | + $v_result_list[$p_options_list[$i]] = $p_options_list[$i + 1]; |
|
| 1556 | 1556 | } |
| 1557 | 1557 | else { |
| 1558 | 1558 | // ----- Error log |
| 1559 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1559 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '" . PclZipUtilOptionText($p_options_list[$i]) . "'"); |
|
| 1560 | 1560 | |
| 1561 | 1561 | // ----- Return |
| 1562 | 1562 | return PclZip::errorCode(); |
@@ -1572,21 +1572,21 @@ discard block |
||
| 1572 | 1572 | case PCLZIP_OPT_BY_PREG : |
| 1573 | 1573 | //case PCLZIP_OPT_CRYPT : |
| 1574 | 1574 | // ----- Check the number of parameters |
| 1575 | - if (($i+1) >= $p_size) { |
|
| 1575 | + if (($i + 1) >= $p_size) { |
|
| 1576 | 1576 | // ----- Error log |
| 1577 | - PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1577 | + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '" . PclZipUtilOptionText($p_options_list[$i]) . "'"); |
|
| 1578 | 1578 | |
| 1579 | 1579 | // ----- Return |
| 1580 | 1580 | return PclZip::errorCode(); |
| 1581 | 1581 | } |
| 1582 | 1582 | |
| 1583 | 1583 | // ----- Get the value |
| 1584 | - if (is_string($p_options_list[$i+1])) { |
|
| 1585 | - $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; |
|
| 1584 | + if (is_string($p_options_list[$i + 1])) { |
|
| 1585 | + $v_result_list[$p_options_list[$i]] = $p_options_list[$i + 1]; |
|
| 1586 | 1586 | } |
| 1587 | 1587 | else { |
| 1588 | 1588 | // ----- Error log |
| 1589 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1589 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '" . PclZipUtilOptionText($p_options_list[$i]) . "'"); |
|
| 1590 | 1590 | |
| 1591 | 1591 | // ----- Return |
| 1592 | 1592 | return PclZip::errorCode(); |
@@ -1599,7 +1599,7 @@ discard block |
||
| 1599 | 1599 | case PCLZIP_OPT_ADD_COMMENT : |
| 1600 | 1600 | case PCLZIP_OPT_PREPEND_COMMENT : |
| 1601 | 1601 | // ----- Check the number of parameters |
| 1602 | - if (($i+1) >= $p_size) { |
|
| 1602 | + if (($i + 1) >= $p_size) { |
|
| 1603 | 1603 | // ----- Error log |
| 1604 | 1604 | PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, |
| 1605 | 1605 | "Missing parameter value for option '" |
@@ -1611,8 +1611,8 @@ discard block |
||
| 1611 | 1611 | } |
| 1612 | 1612 | |
| 1613 | 1613 | // ----- Get the value |
| 1614 | - if (is_string($p_options_list[$i+1])) { |
|
| 1615 | - $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; |
|
| 1614 | + if (is_string($p_options_list[$i + 1])) { |
|
| 1615 | + $v_result_list[$p_options_list[$i]] = $p_options_list[$i + 1]; |
|
| 1616 | 1616 | } |
| 1617 | 1617 | else { |
| 1618 | 1618 | // ----- Error log |
@@ -1630,9 +1630,9 @@ discard block |
||
| 1630 | 1630 | // ----- Look for options that request an array of index |
| 1631 | 1631 | case PCLZIP_OPT_BY_INDEX : |
| 1632 | 1632 | // ----- Check the number of parameters |
| 1633 | - if (($i+1) >= $p_size) { |
|
| 1633 | + if (($i + 1) >= $p_size) { |
|
| 1634 | 1634 | // ----- Error log |
| 1635 | - PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1635 | + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '" . PclZipUtilOptionText($p_options_list[$i]) . "'"); |
|
| 1636 | 1636 | |
| 1637 | 1637 | // ----- Return |
| 1638 | 1638 | return PclZip::errorCode(); |
@@ -1640,23 +1640,23 @@ discard block |
||
| 1640 | 1640 | |
| 1641 | 1641 | // ----- Get the value |
| 1642 | 1642 | $v_work_list = array(); |
| 1643 | - if (is_string($p_options_list[$i+1])) { |
|
| 1643 | + if (is_string($p_options_list[$i + 1])) { |
|
| 1644 | 1644 | |
| 1645 | 1645 | // ----- Remove spaces |
| 1646 | - $p_options_list[$i+1] = strtr($p_options_list[$i+1], ' ', ''); |
|
| 1646 | + $p_options_list[$i + 1] = strtr($p_options_list[$i + 1], ' ', ''); |
|
| 1647 | 1647 | |
| 1648 | 1648 | // ----- Parse items |
| 1649 | - $v_work_list = explode(",", $p_options_list[$i+1]); |
|
| 1649 | + $v_work_list = explode(",", $p_options_list[$i + 1]); |
|
| 1650 | 1650 | } |
| 1651 | - else if (is_integer($p_options_list[$i+1])) { |
|
| 1652 | - $v_work_list[0] = $p_options_list[$i+1].'-'.$p_options_list[$i+1]; |
|
| 1651 | + else if (is_integer($p_options_list[$i + 1])) { |
|
| 1652 | + $v_work_list[0] = $p_options_list[$i + 1] . '-' . $p_options_list[$i + 1]; |
|
| 1653 | 1653 | } |
| 1654 | - else if (is_array($p_options_list[$i+1])) { |
|
| 1655 | - $v_work_list = $p_options_list[$i+1]; |
|
| 1654 | + else if (is_array($p_options_list[$i + 1])) { |
|
| 1655 | + $v_work_list = $p_options_list[$i + 1]; |
|
| 1656 | 1656 | } |
| 1657 | 1657 | else { |
| 1658 | 1658 | // ----- Error log |
| 1659 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Value must be integer, string or array for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1659 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Value must be integer, string or array for option '" . PclZipUtilOptionText($p_options_list[$i]) . "'"); |
|
| 1660 | 1660 | |
| 1661 | 1661 | // ----- Return |
| 1662 | 1662 | return PclZip::errorCode(); |
@@ -1666,9 +1666,9 @@ discard block |
||
| 1666 | 1666 | // each index item in the list must be a couple with a start and |
| 1667 | 1667 | // an end value : [0,3], [5-5], [8-10], ... |
| 1668 | 1668 | // ----- Check the format of each item |
| 1669 | - $v_sort_flag=false; |
|
| 1670 | - $v_sort_value=0; |
|
| 1671 | - for ($j=0; $j<sizeof($v_work_list); $j++) { |
|
| 1669 | + $v_sort_flag = false; |
|
| 1670 | + $v_sort_value = 0; |
|
| 1671 | + for ($j = 0; $j < sizeof($v_work_list); $j++) { |
|
| 1672 | 1672 | // ----- Explode the item |
| 1673 | 1673 | $v_item_list = explode("-", $v_work_list[$j]); |
| 1674 | 1674 | $v_size_item_list = sizeof($v_item_list); |
@@ -1689,7 +1689,7 @@ discard block |
||
| 1689 | 1689 | } |
| 1690 | 1690 | else { |
| 1691 | 1691 | // ----- Error log |
| 1692 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Too many values in index range for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1692 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Too many values in index range for option '" . PclZipUtilOptionText($p_options_list[$i]) . "'"); |
|
| 1693 | 1693 | |
| 1694 | 1694 | // ----- Return |
| 1695 | 1695 | return PclZip::errorCode(); |
@@ -1698,11 +1698,11 @@ discard block |
||
| 1698 | 1698 | |
| 1699 | 1699 | // ----- Look for list sort |
| 1700 | 1700 | if ($v_result_list[$p_options_list[$i]][$j]['start'] < $v_sort_value) { |
| 1701 | - $v_sort_flag=true; |
|
| 1701 | + $v_sort_flag = true; |
|
| 1702 | 1702 | |
| 1703 | 1703 | // ----- TBC : An automatic sort should be writen ... |
| 1704 | 1704 | // ----- Error log |
| 1705 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Invalid order of index range for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1705 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Invalid order of index range for option '" . PclZipUtilOptionText($p_options_list[$i]) . "'"); |
|
| 1706 | 1706 | |
| 1707 | 1707 | // ----- Return |
| 1708 | 1708 | return PclZip::errorCode(); |
@@ -1732,16 +1732,16 @@ discard block |
||
| 1732 | 1732 | // ----- Look for options that request an octal value |
| 1733 | 1733 | case PCLZIP_OPT_SET_CHMOD : |
| 1734 | 1734 | // ----- Check the number of parameters |
| 1735 | - if (($i+1) >= $p_size) { |
|
| 1735 | + if (($i + 1) >= $p_size) { |
|
| 1736 | 1736 | // ----- Error log |
| 1737 | - PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1737 | + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '" . PclZipUtilOptionText($p_options_list[$i]) . "'"); |
|
| 1738 | 1738 | |
| 1739 | 1739 | // ----- Return |
| 1740 | 1740 | return PclZip::errorCode(); |
| 1741 | 1741 | } |
| 1742 | 1742 | |
| 1743 | 1743 | // ----- Get the value |
| 1744 | - $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; |
|
| 1744 | + $v_result_list[$p_options_list[$i]] = $p_options_list[$i + 1]; |
|
| 1745 | 1745 | $i++; |
| 1746 | 1746 | break; |
| 1747 | 1747 | |
@@ -1757,21 +1757,21 @@ discard block |
||
| 1757 | 1757 | case PCLZIP_CB_POST_LIST : |
| 1758 | 1758 | */ |
| 1759 | 1759 | // ----- Check the number of parameters |
| 1760 | - if (($i+1) >= $p_size) { |
|
| 1760 | + if (($i + 1) >= $p_size) { |
|
| 1761 | 1761 | // ----- Error log |
| 1762 | - PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1762 | + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '" . PclZipUtilOptionText($p_options_list[$i]) . "'"); |
|
| 1763 | 1763 | |
| 1764 | 1764 | // ----- Return |
| 1765 | 1765 | return PclZip::errorCode(); |
| 1766 | 1766 | } |
| 1767 | 1767 | |
| 1768 | 1768 | // ----- Get the value |
| 1769 | - $v_function_name = $p_options_list[$i+1]; |
|
| 1769 | + $v_function_name = $p_options_list[$i + 1]; |
|
| 1770 | 1770 | |
| 1771 | 1771 | // ----- Check that the value is a valid existing function |
| 1772 | 1772 | if (!function_exists($v_function_name)) { |
| 1773 | 1773 | // ----- Error log |
| 1774 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Function '".$v_function_name."()' is not an existing function for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1774 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Function '" . $v_function_name . "()' is not an existing function for option '" . PclZipUtilOptionText($p_options_list[$i]) . "'"); |
|
| 1775 | 1775 | |
| 1776 | 1776 | // ----- Return |
| 1777 | 1777 | return PclZip::errorCode(); |
@@ -1786,7 +1786,7 @@ discard block |
||
| 1786 | 1786 | // ----- Error log |
| 1787 | 1787 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, |
| 1788 | 1788 | "Unknown parameter '" |
| 1789 | - .$p_options_list[$i]."'"); |
|
| 1789 | + .$p_options_list[$i] . "'"); |
|
| 1790 | 1790 | |
| 1791 | 1791 | // ----- Return |
| 1792 | 1792 | return PclZip::errorCode(); |
@@ -1798,13 +1798,13 @@ discard block |
||
| 1798 | 1798 | |
| 1799 | 1799 | // ----- Look for mandatory options |
| 1800 | 1800 | if ($v_requested_options !== false) { |
| 1801 | - for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) { |
|
| 1801 | + for ($key = reset($v_requested_options); $key = key($v_requested_options); $key = next($v_requested_options)) { |
|
| 1802 | 1802 | // ----- Look for mandatory option |
| 1803 | 1803 | if ($v_requested_options[$key] == 'mandatory') { |
| 1804 | 1804 | // ----- Look if present |
| 1805 | 1805 | if (!isset($v_result_list[$key])) { |
| 1806 | 1806 | // ----- Error log |
| 1807 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")"); |
|
| 1807 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter " . PclZipUtilOptionText($key) . "(" . $key . ")"); |
|
| 1808 | 1808 | |
| 1809 | 1809 | // ----- Return |
| 1810 | 1810 | return PclZip::errorCode(); |
@@ -1831,7 +1831,7 @@ discard block |
||
| 1831 | 1831 | // -------------------------------------------------------------------------------- |
| 1832 | 1832 | function privOptionDefaultThreshold(&$p_options) |
| 1833 | 1833 | { |
| 1834 | - $v_result=1; |
|
| 1834 | + $v_result = 1; |
|
| 1835 | 1835 | |
| 1836 | 1836 | if (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]) |
| 1837 | 1837 | || isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) { |
@@ -1843,16 +1843,16 @@ discard block |
||
| 1843 | 1843 | $v_memory_limit = trim($v_memory_limit); |
| 1844 | 1844 | $last = strtolower(substr($v_memory_limit, -1)); |
| 1845 | 1845 | |
| 1846 | - if($last == 'g') |
|
| 1846 | + if ($last == 'g') |
|
| 1847 | 1847 | //$v_memory_limit = $v_memory_limit*1024*1024*1024; |
| 1848 | - $v_memory_limit = $v_memory_limit*1073741824; |
|
| 1849 | - if($last == 'm') |
|
| 1848 | + $v_memory_limit = $v_memory_limit * 1073741824; |
|
| 1849 | + if ($last == 'm') |
|
| 1850 | 1850 | //$v_memory_limit = $v_memory_limit*1024*1024; |
| 1851 | - $v_memory_limit = $v_memory_limit*1048576; |
|
| 1852 | - if($last == 'k') |
|
| 1853 | - $v_memory_limit = $v_memory_limit*1024; |
|
| 1851 | + $v_memory_limit = $v_memory_limit * 1048576; |
|
| 1852 | + if ($last == 'k') |
|
| 1853 | + $v_memory_limit = $v_memory_limit * 1024; |
|
| 1854 | 1854 | |
| 1855 | - $p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] = floor($v_memory_limit*PCLZIP_TEMPORARY_FILE_RATIO); |
|
| 1855 | + $p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] = floor($v_memory_limit * PCLZIP_TEMPORARY_FILE_RATIO); |
|
| 1856 | 1856 | |
| 1857 | 1857 | |
| 1858 | 1858 | // ----- Sanity check : No threshold if value lower than 1M |
@@ -1873,9 +1873,9 @@ discard block |
||
| 1873 | 1873 | // 1 on success. |
| 1874 | 1874 | // 0 on failure. |
| 1875 | 1875 | // -------------------------------------------------------------------------------- |
| 1876 | - function privFileDescrParseAtt(&$p_file_list, &$p_filedescr, $v_options, $v_requested_options=false) |
|
| 1876 | + function privFileDescrParseAtt(&$p_file_list, &$p_filedescr, $v_options, $v_requested_options = false) |
|
| 1877 | 1877 | { |
| 1878 | - $v_result=1; |
|
| 1878 | + $v_result = 1; |
|
| 1879 | 1879 | |
| 1880 | 1880 | // ----- For each file in the list check the attributes |
| 1881 | 1881 | foreach ($p_file_list as $v_key => $v_value) { |
@@ -1883,7 +1883,7 @@ discard block |
||
| 1883 | 1883 | // ----- Check if the option is supported |
| 1884 | 1884 | if (!isset($v_requested_options[$v_key])) { |
| 1885 | 1885 | // ----- Error log |
| 1886 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file attribute '".$v_key."' for this file"); |
|
| 1886 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file attribute '" . $v_key . "' for this file"); |
|
| 1887 | 1887 | |
| 1888 | 1888 | // ----- Return |
| 1889 | 1889 | return PclZip::errorCode(); |
@@ -1893,14 +1893,14 @@ discard block |
||
| 1893 | 1893 | switch ($v_key) { |
| 1894 | 1894 | case PCLZIP_ATT_FILE_NAME : |
| 1895 | 1895 | if (!is_string($v_value)) { |
| 1896 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'"); |
|
| 1896 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type " . gettype($v_value) . ". String expected for attribute '" . PclZipUtilOptionText($v_key) . "'"); |
|
| 1897 | 1897 | return PclZip::errorCode(); |
| 1898 | 1898 | } |
| 1899 | 1899 | |
| 1900 | 1900 | $p_filedescr['filename'] = PclZipUtilPathReduction($v_value); |
| 1901 | 1901 | |
| 1902 | 1902 | if ($p_filedescr['filename'] == '') { |
| 1903 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty filename for attribute '".PclZipUtilOptionText($v_key)."'"); |
|
| 1903 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty filename for attribute '" . PclZipUtilOptionText($v_key) . "'"); |
|
| 1904 | 1904 | return PclZip::errorCode(); |
| 1905 | 1905 | } |
| 1906 | 1906 | |
@@ -1908,28 +1908,28 @@ discard block |
||
| 1908 | 1908 | |
| 1909 | 1909 | case PCLZIP_ATT_FILE_NEW_SHORT_NAME : |
| 1910 | 1910 | if (!is_string($v_value)) { |
| 1911 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'"); |
|
| 1911 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type " . gettype($v_value) . ". String expected for attribute '" . PclZipUtilOptionText($v_key) . "'"); |
|
| 1912 | 1912 | return PclZip::errorCode(); |
| 1913 | 1913 | } |
| 1914 | 1914 | |
| 1915 | 1915 | $p_filedescr['new_short_name'] = PclZipUtilPathReduction($v_value); |
| 1916 | 1916 | |
| 1917 | 1917 | if ($p_filedescr['new_short_name'] == '') { |
| 1918 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty short filename for attribute '".PclZipUtilOptionText($v_key)."'"); |
|
| 1918 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty short filename for attribute '" . PclZipUtilOptionText($v_key) . "'"); |
|
| 1919 | 1919 | return PclZip::errorCode(); |
| 1920 | 1920 | } |
| 1921 | 1921 | break; |
| 1922 | 1922 | |
| 1923 | 1923 | case PCLZIP_ATT_FILE_NEW_FULL_NAME : |
| 1924 | 1924 | if (!is_string($v_value)) { |
| 1925 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'"); |
|
| 1925 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type " . gettype($v_value) . ". String expected for attribute '" . PclZipUtilOptionText($v_key) . "'"); |
|
| 1926 | 1926 | return PclZip::errorCode(); |
| 1927 | 1927 | } |
| 1928 | 1928 | |
| 1929 | 1929 | $p_filedescr['new_full_name'] = PclZipUtilPathReduction($v_value); |
| 1930 | 1930 | |
| 1931 | 1931 | if ($p_filedescr['new_full_name'] == '') { |
| 1932 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty full filename for attribute '".PclZipUtilOptionText($v_key)."'"); |
|
| 1932 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty full filename for attribute '" . PclZipUtilOptionText($v_key) . "'"); |
|
| 1933 | 1933 | return PclZip::errorCode(); |
| 1934 | 1934 | } |
| 1935 | 1935 | break; |
@@ -1937,7 +1937,7 @@ discard block |
||
| 1937 | 1937 | // ----- Look for options that takes a string |
| 1938 | 1938 | case PCLZIP_ATT_FILE_COMMENT : |
| 1939 | 1939 | if (!is_string($v_value)) { |
| 1940 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'"); |
|
| 1940 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type " . gettype($v_value) . ". String expected for attribute '" . PclZipUtilOptionText($v_key) . "'"); |
|
| 1941 | 1941 | return PclZip::errorCode(); |
| 1942 | 1942 | } |
| 1943 | 1943 | |
@@ -1946,7 +1946,7 @@ discard block |
||
| 1946 | 1946 | |
| 1947 | 1947 | case PCLZIP_ATT_FILE_MTIME : |
| 1948 | 1948 | if (!is_integer($v_value)) { |
| 1949 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". Integer expected for attribute '".PclZipUtilOptionText($v_key)."'"); |
|
| 1949 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type " . gettype($v_value) . ". Integer expected for attribute '" . PclZipUtilOptionText($v_key) . "'"); |
|
| 1950 | 1950 | return PclZip::errorCode(); |
| 1951 | 1951 | } |
| 1952 | 1952 | |
@@ -1960,7 +1960,7 @@ discard block |
||
| 1960 | 1960 | default : |
| 1961 | 1961 | // ----- Error log |
| 1962 | 1962 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, |
| 1963 | - "Unknown parameter '".$v_key."'"); |
|
| 1963 | + "Unknown parameter '" . $v_key . "'"); |
|
| 1964 | 1964 | |
| 1965 | 1965 | // ----- Return |
| 1966 | 1966 | return PclZip::errorCode(); |
@@ -1968,12 +1968,12 @@ discard block |
||
| 1968 | 1968 | |
| 1969 | 1969 | // ----- Look for mandatory options |
| 1970 | 1970 | if ($v_requested_options !== false) { |
| 1971 | - for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) { |
|
| 1971 | + for ($key = reset($v_requested_options); $key = key($v_requested_options); $key = next($v_requested_options)) { |
|
| 1972 | 1972 | // ----- Look for mandatory option |
| 1973 | 1973 | if ($v_requested_options[$key] == 'mandatory') { |
| 1974 | 1974 | // ----- Look if present |
| 1975 | 1975 | if (!isset($p_file_list[$key])) { |
| 1976 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")"); |
|
| 1976 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter " . PclZipUtilOptionText($key) . "(" . $key . ")"); |
|
| 1977 | 1977 | return PclZip::errorCode(); |
| 1978 | 1978 | } |
| 1979 | 1979 | } |
@@ -2004,13 +2004,13 @@ discard block |
||
| 2004 | 2004 | // -------------------------------------------------------------------------------- |
| 2005 | 2005 | function privFileDescrExpand(&$p_filedescr_list, &$p_options) |
| 2006 | 2006 | { |
| 2007 | - $v_result=1; |
|
| 2007 | + $v_result = 1; |
|
| 2008 | 2008 | |
| 2009 | 2009 | // ----- Create a result list |
| 2010 | 2010 | $v_result_list = array(); |
| 2011 | 2011 | |
| 2012 | 2012 | // ----- Look each entry |
| 2013 | - for ($i=0; $i<sizeof($p_filedescr_list); $i++) { |
|
| 2013 | + for ($i = 0; $i < sizeof($p_filedescr_list); $i++) { |
|
| 2014 | 2014 | |
| 2015 | 2015 | // ----- Get filedescr |
| 2016 | 2016 | $v_descr = $p_filedescr_list[$i]; |
@@ -2045,7 +2045,7 @@ discard block |
||
| 2045 | 2045 | // ----- Missing file |
| 2046 | 2046 | else { |
| 2047 | 2047 | // ----- Error log |
| 2048 | - PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$v_descr['filename']."' does not exist"); |
|
| 2048 | + PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '" . $v_descr['filename'] . "' does not exist"); |
|
| 2049 | 2049 | |
| 2050 | 2050 | // ----- Return |
| 2051 | 2051 | return PclZip::errorCode(); |
@@ -2071,7 +2071,7 @@ discard block |
||
| 2071 | 2071 | } |
| 2072 | 2072 | |
| 2073 | 2073 | // ----- Compose the full filename |
| 2074 | - $v_dirlist_descr[$v_dirlist_nb]['filename'] = $v_descr['filename'].'/'.$v_item_handler; |
|
| 2074 | + $v_dirlist_descr[$v_dirlist_nb]['filename'] = $v_descr['filename'] . '/' . $v_item_handler; |
|
| 2075 | 2075 | |
| 2076 | 2076 | // ----- Look for different stored filename |
| 2077 | 2077 | // Because the name of the folder was changed, the name of the |
@@ -2079,7 +2079,7 @@ discard block |
||
| 2079 | 2079 | if (($v_descr['stored_filename'] != $v_descr['filename']) |
| 2080 | 2080 | && (!isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))) { |
| 2081 | 2081 | if ($v_descr['stored_filename'] != '') { |
| 2082 | - $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_descr['stored_filename'].'/'.$v_item_handler; |
|
| 2082 | + $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_descr['stored_filename'] . '/' . $v_item_handler; |
|
| 2083 | 2083 | } |
| 2084 | 2084 | else { |
| 2085 | 2085 | $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_item_handler; |
@@ -2129,7 +2129,7 @@ discard block |
||
| 2129 | 2129 | // -------------------------------------------------------------------------------- |
| 2130 | 2130 | function privCreate($p_filedescr_list, &$p_result_list, &$p_options) |
| 2131 | 2131 | { |
| 2132 | - $v_result=1; |
|
| 2132 | + $v_result = 1; |
|
| 2133 | 2133 | $v_list_detail = array(); |
| 2134 | 2134 | |
| 2135 | 2135 | // ----- Magic quotes trick |
@@ -2164,7 +2164,7 @@ discard block |
||
| 2164 | 2164 | // -------------------------------------------------------------------------------- |
| 2165 | 2165 | function privAdd($p_filedescr_list, &$p_result_list, &$p_options) |
| 2166 | 2166 | { |
| 2167 | - $v_result=1; |
|
| 2167 | + $v_result = 1; |
|
| 2168 | 2168 | $v_list_detail = array(); |
| 2169 | 2169 | |
| 2170 | 2170 | // ----- Look if the archive exists or is empty |
@@ -2181,7 +2181,7 @@ discard block |
||
| 2181 | 2181 | $this->privDisableMagicQuotes(); |
| 2182 | 2182 | |
| 2183 | 2183 | // ----- Open the zip file |
| 2184 | - if (($v_result=$this->privOpenFd('rb')) != 1) |
|
| 2184 | + if (($v_result = $this->privOpenFd('rb')) != 1) |
|
| 2185 | 2185 | { |
| 2186 | 2186 | // ----- Magic quotes trick |
| 2187 | 2187 | $this->privSwapBackMagicQuotes(); |
@@ -2203,7 +2203,7 @@ discard block |
||
| 2203 | 2203 | @rewind($this->zip_fd); |
| 2204 | 2204 | |
| 2205 | 2205 | // ----- Creates a temporay file |
| 2206 | - $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp'; |
|
| 2206 | + $v_zip_temp_name = PCLZIP_TEMPORARY_DIR . uniqid('pclzip-') . '.tmp'; |
|
| 2207 | 2207 | |
| 2208 | 2208 | // ----- Open the temporary file in write mode |
| 2209 | 2209 | if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0) |
@@ -2211,7 +2211,7 @@ discard block |
||
| 2211 | 2211 | $this->privCloseFd(); |
| 2212 | 2212 | $this->privSwapBackMagicQuotes(); |
| 2213 | 2213 | |
| 2214 | - PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode'); |
|
| 2214 | + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \'' . $v_zip_temp_name . '\' in binary write mode'); |
|
| 2215 | 2215 | |
| 2216 | 2216 | // ----- Return |
| 2217 | 2217 | return PclZip::errorCode(); |
@@ -2262,7 +2262,7 @@ discard block |
||
| 2262 | 2262 | } |
| 2263 | 2263 | |
| 2264 | 2264 | // ----- Create the Central Dir files header |
| 2265 | - for ($i=0, $v_count=0; $i<sizeof($v_header_list); $i++) |
|
| 2265 | + for ($i = 0, $v_count = 0; $i < sizeof($v_header_list); $i++) |
|
| 2266 | 2266 | { |
| 2267 | 2267 | // ----- Create the file header |
| 2268 | 2268 | if ($v_header_list[$i]['status'] == 'ok') { |
@@ -2288,17 +2288,17 @@ discard block |
||
| 2288 | 2288 | $v_comment = $p_options[PCLZIP_OPT_COMMENT]; |
| 2289 | 2289 | } |
| 2290 | 2290 | if (isset($p_options[PCLZIP_OPT_ADD_COMMENT])) { |
| 2291 | - $v_comment = $v_comment.$p_options[PCLZIP_OPT_ADD_COMMENT]; |
|
| 2291 | + $v_comment = $v_comment . $p_options[PCLZIP_OPT_ADD_COMMENT]; |
|
| 2292 | 2292 | } |
| 2293 | 2293 | if (isset($p_options[PCLZIP_OPT_PREPEND_COMMENT])) { |
| 2294 | - $v_comment = $p_options[PCLZIP_OPT_PREPEND_COMMENT].$v_comment; |
|
| 2294 | + $v_comment = $p_options[PCLZIP_OPT_PREPEND_COMMENT] . $v_comment; |
|
| 2295 | 2295 | } |
| 2296 | 2296 | |
| 2297 | 2297 | // ----- Calculate the size of the central header |
| 2298 | - $v_size = @ftell($this->zip_fd)-$v_offset; |
|
| 2298 | + $v_size = @ftell($this->zip_fd) - $v_offset; |
|
| 2299 | 2299 | |
| 2300 | 2300 | // ----- Create the central dir footer |
| 2301 | - if (($v_result = $this->privWriteCentralHeader($v_count+$v_central_dir['entries'], $v_size, $v_offset, $v_comment)) != 1) |
|
| 2301 | + if (($v_result = $this->privWriteCentralHeader($v_count + $v_central_dir['entries'], $v_size, $v_offset, $v_comment)) != 1) |
|
| 2302 | 2302 | { |
| 2303 | 2303 | // ----- Reset the file list |
| 2304 | 2304 | unset($v_header_list); |
@@ -2343,13 +2343,13 @@ discard block |
||
| 2343 | 2343 | // -------------------------------------------------------------------------------- |
| 2344 | 2344 | function privOpenFd($p_mode) |
| 2345 | 2345 | { |
| 2346 | - $v_result=1; |
|
| 2346 | + $v_result = 1; |
|
| 2347 | 2347 | |
| 2348 | 2348 | // ----- Look if already open |
| 2349 | 2349 | if ($this->zip_fd != 0) |
| 2350 | 2350 | { |
| 2351 | 2351 | // ----- Error log |
| 2352 | - PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Zip file \''.$this->zipname.'\' already open'); |
|
| 2352 | + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Zip file \'' . $this->zipname . '\' already open'); |
|
| 2353 | 2353 | |
| 2354 | 2354 | // ----- Return |
| 2355 | 2355 | return PclZip::errorCode(); |
@@ -2359,7 +2359,7 @@ discard block |
||
| 2359 | 2359 | if (($this->zip_fd = @fopen($this->zipname, $p_mode)) == 0) |
| 2360 | 2360 | { |
| 2361 | 2361 | // ----- Error log |
| 2362 | - PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in '.$p_mode.' mode'); |
|
| 2362 | + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \'' . $this->zipname . '\' in ' . $p_mode . ' mode'); |
|
| 2363 | 2363 | |
| 2364 | 2364 | // ----- Return |
| 2365 | 2365 | return PclZip::errorCode(); |
@@ -2377,7 +2377,7 @@ discard block |
||
| 2377 | 2377 | // -------------------------------------------------------------------------------- |
| 2378 | 2378 | function privCloseFd() |
| 2379 | 2379 | { |
| 2380 | - $v_result=1; |
|
| 2380 | + $v_result = 1; |
|
| 2381 | 2381 | |
| 2382 | 2382 | if ($this->zip_fd != 0) |
| 2383 | 2383 | @fclose($this->zip_fd); |
@@ -2404,7 +2404,7 @@ discard block |
||
| 2404 | 2404 | // function privAddList($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options) |
| 2405 | 2405 | function privAddList($p_filedescr_list, &$p_result_list, &$p_options) |
| 2406 | 2406 | { |
| 2407 | - $v_result=1; |
|
| 2407 | + $v_result = 1; |
|
| 2408 | 2408 | |
| 2409 | 2409 | // ----- Add the files |
| 2410 | 2410 | $v_header_list = array(); |
@@ -2418,7 +2418,7 @@ discard block |
||
| 2418 | 2418 | $v_offset = @ftell($this->zip_fd); |
| 2419 | 2419 | |
| 2420 | 2420 | // ----- Create the Central Dir files header |
| 2421 | - for ($i=0,$v_count=0; $i<sizeof($v_header_list); $i++) |
|
| 2421 | + for ($i = 0, $v_count = 0; $i < sizeof($v_header_list); $i++) |
|
| 2422 | 2422 | { |
| 2423 | 2423 | // ----- Create the file header |
| 2424 | 2424 | if ($v_header_list[$i]['status'] == 'ok') { |
@@ -2440,7 +2440,7 @@ discard block |
||
| 2440 | 2440 | } |
| 2441 | 2441 | |
| 2442 | 2442 | // ----- Calculate the size of the central header |
| 2443 | - $v_size = @ftell($this->zip_fd)-$v_offset; |
|
| 2443 | + $v_size = @ftell($this->zip_fd) - $v_offset; |
|
| 2444 | 2444 | |
| 2445 | 2445 | // ----- Create the central dir footer |
| 2446 | 2446 | if (($v_result = $this->privWriteCentralHeader($v_count, $v_size, $v_offset, $v_comment)) != 1) |
@@ -2468,14 +2468,14 @@ discard block |
||
| 2468 | 2468 | // -------------------------------------------------------------------------------- |
| 2469 | 2469 | function privAddFileList($p_filedescr_list, &$p_result_list, &$p_options) |
| 2470 | 2470 | { |
| 2471 | - $v_result=1; |
|
| 2471 | + $v_result = 1; |
|
| 2472 | 2472 | $v_header = array(); |
| 2473 | 2473 | |
| 2474 | 2474 | // ----- Recuperate the current number of elt in list |
| 2475 | 2475 | $v_nb = sizeof($p_result_list); |
| 2476 | 2476 | |
| 2477 | 2477 | // ----- Loop on the files |
| 2478 | - for ($j=0; ($j<sizeof($p_filedescr_list)) && ($v_result==1); $j++) { |
|
| 2478 | + for ($j = 0; ($j < sizeof($p_filedescr_list)) && ($v_result == 1); $j++) { |
|
| 2479 | 2479 | // ----- Format the filename |
| 2480 | 2480 | $p_filedescr_list[$j]['filename'] |
| 2481 | 2481 | = PclZipUtilTranslateWinPath($p_filedescr_list[$j]['filename'], false); |
@@ -2488,9 +2488,9 @@ discard block |
||
| 2488 | 2488 | } |
| 2489 | 2489 | |
| 2490 | 2490 | // ----- Check the filename |
| 2491 | - if ( ($p_filedescr_list[$j]['type'] != 'virtual_file') |
|
| 2491 | + if (($p_filedescr_list[$j]['type'] != 'virtual_file') |
|
| 2492 | 2492 | && (!file_exists($p_filedescr_list[$j]['filename']))) { |
| 2493 | - PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$p_filedescr_list[$j]['filename']."' does not exist"); |
|
| 2493 | + PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '" . $p_filedescr_list[$j]['filename'] . "' does not exist"); |
|
| 2494 | 2494 | return PclZip::errorCode(); |
| 2495 | 2495 | } |
| 2496 | 2496 | |
@@ -2498,10 +2498,10 @@ discard block |
||
| 2498 | 2498 | // or a dir with all its path removed |
| 2499 | 2499 | // if ( (is_file($p_filedescr_list[$j]['filename'])) |
| 2500 | 2500 | // || ( is_dir($p_filedescr_list[$j]['filename']) |
| 2501 | - if ( ($p_filedescr_list[$j]['type'] == 'file') |
|
| 2501 | + if (($p_filedescr_list[$j]['type'] == 'file') |
|
| 2502 | 2502 | || ($p_filedescr_list[$j]['type'] == 'virtual_file') |
| 2503 | - || ( ($p_filedescr_list[$j]['type'] == 'folder') |
|
| 2504 | - && ( !isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH]) |
|
| 2503 | + || (($p_filedescr_list[$j]['type'] == 'folder') |
|
| 2504 | + && (!isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH]) |
|
| 2505 | 2505 | || !$p_options[PCLZIP_OPT_REMOVE_ALL_PATH])) |
| 2506 | 2506 | ) { |
| 2507 | 2507 | |
@@ -2530,7 +2530,7 @@ discard block |
||
| 2530 | 2530 | // -------------------------------------------------------------------------------- |
| 2531 | 2531 | function privAddFile($p_filedescr, &$p_header, &$p_options) |
| 2532 | 2532 | { |
| 2533 | - $v_result=1; |
|
| 2533 | + $v_result = 1; |
|
| 2534 | 2534 | |
| 2535 | 2535 | // ----- Working variable |
| 2536 | 2536 | $p_filename = $p_filedescr['filename']; |
@@ -2575,13 +2575,13 @@ discard block |
||
| 2575 | 2575 | $p_header['index'] = -1; |
| 2576 | 2576 | |
| 2577 | 2577 | // ----- Look for regular file |
| 2578 | - if ($p_filedescr['type']=='file') { |
|
| 2578 | + if ($p_filedescr['type'] == 'file') { |
|
| 2579 | 2579 | $p_header['external'] = 0x00000000; |
| 2580 | 2580 | $p_header['size'] = filesize($p_filename); |
| 2581 | 2581 | } |
| 2582 | 2582 | |
| 2583 | 2583 | // ----- Look for regular folder |
| 2584 | - else if ($p_filedescr['type']=='folder') { |
|
| 2584 | + else if ($p_filedescr['type'] == 'folder') { |
|
| 2585 | 2585 | $p_header['external'] = 0x00000010; |
| 2586 | 2586 | $p_header['mtime'] = filemtime($p_filename); |
| 2587 | 2587 | $p_header['size'] = filesize($p_filename); |
@@ -2656,10 +2656,10 @@ discard block |
||
| 2656 | 2656 | // ----- Look for a file |
| 2657 | 2657 | if ($p_filedescr['type'] == 'file') { |
| 2658 | 2658 | // ----- Look for using temporary file to zip |
| 2659 | - if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) |
|
| 2659 | + if ((!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) |
|
| 2660 | 2660 | && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON]) |
| 2661 | 2661 | || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]) |
| 2662 | - && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_header['size'])) ) ) { |
|
| 2662 | + && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_header['size'])))) { |
|
| 2663 | 2663 | $v_result = $this->privAddFileUsingTempFile($p_filedescr, $p_header, $p_options); |
| 2664 | 2664 | if ($v_result < PCLZIP_ERR_NO_ERROR) { |
| 2665 | 2665 | return $v_result; |
@@ -2759,7 +2759,7 @@ discard block |
||
| 2759 | 2759 | // ----- Set the file properties |
| 2760 | 2760 | $p_header['size'] = 0; |
| 2761 | 2761 | //$p_header['external'] = 0x41FF0010; // Value for a folder : to be checked |
| 2762 | - $p_header['external'] = 0x00000010; // Value for a folder : to be checked |
|
| 2762 | + $p_header['external'] = 0x00000010; // Value for a folder : to be checked |
|
| 2763 | 2763 | |
| 2764 | 2764 | // ----- Call the header generation |
| 2765 | 2765 | if (($v_result = $this->privWriteFileHeader($p_header)) != 1) |
@@ -2803,7 +2803,7 @@ discard block |
||
| 2803 | 2803 | // -------------------------------------------------------------------------------- |
| 2804 | 2804 | function privAddFileUsingTempFile($p_filedescr, &$p_header, &$p_options) |
| 2805 | 2805 | { |
| 2806 | - $v_result=PCLZIP_ERR_NO_ERROR; |
|
| 2806 | + $v_result = PCLZIP_ERR_NO_ERROR; |
|
| 2807 | 2807 | |
| 2808 | 2808 | // ----- Working variable |
| 2809 | 2809 | $p_filename = $p_filedescr['filename']; |
@@ -2816,10 +2816,10 @@ discard block |
||
| 2816 | 2816 | } |
| 2817 | 2817 | |
| 2818 | 2818 | // ----- Creates a compressed temporary file |
| 2819 | - $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz'; |
|
| 2819 | + $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR . uniqid('pclzip-') . '.gz'; |
|
| 2820 | 2820 | if (($v_file_compressed = @gzopen($v_gzip_temp_name, "wb")) == 0) { |
| 2821 | 2821 | fclose($v_file); |
| 2822 | - PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode'); |
|
| 2822 | + PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \'' . $v_gzip_temp_name . '\' in binary write mode'); |
|
| 2823 | 2823 | return PclZip::errorCode(); |
| 2824 | 2824 | } |
| 2825 | 2825 | |
@@ -2839,13 +2839,13 @@ discard block |
||
| 2839 | 2839 | |
| 2840 | 2840 | // ----- Check the minimum file size |
| 2841 | 2841 | if (filesize($v_gzip_temp_name) < 18) { |
| 2842 | - PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'gzip temporary file \''.$v_gzip_temp_name.'\' has invalid filesize - should be minimum 18 bytes'); |
|
| 2842 | + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'gzip temporary file \'' . $v_gzip_temp_name . '\' has invalid filesize - should be minimum 18 bytes'); |
|
| 2843 | 2843 | return PclZip::errorCode(); |
| 2844 | 2844 | } |
| 2845 | 2845 | |
| 2846 | 2846 | // ----- Extract the compressed attributes |
| 2847 | 2847 | if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0) { |
| 2848 | - PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode'); |
|
| 2848 | + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \'' . $v_gzip_temp_name . '\' in binary read mode'); |
|
| 2849 | 2849 | return PclZip::errorCode(); |
| 2850 | 2850 | } |
| 2851 | 2851 | |
@@ -2857,7 +2857,7 @@ discard block |
||
| 2857 | 2857 | $v_data_header['os'] = bin2hex($v_data_header['os']); |
| 2858 | 2858 | |
| 2859 | 2859 | // ----- Read the gzip file footer |
| 2860 | - @fseek($v_file_compressed, filesize($v_gzip_temp_name)-8); |
|
| 2860 | + @fseek($v_file_compressed, filesize($v_gzip_temp_name) - 8); |
|
| 2861 | 2861 | $v_binary_data = @fread($v_file_compressed, 8); |
| 2862 | 2862 | $v_data_footer = unpack('Vcrc/Vcompressed_size', $v_binary_data); |
| 2863 | 2863 | |
@@ -2865,7 +2865,7 @@ discard block |
||
| 2865 | 2865 | $p_header['compression'] = ord($v_data_header['cm']); |
| 2866 | 2866 | //$p_header['mtime'] = $v_data_header['mtime']; |
| 2867 | 2867 | $p_header['crc'] = $v_data_footer['crc']; |
| 2868 | - $p_header['compressed_size'] = filesize($v_gzip_temp_name)-18; |
|
| 2868 | + $p_header['compressed_size'] = filesize($v_gzip_temp_name) - 18; |
|
| 2869 | 2869 | |
| 2870 | 2870 | // ----- Close the file |
| 2871 | 2871 | @fclose($v_file_compressed); |
@@ -2878,7 +2878,7 @@ discard block |
||
| 2878 | 2878 | // ----- Add the compressed data |
| 2879 | 2879 | if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0) |
| 2880 | 2880 | { |
| 2881 | - PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode'); |
|
| 2881 | + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \'' . $v_gzip_temp_name . '\' in binary read mode'); |
|
| 2882 | 2882 | return PclZip::errorCode(); |
| 2883 | 2883 | } |
| 2884 | 2884 | |
@@ -2915,7 +2915,7 @@ discard block |
||
| 2915 | 2915 | // -------------------------------------------------------------------------------- |
| 2916 | 2916 | function privCalculateStoredFilename(&$p_filedescr, &$p_options) |
| 2917 | 2917 | { |
| 2918 | - $v_result=1; |
|
| 2918 | + $v_result = 1; |
|
| 2919 | 2919 | |
| 2920 | 2920 | // ----- Working variables |
| 2921 | 2921 | $p_filename = $p_filedescr['filename']; |
@@ -2954,9 +2954,9 @@ discard block |
||
| 2954 | 2954 | $v_path_info = pathinfo($p_filename); |
| 2955 | 2955 | $v_dir = ''; |
| 2956 | 2956 | if ($v_path_info['dirname'] != '') { |
| 2957 | - $v_dir = $v_path_info['dirname'].'/'; |
|
| 2957 | + $v_dir = $v_path_info['dirname'] . '/'; |
|
| 2958 | 2958 | } |
| 2959 | - $v_stored_filename = $v_dir.$p_filedescr['new_short_name']; |
|
| 2959 | + $v_stored_filename = $v_dir . $p_filedescr['new_short_name']; |
|
| 2960 | 2960 | } |
| 2961 | 2961 | else { |
| 2962 | 2962 | // ----- Calculate the stored filename |
@@ -2972,14 +2972,14 @@ discard block |
||
| 2972 | 2972 | if (substr($p_remove_dir, -1) != '/') |
| 2973 | 2973 | $p_remove_dir .= "/"; |
| 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 | |
| 2978 | - if ( (substr($p_filename, 0, 2) == "./") |
|
| 2978 | + if ((substr($p_filename, 0, 2) == "./") |
|
| 2979 | 2979 | && (substr($p_remove_dir, 0, 2) != "./")) { |
| 2980 | - $p_remove_dir = "./".$p_remove_dir; |
|
| 2980 | + $p_remove_dir = "./" . $p_remove_dir; |
|
| 2981 | 2981 | } |
| 2982 | - if ( (substr($p_filename, 0, 2) != "./") |
|
| 2982 | + if ((substr($p_filename, 0, 2) != "./") |
|
| 2983 | 2983 | && (substr($p_remove_dir, 0, 2) == "./")) { |
| 2984 | 2984 | $p_remove_dir = substr($p_remove_dir, 2); |
| 2985 | 2985 | } |
@@ -3004,9 +3004,9 @@ discard block |
||
| 3004 | 3004 | // ----- Look for path to add |
| 3005 | 3005 | if ($p_add_dir != "") { |
| 3006 | 3006 | if (substr($p_add_dir, -1) == "/") |
| 3007 | - $v_stored_filename = $p_add_dir.$v_stored_filename; |
|
| 3007 | + $v_stored_filename = $p_add_dir . $v_stored_filename; |
|
| 3008 | 3008 | else |
| 3009 | - $v_stored_filename = $p_add_dir."/".$v_stored_filename; |
|
| 3009 | + $v_stored_filename = $p_add_dir . "/" . $v_stored_filename; |
|
| 3010 | 3010 | } |
| 3011 | 3011 | } |
| 3012 | 3012 | |
@@ -3027,15 +3027,15 @@ discard block |
||
| 3027 | 3027 | // -------------------------------------------------------------------------------- |
| 3028 | 3028 | function privWriteFileHeader(&$p_header) |
| 3029 | 3029 | { |
| 3030 | - $v_result=1; |
|
| 3030 | + $v_result = 1; |
|
| 3031 | 3031 | |
| 3032 | 3032 | // ----- Store the offset position of the file |
| 3033 | 3033 | $p_header['offset'] = ftell($this->zip_fd); |
| 3034 | 3034 | |
| 3035 | 3035 | // ----- Transform UNIX mtime to DOS format mdate/mtime |
| 3036 | 3036 | $v_date = getdate($p_header['mtime']); |
| 3037 | - $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2; |
|
| 3038 | - $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday']; |
|
| 3037 | + $v_mtime = ($v_date['hours'] << 11) + ($v_date['minutes'] << 5) + $v_date['seconds'] / 2; |
|
| 3038 | + $v_mdate = (($v_date['year'] - 1980) << 9) + ($v_date['mon'] << 5) + $v_date['mday']; |
|
| 3039 | 3039 | |
| 3040 | 3040 | // ----- Packed data |
| 3041 | 3041 | $v_binary_data = pack("VvvvvvVVVvv", 0x04034b50, |
@@ -3072,7 +3072,7 @@ discard block |
||
| 3072 | 3072 | // -------------------------------------------------------------------------------- |
| 3073 | 3073 | function privWriteCentralFileHeader(&$p_header) |
| 3074 | 3074 | { |
| 3075 | - $v_result=1; |
|
| 3075 | + $v_result = 1; |
|
| 3076 | 3076 | |
| 3077 | 3077 | // TBC |
| 3078 | 3078 | //for(reset($p_header); $key = key($p_header); next($p_header)) { |
@@ -3080,8 +3080,8 @@ discard block |
||
| 3080 | 3080 | |
| 3081 | 3081 | // ----- Transform UNIX mtime to DOS format mdate/mtime |
| 3082 | 3082 | $v_date = getdate($p_header['mtime']); |
| 3083 | - $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2; |
|
| 3084 | - $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday']; |
|
| 3083 | + $v_mtime = ($v_date['hours'] << 11) + ($v_date['minutes'] << 5) + $v_date['seconds'] / 2; |
|
| 3084 | + $v_mdate = (($v_date['year'] - 1980) << 9) + ($v_date['mon'] << 5) + $v_date['mday']; |
|
| 3085 | 3085 | |
| 3086 | 3086 | |
| 3087 | 3087 | // ----- Packed data |
@@ -3125,7 +3125,7 @@ discard block |
||
| 3125 | 3125 | // -------------------------------------------------------------------------------- |
| 3126 | 3126 | function privWriteCentralHeader($p_nb_entries, $p_size, $p_offset, $p_comment) |
| 3127 | 3127 | { |
| 3128 | - $v_result=1; |
|
| 3128 | + $v_result = 1; |
|
| 3129 | 3129 | |
| 3130 | 3130 | // ----- Packed data |
| 3131 | 3131 | $v_binary_data = pack("VvvvvVVv", 0x06054b50, 0, 0, $p_nb_entries, |
@@ -3154,7 +3154,7 @@ discard block |
||
| 3154 | 3154 | // -------------------------------------------------------------------------------- |
| 3155 | 3155 | function privList(&$p_list) |
| 3156 | 3156 | { |
| 3157 | - $v_result=1; |
|
| 3157 | + $v_result = 1; |
|
| 3158 | 3158 | |
| 3159 | 3159 | // ----- Magic quotes trick |
| 3160 | 3160 | $this->privDisableMagicQuotes(); |
@@ -3166,7 +3166,7 @@ discard block |
||
| 3166 | 3166 | $this->privSwapBackMagicQuotes(); |
| 3167 | 3167 | |
| 3168 | 3168 | // ----- Error log |
| 3169 | - PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode'); |
|
| 3169 | + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \'' . $this->zipname . '\' in binary read mode'); |
|
| 3170 | 3170 | |
| 3171 | 3171 | // ----- Return |
| 3172 | 3172 | return PclZip::errorCode(); |
@@ -3194,7 +3194,7 @@ discard block |
||
| 3194 | 3194 | } |
| 3195 | 3195 | |
| 3196 | 3196 | // ----- Read each entry |
| 3197 | - for ($i=0; $i<$v_central_dir['entries']; $i++) |
|
| 3197 | + for ($i = 0; $i < $v_central_dir['entries']; $i++) |
|
| 3198 | 3198 | { |
| 3199 | 3199 | // ----- Read the file header |
| 3200 | 3200 | if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1) |
@@ -3241,7 +3241,7 @@ discard block |
||
| 3241 | 3241 | // -------------------------------------------------------------------------------- |
| 3242 | 3242 | function privConvertHeader2FileInfo($p_header, &$p_info) |
| 3243 | 3243 | { |
| 3244 | - $v_result=1; |
|
| 3244 | + $v_result = 1; |
|
| 3245 | 3245 | |
| 3246 | 3246 | // ----- Get the interesting attributes |
| 3247 | 3247 | $v_temp_path = PclZipUtilPathReduction($p_header['filename']); |
@@ -3252,7 +3252,7 @@ discard block |
||
| 3252 | 3252 | $p_info['compressed_size'] = $p_header['compressed_size']; |
| 3253 | 3253 | $p_info['mtime'] = $p_header['mtime']; |
| 3254 | 3254 | $p_info['comment'] = $p_header['comment']; |
| 3255 | - $p_info['folder'] = (($p_header['external']&0x00000010)==0x00000010); |
|
| 3255 | + $p_info['folder'] = (($p_header['external'] & 0x00000010) == 0x00000010); |
|
| 3256 | 3256 | $p_info['index'] = $p_header['index']; |
| 3257 | 3257 | $p_info['status'] = $p_header['status']; |
| 3258 | 3258 | $p_info['crc'] = $p_header['crc']; |
@@ -3280,17 +3280,17 @@ discard block |
||
| 3280 | 3280 | // -------------------------------------------------------------------------------- |
| 3281 | 3281 | function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all_path, &$p_options) |
| 3282 | 3282 | { |
| 3283 | - $v_result=1; |
|
| 3283 | + $v_result = 1; |
|
| 3284 | 3284 | |
| 3285 | 3285 | // ----- Magic quotes trick |
| 3286 | 3286 | $this->privDisableMagicQuotes(); |
| 3287 | 3287 | |
| 3288 | 3288 | // ----- Check the path |
| 3289 | - if ( ($p_path == "") |
|
| 3290 | - || ( (substr($p_path, 0, 1) != "/") |
|
| 3289 | + if (($p_path == "") |
|
| 3290 | + || ((substr($p_path, 0, 1) != "/") |
|
| 3291 | 3291 | && (substr($p_path, 0, 3) != "../") |
| 3292 | - && (substr($p_path,1,2)!=":/"))) |
|
| 3293 | - $p_path = "./".$p_path; |
|
| 3292 | + && (substr($p_path, 1, 2) != ":/"))) |
|
| 3293 | + $p_path = "./" . $p_path; |
|
| 3294 | 3294 | |
| 3295 | 3295 | // ----- Reduce the path last (and duplicated) '/' |
| 3296 | 3296 | if (($p_path != "./") && ($p_path != "/")) |
@@ -3298,7 +3298,7 @@ discard block |
||
| 3298 | 3298 | // ----- Look for the path end '/' |
| 3299 | 3299 | while (substr($p_path, -1) == "/") |
| 3300 | 3300 | { |
| 3301 | - $p_path = substr($p_path, 0, strlen($p_path)-1); |
|
| 3301 | + $p_path = substr($p_path, 0, strlen($p_path) - 1); |
|
| 3302 | 3302 | } |
| 3303 | 3303 | } |
| 3304 | 3304 | |
@@ -3332,7 +3332,7 @@ discard block |
||
| 3332 | 3332 | |
| 3333 | 3333 | // ----- Read each entry |
| 3334 | 3334 | $j_start = 0; |
| 3335 | - for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++) |
|
| 3335 | + for ($i = 0, $v_nb_extracted = 0; $i < $v_central_dir['entries']; $i++) |
|
| 3336 | 3336 | { |
| 3337 | 3337 | |
| 3338 | 3338 | // ----- Read next Central dir entry |
@@ -3371,17 +3371,17 @@ discard block |
||
| 3371 | 3371 | $v_extract = false; |
| 3372 | 3372 | |
| 3373 | 3373 | // ----- Look for extract by name rule |
| 3374 | - if ( (isset($p_options[PCLZIP_OPT_BY_NAME])) |
|
| 3374 | + if ((isset($p_options[PCLZIP_OPT_BY_NAME])) |
|
| 3375 | 3375 | && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) { |
| 3376 | 3376 | |
| 3377 | 3377 | // ----- Look if the filename is in the list |
| 3378 | - for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_extract); $j++) { |
|
| 3378 | + for ($j = 0; ($j < sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_extract); $j++) { |
|
| 3379 | 3379 | |
| 3380 | 3380 | // ----- Look for a directory |
| 3381 | 3381 | if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") { |
| 3382 | 3382 | |
| 3383 | 3383 | // ----- Look if the directory is in the filename path |
| 3384 | - if ( (strlen($v_header['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) |
|
| 3384 | + if ((strlen($v_header['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) |
|
| 3385 | 3385 | && (substr($v_header['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) { |
| 3386 | 3386 | $v_extract = true; |
| 3387 | 3387 | } |
@@ -3406,7 +3406,7 @@ discard block |
||
| 3406 | 3406 | */ |
| 3407 | 3407 | |
| 3408 | 3408 | // ----- Look for extract by preg rule |
| 3409 | - else if ( (isset($p_options[PCLZIP_OPT_BY_PREG])) |
|
| 3409 | + else if ((isset($p_options[PCLZIP_OPT_BY_PREG])) |
|
| 3410 | 3410 | && ($p_options[PCLZIP_OPT_BY_PREG] != "")) { |
| 3411 | 3411 | |
| 3412 | 3412 | if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header['stored_filename'])) { |
@@ -3415,20 +3415,20 @@ discard block |
||
| 3415 | 3415 | } |
| 3416 | 3416 | |
| 3417 | 3417 | // ----- Look for extract by index rule |
| 3418 | - else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX])) |
|
| 3418 | + else if ((isset($p_options[PCLZIP_OPT_BY_INDEX])) |
|
| 3419 | 3419 | && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) { |
| 3420 | 3420 | |
| 3421 | 3421 | // ----- Look if the index is in the list |
| 3422 | - for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_extract); $j++) { |
|
| 3422 | + for ($j = $j_start; ($j < sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_extract); $j++) { |
|
| 3423 | 3423 | |
| 3424 | - if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) { |
|
| 3424 | + if (($i >= $p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i <= $p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) { |
|
| 3425 | 3425 | $v_extract = true; |
| 3426 | 3426 | } |
| 3427 | - if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) { |
|
| 3428 | - $j_start = $j+1; |
|
| 3427 | + if ($i >= $p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) { |
|
| 3428 | + $j_start = $j + 1; |
|
| 3429 | 3429 | } |
| 3430 | 3430 | |
| 3431 | - if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) { |
|
| 3431 | + if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start'] > $i) { |
|
| 3432 | 3432 | break; |
| 3433 | 3433 | } |
| 3434 | 3434 | } |
@@ -3440,21 +3440,21 @@ discard block |
||
| 3440 | 3440 | } |
| 3441 | 3441 | |
| 3442 | 3442 | // ----- Check compression method |
| 3443 | - if ( ($v_extract) |
|
| 3444 | - && ( ($v_header['compression'] != 8) |
|
| 3443 | + if (($v_extract) |
|
| 3444 | + && (($v_header['compression'] != 8) |
|
| 3445 | 3445 | && ($v_header['compression'] != 0))) { |
| 3446 | 3446 | $v_header['status'] = 'unsupported_compression'; |
| 3447 | 3447 | |
| 3448 | 3448 | // ----- Look for PCLZIP_OPT_STOP_ON_ERROR |
| 3449 | - if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
|
| 3450 | - && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { |
|
| 3449 | + if ((isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
|
| 3450 | + && ($p_options[PCLZIP_OPT_STOP_ON_ERROR] === true)) { |
|
| 3451 | 3451 | |
| 3452 | 3452 | $this->privSwapBackMagicQuotes(); |
| 3453 | 3453 | |
| 3454 | 3454 | PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_COMPRESSION, |
| 3455 | - "Filename '".$v_header['stored_filename']."' is " |
|
| 3455 | + "Filename '" . $v_header['stored_filename'] . "' is " |
|
| 3456 | 3456 | ."compressed by an unsupported compression " |
| 3457 | - ."method (".$v_header['compression'].") "); |
|
| 3457 | + ."method (" . $v_header['compression'] . ") "); |
|
| 3458 | 3458 | |
| 3459 | 3459 | return PclZip::errorCode(); |
| 3460 | 3460 | } |
@@ -3465,14 +3465,14 @@ discard block |
||
| 3465 | 3465 | $v_header['status'] = 'unsupported_encryption'; |
| 3466 | 3466 | |
| 3467 | 3467 | // ----- Look for PCLZIP_OPT_STOP_ON_ERROR |
| 3468 | - if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
|
| 3469 | - && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { |
|
| 3468 | + if ((isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
|
| 3469 | + && ($p_options[PCLZIP_OPT_STOP_ON_ERROR] === true)) { |
|
| 3470 | 3470 | |
| 3471 | 3471 | $this->privSwapBackMagicQuotes(); |
| 3472 | 3472 | |
| 3473 | 3473 | PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION, |
| 3474 | 3474 | "Unsupported encryption for " |
| 3475 | - ." filename '".$v_header['stored_filename'] |
|
| 3475 | + ." filename '" . $v_header['stored_filename'] |
|
| 3476 | 3476 | ."'"); |
| 3477 | 3477 | |
| 3478 | 3478 | return PclZip::errorCode(); |
@@ -3547,7 +3547,7 @@ discard block |
||
| 3547 | 3547 | } |
| 3548 | 3548 | } |
| 3549 | 3549 | // ----- Look for extraction in standard output |
| 3550 | - elseif ( (isset($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) |
|
| 3550 | + elseif ((isset($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) |
|
| 3551 | 3551 | && ($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) { |
| 3552 | 3552 | // ----- Extracting the file in standard output |
| 3553 | 3553 | $v_result1 = $this->privExtractFileInOutput($v_header, $p_options); |
@@ -3620,7 +3620,7 @@ discard block |
||
| 3620 | 3620 | // -------------------------------------------------------------------------------- |
| 3621 | 3621 | function privExtractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_options) |
| 3622 | 3622 | { |
| 3623 | - $v_result=1; |
|
| 3623 | + $v_result = 1; |
|
| 3624 | 3624 | |
| 3625 | 3625 | // ----- Read the file header |
| 3626 | 3626 | if (($v_result = $this->privReadFileHeader($v_header)) != 1) |
@@ -3638,7 +3638,7 @@ discard block |
||
| 3638 | 3638 | // ----- Look for all path to remove |
| 3639 | 3639 | if ($p_remove_all_path == true) { |
| 3640 | 3640 | // ----- Look for folder entry that not need to be extracted |
| 3641 | - if (($p_entry['external']&0x00000010)==0x00000010) { |
|
| 3641 | + if (($p_entry['external'] & 0x00000010) == 0x00000010) { |
|
| 3642 | 3642 | |
| 3643 | 3643 | $p_entry['status'] = "filtered"; |
| 3644 | 3644 | |
@@ -3674,7 +3674,7 @@ discard block |
||
| 3674 | 3674 | |
| 3675 | 3675 | // ----- Add the path |
| 3676 | 3676 | if ($p_path != '') { |
| 3677 | - $p_entry['filename'] = $p_path."/".$p_entry['filename']; |
|
| 3677 | + $p_entry['filename'] = $p_path . "/" . $p_entry['filename']; |
|
| 3678 | 3678 | } |
| 3679 | 3679 | |
| 3680 | 3680 | // ----- Check a base_dir_restriction |
@@ -3685,7 +3685,7 @@ discard block |
||
| 3685 | 3685 | if ($v_inclusion == 0) { |
| 3686 | 3686 | |
| 3687 | 3687 | PclZip::privErrorLog(PCLZIP_ERR_DIRECTORY_RESTRICTION, |
| 3688 | - "Filename '".$p_entry['filename']."' is " |
|
| 3688 | + "Filename '" . $p_entry['filename'] . "' is " |
|
| 3689 | 3689 | ."outside PCLZIP_OPT_EXTRACT_DIR_RESTRICTION"); |
| 3690 | 3690 | |
| 3691 | 3691 | return PclZip::errorCode(); |
@@ -3740,11 +3740,11 @@ discard block |
||
| 3740 | 3740 | // ----- Look for PCLZIP_OPT_STOP_ON_ERROR |
| 3741 | 3741 | // For historical reason first PclZip implementation does not stop |
| 3742 | 3742 | // when this kind of error occurs. |
| 3743 | - if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
|
| 3744 | - && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { |
|
| 3743 | + if ((isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
|
| 3744 | + && ($p_options[PCLZIP_OPT_STOP_ON_ERROR] === true)) { |
|
| 3745 | 3745 | |
| 3746 | 3746 | PclZip::privErrorLog(PCLZIP_ERR_ALREADY_A_DIRECTORY, |
| 3747 | - "Filename '".$p_entry['filename']."' is " |
|
| 3747 | + "Filename '" . $p_entry['filename'] . "' is " |
|
| 3748 | 3748 | ."already used by an existing directory"); |
| 3749 | 3749 | |
| 3750 | 3750 | return PclZip::errorCode(); |
@@ -3760,11 +3760,11 @@ discard block |
||
| 3760 | 3760 | // ----- Look for PCLZIP_OPT_STOP_ON_ERROR |
| 3761 | 3761 | // For historical reason first PclZip implementation does not stop |
| 3762 | 3762 | // when this kind of error occurs. |
| 3763 | - if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
|
| 3764 | - && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { |
|
| 3763 | + if ((isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
|
| 3764 | + && ($p_options[PCLZIP_OPT_STOP_ON_ERROR] === true)) { |
|
| 3765 | 3765 | |
| 3766 | 3766 | PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, |
| 3767 | - "Filename '".$p_entry['filename']."' exists " |
|
| 3767 | + "Filename '" . $p_entry['filename'] . "' exists " |
|
| 3768 | 3768 | ."and is write protected"); |
| 3769 | 3769 | |
| 3770 | 3770 | return PclZip::errorCode(); |
@@ -3775,8 +3775,8 @@ discard block |
||
| 3775 | 3775 | else if (filemtime($p_entry['filename']) > $p_entry['mtime']) |
| 3776 | 3776 | { |
| 3777 | 3777 | // ----- Change the file status |
| 3778 | - if ( (isset($p_options[PCLZIP_OPT_REPLACE_NEWER])) |
|
| 3779 | - && ($p_options[PCLZIP_OPT_REPLACE_NEWER]===true)) { |
|
| 3778 | + if ((isset($p_options[PCLZIP_OPT_REPLACE_NEWER])) |
|
| 3779 | + && ($p_options[PCLZIP_OPT_REPLACE_NEWER] === true)) { |
|
| 3780 | 3780 | } |
| 3781 | 3781 | else { |
| 3782 | 3782 | $p_entry['status'] = "newer_exist"; |
@@ -3784,11 +3784,11 @@ discard block |
||
| 3784 | 3784 | // ----- Look for PCLZIP_OPT_STOP_ON_ERROR |
| 3785 | 3785 | // For historical reason first PclZip implementation does not stop |
| 3786 | 3786 | // when this kind of error occurs. |
| 3787 | - if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
|
| 3788 | - && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { |
|
| 3787 | + if ((isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
|
| 3788 | + && ($p_options[PCLZIP_OPT_STOP_ON_ERROR] === true)) { |
|
| 3789 | 3789 | |
| 3790 | 3790 | PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, |
| 3791 | - "Newer version of '".$p_entry['filename']."' exists " |
|
| 3791 | + "Newer version of '" . $p_entry['filename'] . "' exists " |
|
| 3792 | 3792 | ."and option PCLZIP_OPT_REPLACE_NEWER is not selected"); |
| 3793 | 3793 | |
| 3794 | 3794 | return PclZip::errorCode(); |
@@ -3801,14 +3801,14 @@ discard block |
||
| 3801 | 3801 | |
| 3802 | 3802 | // ----- Check the directory availability and create it if necessary |
| 3803 | 3803 | else { |
| 3804 | - if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/')) |
|
| 3804 | + if ((($p_entry['external'] & 0x00000010) == 0x00000010) || (substr($p_entry['filename'], -1) == '/')) |
|
| 3805 | 3805 | $v_dir_to_check = $p_entry['filename']; |
| 3806 | 3806 | else if (!strstr($p_entry['filename'], "/")) |
| 3807 | 3807 | $v_dir_to_check = ""; |
| 3808 | 3808 | else |
| 3809 | 3809 | $v_dir_to_check = dirname($p_entry['filename']); |
| 3810 | 3810 | |
| 3811 | - if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external']&0x00000010)==0x00000010))) != 1) { |
|
| 3811 | + if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external'] & 0x00000010) == 0x00000010))) != 1) { |
|
| 3812 | 3812 | |
| 3813 | 3813 | // ----- Change the file status |
| 3814 | 3814 | $p_entry['status'] = "path_creation_fail"; |
@@ -3824,7 +3824,7 @@ discard block |
||
| 3824 | 3824 | if ($p_entry['status'] == 'ok') { |
| 3825 | 3825 | |
| 3826 | 3826 | // ----- Do the extraction (if not a folder) |
| 3827 | - if (!(($p_entry['external']&0x00000010)==0x00000010)) |
|
| 3827 | + if (!(($p_entry['external'] & 0x00000010) == 0x00000010)) |
|
| 3828 | 3828 | { |
| 3829 | 3829 | // ----- Look for not compressed file |
| 3830 | 3830 | if ($p_entry['compression'] == 0) { |
@@ -3867,16 +3867,16 @@ discard block |
||
| 3867 | 3867 | // ----- TBC |
| 3868 | 3868 | // Need to be finished |
| 3869 | 3869 | if (($p_entry['flag'] & 1) == 1) { |
| 3870 | - PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION, 'File \''.$p_entry['filename'].'\' is encrypted. Encrypted files are not supported.'); |
|
| 3870 | + PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION, 'File \'' . $p_entry['filename'] . '\' is encrypted. Encrypted files are not supported.'); |
|
| 3871 | 3871 | return PclZip::errorCode(); |
| 3872 | 3872 | } |
| 3873 | 3873 | |
| 3874 | 3874 | |
| 3875 | 3875 | // ----- Look for using temporary file to unzip |
| 3876 | - if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) |
|
| 3876 | + if ((!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) |
|
| 3877 | 3877 | && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON]) |
| 3878 | 3878 | || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]) |
| 3879 | - && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_entry['size'])) ) ) { |
|
| 3879 | + && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_entry['size'])))) { |
|
| 3880 | 3880 | $v_result = $this->privExtractFileUsingTempFile($p_entry, $p_options); |
| 3881 | 3881 | if ($v_result < PCLZIP_ERR_NO_ERROR) { |
| 3882 | 3882 | return $v_result; |
@@ -3971,13 +3971,13 @@ discard block |
||
| 3971 | 3971 | // -------------------------------------------------------------------------------- |
| 3972 | 3972 | function privExtractFileUsingTempFile(&$p_entry, &$p_options) |
| 3973 | 3973 | { |
| 3974 | - $v_result=1; |
|
| 3974 | + $v_result = 1; |
|
| 3975 | 3975 | |
| 3976 | 3976 | // ----- Creates a temporary file |
| 3977 | - $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz'; |
|
| 3977 | + $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR . uniqid('pclzip-') . '.gz'; |
|
| 3978 | 3978 | if (($v_dest_file = @fopen($v_gzip_temp_name, "wb")) == 0) { |
| 3979 | 3979 | fclose($v_file); |
| 3980 | - PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode'); |
|
| 3980 | + PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \'' . $v_gzip_temp_name . '\' in binary write mode'); |
|
| 3981 | 3981 | return PclZip::errorCode(); |
| 3982 | 3982 | } |
| 3983 | 3983 | |
@@ -4014,7 +4014,7 @@ discard block |
||
| 4014 | 4014 | if (($v_src_file = @gzopen($v_gzip_temp_name, 'rb')) == 0) { |
| 4015 | 4015 | @fclose($v_dest_file); |
| 4016 | 4016 | $p_entry['status'] = "read_error"; |
| 4017 | - PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode'); |
|
| 4017 | + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \'' . $v_gzip_temp_name . '\' in binary read mode'); |
|
| 4018 | 4018 | return PclZip::errorCode(); |
| 4019 | 4019 | } |
| 4020 | 4020 | |
@@ -4047,7 +4047,7 @@ discard block |
||
| 4047 | 4047 | // -------------------------------------------------------------------------------- |
| 4048 | 4048 | function privExtractFileInOutput(&$p_entry, &$p_options) |
| 4049 | 4049 | { |
| 4050 | - $v_result=1; |
|
| 4050 | + $v_result = 1; |
|
| 4051 | 4051 | |
| 4052 | 4052 | // ----- Read the file header |
| 4053 | 4053 | if (($v_result = $this->privReadFileHeader($v_header)) != 1) { |
@@ -4096,7 +4096,7 @@ discard block |
||
| 4096 | 4096 | if ($p_entry['status'] == 'ok') { |
| 4097 | 4097 | |
| 4098 | 4098 | // ----- Do the extraction (if not a folder) |
| 4099 | - if (!(($p_entry['external']&0x00000010)==0x00000010)) { |
|
| 4099 | + if (!(($p_entry['external'] & 0x00000010) == 0x00000010)) { |
|
| 4100 | 4100 | // ----- Look for not compressed file |
| 4101 | 4101 | if ($p_entry['compressed_size'] == $p_entry['size']) { |
| 4102 | 4102 | |
@@ -4159,7 +4159,7 @@ discard block |
||
| 4159 | 4159 | // -------------------------------------------------------------------------------- |
| 4160 | 4160 | function privExtractFileAsString(&$p_entry, &$p_string, &$p_options) |
| 4161 | 4161 | { |
| 4162 | - $v_result=1; |
|
| 4162 | + $v_result = 1; |
|
| 4163 | 4163 | |
| 4164 | 4164 | // ----- Read the file header |
| 4165 | 4165 | $v_header = array(); |
@@ -4210,7 +4210,7 @@ discard block |
||
| 4210 | 4210 | if ($p_entry['status'] == 'ok') { |
| 4211 | 4211 | |
| 4212 | 4212 | // ----- Do the extraction (if not a folder) |
| 4213 | - if (!(($p_entry['external']&0x00000010)==0x00000010)) { |
|
| 4213 | + if (!(($p_entry['external'] & 0x00000010) == 0x00000010)) { |
|
| 4214 | 4214 | // ----- Look for not compressed file |
| 4215 | 4215 | // if ($p_entry['compressed_size'] == $p_entry['size']) |
| 4216 | 4216 | if ($p_entry['compression'] == 0) { |
@@ -4282,7 +4282,7 @@ discard block |
||
| 4282 | 4282 | // -------------------------------------------------------------------------------- |
| 4283 | 4283 | function privReadFileHeader(&$p_header) |
| 4284 | 4284 | { |
| 4285 | - $v_result=1; |
|
| 4285 | + $v_result = 1; |
|
| 4286 | 4286 | |
| 4287 | 4287 | // ----- Read the 4 bytes signature |
| 4288 | 4288 | $v_binary_data = @fread($this->zip_fd, 4); |
@@ -4309,7 +4309,7 @@ discard block |
||
| 4309 | 4309 | $p_header['status'] = "invalid_header"; |
| 4310 | 4310 | |
| 4311 | 4311 | // ----- Error log |
| 4312 | - PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data)); |
|
| 4312 | + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : " . strlen($v_binary_data)); |
|
| 4313 | 4313 | |
| 4314 | 4314 | // ----- Return |
| 4315 | 4315 | return PclZip::errorCode(); |
@@ -4346,7 +4346,7 @@ discard block |
||
| 4346 | 4346 | // ----- Extract time |
| 4347 | 4347 | $v_hour = ($p_header['mtime'] & 0xF800) >> 11; |
| 4348 | 4348 | $v_minute = ($p_header['mtime'] & 0x07E0) >> 5; |
| 4349 | - $v_seconde = ($p_header['mtime'] & 0x001F)*2; |
|
| 4349 | + $v_seconde = ($p_header['mtime'] & 0x001F) * 2; |
|
| 4350 | 4350 | |
| 4351 | 4351 | // ----- Extract date |
| 4352 | 4352 | $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980; |
@@ -4385,7 +4385,7 @@ discard block |
||
| 4385 | 4385 | // -------------------------------------------------------------------------------- |
| 4386 | 4386 | function privReadCentralFileHeader(&$p_header) |
| 4387 | 4387 | { |
| 4388 | - $v_result=1; |
|
| 4388 | + $v_result = 1; |
|
| 4389 | 4389 | |
| 4390 | 4390 | // ----- Read the 4 bytes signature |
| 4391 | 4391 | $v_binary_data = @fread($this->zip_fd, 4); |
@@ -4412,7 +4412,7 @@ discard block |
||
| 4412 | 4412 | $p_header['status'] = "invalid_header"; |
| 4413 | 4413 | |
| 4414 | 4414 | // ----- Error log |
| 4415 | - PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data)); |
|
| 4415 | + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : " . strlen($v_binary_data)); |
|
| 4416 | 4416 | |
| 4417 | 4417 | // ----- Return |
| 4418 | 4418 | return PclZip::errorCode(); |
@@ -4449,7 +4449,7 @@ discard block |
||
| 4449 | 4449 | // ----- Extract time |
| 4450 | 4450 | $v_hour = ($p_header['mtime'] & 0xF800) >> 11; |
| 4451 | 4451 | $v_minute = ($p_header['mtime'] & 0x07E0) >> 5; |
| 4452 | - $v_seconde = ($p_header['mtime'] & 0x001F)*2; |
|
| 4452 | + $v_seconde = ($p_header['mtime'] & 0x001F) * 2; |
|
| 4453 | 4453 | |
| 4454 | 4454 | // ----- Extract date |
| 4455 | 4455 | $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980; |
@@ -4493,7 +4493,7 @@ discard block |
||
| 4493 | 4493 | // -------------------------------------------------------------------------------- |
| 4494 | 4494 | function privCheckFileHeaders(&$p_local_header, &$p_central_header) |
| 4495 | 4495 | { |
| 4496 | - $v_result=1; |
|
| 4496 | + $v_result = 1; |
|
| 4497 | 4497 | |
| 4498 | 4498 | // ----- Check the static values |
| 4499 | 4499 | // TBC |
@@ -4530,7 +4530,7 @@ discard block |
||
| 4530 | 4530 | // -------------------------------------------------------------------------------- |
| 4531 | 4531 | function privReadEndCentralDir(&$p_central_dir) |
| 4532 | 4532 | { |
| 4533 | - $v_result=1; |
|
| 4533 | + $v_result = 1; |
|
| 4534 | 4534 | |
| 4535 | 4535 | // ----- Go to the end of the zip file |
| 4536 | 4536 | $v_size = filesize($this->zipname); |
@@ -4538,7 +4538,7 @@ discard block |
||
| 4538 | 4538 | if (@ftell($this->zip_fd) != $v_size) |
| 4539 | 4539 | { |
| 4540 | 4540 | // ----- Error log |
| 4541 | - PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to go to the end of the archive \''.$this->zipname.'\''); |
|
| 4541 | + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to go to the end of the archive \'' . $this->zipname . '\''); |
|
| 4542 | 4542 | |
| 4543 | 4543 | // ----- Return |
| 4544 | 4544 | return PclZip::errorCode(); |
@@ -4548,11 +4548,11 @@ discard block |
||
| 4548 | 4548 | // in this case the end of central dir is at 22 bytes of the file end |
| 4549 | 4549 | $v_found = 0; |
| 4550 | 4550 | if ($v_size > 26) { |
| 4551 | - @fseek($this->zip_fd, $v_size-22); |
|
| 4552 | - if (($v_pos = @ftell($this->zip_fd)) != ($v_size-22)) |
|
| 4551 | + @fseek($this->zip_fd, $v_size - 22); |
|
| 4552 | + if (($v_pos = @ftell($this->zip_fd)) != ($v_size - 22)) |
|
| 4553 | 4553 | { |
| 4554 | 4554 | // ----- Error log |
| 4555 | - PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\''); |
|
| 4555 | + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \'' . $this->zipname . '\''); |
|
| 4556 | 4556 | |
| 4557 | 4557 | // ----- Return |
| 4558 | 4558 | return PclZip::errorCode(); |
@@ -4575,11 +4575,11 @@ discard block |
||
| 4575 | 4575 | $v_maximum_size = 65557; // 0xFFFF + 22; |
| 4576 | 4576 | if ($v_maximum_size > $v_size) |
| 4577 | 4577 | $v_maximum_size = $v_size; |
| 4578 | - @fseek($this->zip_fd, $v_size-$v_maximum_size); |
|
| 4579 | - if (@ftell($this->zip_fd) != ($v_size-$v_maximum_size)) |
|
| 4578 | + @fseek($this->zip_fd, $v_size - $v_maximum_size); |
|
| 4579 | + if (@ftell($this->zip_fd) != ($v_size - $v_maximum_size)) |
|
| 4580 | 4580 | { |
| 4581 | 4581 | // ----- Error log |
| 4582 | - PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\''); |
|
| 4582 | + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \'' . $this->zipname . '\''); |
|
| 4583 | 4583 | |
| 4584 | 4584 | // ----- Return |
| 4585 | 4585 | return PclZip::errorCode(); |
@@ -4597,7 +4597,7 @@ discard block |
||
| 4597 | 4597 | //$v_bytes = ($v_bytes << 8) | Ord($v_byte); |
| 4598 | 4598 | // Note we mask the old value down such that once shifted we can never end up with more than a 32bit number |
| 4599 | 4599 | // Otherwise on systems where we have 64bit integers the check below for the magic number will fail. |
| 4600 | - $v_bytes = ( ($v_bytes & 0xFFFFFF) << 8) | Ord($v_byte); |
|
| 4600 | + $v_bytes = (($v_bytes & 0xFFFFFF) << 8) | Ord($v_byte); |
|
| 4601 | 4601 | |
| 4602 | 4602 | // ----- Compare the bytes |
| 4603 | 4603 | if ($v_bytes == 0x504b0506) |
@@ -4629,7 +4629,7 @@ discard block |
||
| 4629 | 4629 | { |
| 4630 | 4630 | |
| 4631 | 4631 | // ----- Error log |
| 4632 | - PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid End of Central Dir Record size : ".strlen($v_binary_data)); |
|
| 4632 | + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid End of Central Dir Record size : " . strlen($v_binary_data)); |
|
| 4633 | 4633 | |
| 4634 | 4634 | // ----- Return |
| 4635 | 4635 | return PclZip::errorCode(); |
@@ -4687,11 +4687,11 @@ discard block |
||
| 4687 | 4687 | // -------------------------------------------------------------------------------- |
| 4688 | 4688 | function privDeleteByRule(&$p_result_list, &$p_options) |
| 4689 | 4689 | { |
| 4690 | - $v_result=1; |
|
| 4690 | + $v_result = 1; |
|
| 4691 | 4691 | $v_list_detail = array(); |
| 4692 | 4692 | |
| 4693 | 4693 | // ----- Open the zip file |
| 4694 | - if (($v_result=$this->privOpenFd('rb')) != 1) |
|
| 4694 | + if (($v_result = $this->privOpenFd('rb')) != 1) |
|
| 4695 | 4695 | { |
| 4696 | 4696 | // ----- Return |
| 4697 | 4697 | return $v_result; |
@@ -4727,7 +4727,7 @@ discard block |
||
| 4727 | 4727 | // ----- Read each entry |
| 4728 | 4728 | $v_header_list = array(); |
| 4729 | 4729 | $j_start = 0; |
| 4730 | - for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++) |
|
| 4730 | + for ($i = 0, $v_nb_extracted = 0; $i < $v_central_dir['entries']; $i++) |
|
| 4731 | 4731 | { |
| 4732 | 4732 | |
| 4733 | 4733 | // ----- Read the file header |
@@ -4748,22 +4748,22 @@ discard block |
||
| 4748 | 4748 | $v_found = false; |
| 4749 | 4749 | |
| 4750 | 4750 | // ----- Look for extract by name rule |
| 4751 | - if ( (isset($p_options[PCLZIP_OPT_BY_NAME])) |
|
| 4751 | + if ((isset($p_options[PCLZIP_OPT_BY_NAME])) |
|
| 4752 | 4752 | && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) { |
| 4753 | 4753 | |
| 4754 | 4754 | // ----- Look if the filename is in the list |
| 4755 | - for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_found); $j++) { |
|
| 4755 | + for ($j = 0; ($j < sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_found); $j++) { |
|
| 4756 | 4756 | |
| 4757 | 4757 | // ----- Look for a directory |
| 4758 | 4758 | if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") { |
| 4759 | 4759 | |
| 4760 | 4760 | // ----- Look if the directory is in the filename path |
| 4761 | - if ( (strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) |
|
| 4761 | + if ((strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) |
|
| 4762 | 4762 | && (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])) { |
| 4763 | 4763 | $v_found = true; |
| 4764 | 4764 | } |
| 4765 | - elseif ( (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */ |
|
| 4766 | - && ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_options[PCLZIP_OPT_BY_NAME][$j])) { |
|
| 4765 | + elseif ((($v_header_list[$v_nb_extracted]['external'] & 0x00000010) == 0x00000010) /* Indicates a folder */ |
|
| 4766 | + && ($v_header_list[$v_nb_extracted]['stored_filename'] . '/' == $p_options[PCLZIP_OPT_BY_NAME][$j])) { |
|
| 4767 | 4767 | $v_found = true; |
| 4768 | 4768 | } |
| 4769 | 4769 | } |
@@ -4787,7 +4787,7 @@ discard block |
||
| 4787 | 4787 | */ |
| 4788 | 4788 | |
| 4789 | 4789 | // ----- Look for extract by preg rule |
| 4790 | - else if ( (isset($p_options[PCLZIP_OPT_BY_PREG])) |
|
| 4790 | + else if ((isset($p_options[PCLZIP_OPT_BY_PREG])) |
|
| 4791 | 4791 | && ($p_options[PCLZIP_OPT_BY_PREG] != "")) { |
| 4792 | 4792 | |
| 4793 | 4793 | if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header_list[$v_nb_extracted]['stored_filename'])) { |
@@ -4796,20 +4796,20 @@ discard block |
||
| 4796 | 4796 | } |
| 4797 | 4797 | |
| 4798 | 4798 | // ----- Look for extract by index rule |
| 4799 | - else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX])) |
|
| 4799 | + else if ((isset($p_options[PCLZIP_OPT_BY_INDEX])) |
|
| 4800 | 4800 | && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) { |
| 4801 | 4801 | |
| 4802 | 4802 | // ----- Look if the index is in the list |
| 4803 | - for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_found); $j++) { |
|
| 4803 | + for ($j = $j_start; ($j < sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_found); $j++) { |
|
| 4804 | 4804 | |
| 4805 | - if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) { |
|
| 4805 | + if (($i >= $p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i <= $p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) { |
|
| 4806 | 4806 | $v_found = true; |
| 4807 | 4807 | } |
| 4808 | - if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) { |
|
| 4809 | - $j_start = $j+1; |
|
| 4808 | + if ($i >= $p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) { |
|
| 4809 | + $j_start = $j + 1; |
|
| 4810 | 4810 | } |
| 4811 | 4811 | |
| 4812 | - if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) { |
|
| 4812 | + if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start'] > $i) { |
|
| 4813 | 4813 | break; |
| 4814 | 4814 | } |
| 4815 | 4815 | } |
@@ -4833,7 +4833,7 @@ discard block |
||
| 4833 | 4833 | if ($v_nb_extracted > 0) { |
| 4834 | 4834 | |
| 4835 | 4835 | // ----- Creates a temporay file |
| 4836 | - $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp'; |
|
| 4836 | + $v_zip_temp_name = PCLZIP_TEMPORARY_DIR . uniqid('pclzip-') . '.tmp'; |
|
| 4837 | 4837 | |
| 4838 | 4838 | // ----- Creates a temporary zip archive |
| 4839 | 4839 | $v_temp_zip = new PclZip($v_zip_temp_name); |
@@ -4847,11 +4847,11 @@ discard block |
||
| 4847 | 4847 | } |
| 4848 | 4848 | |
| 4849 | 4849 | // ----- Look which file need to be kept |
| 4850 | - for ($i=0; $i<sizeof($v_header_list); $i++) { |
|
| 4850 | + for ($i = 0; $i < sizeof($v_header_list); $i++) { |
|
| 4851 | 4851 | |
| 4852 | 4852 | // ----- Calculate the position of the header |
| 4853 | 4853 | @rewind($this->zip_fd); |
| 4854 | - if (@fseek($this->zip_fd, $v_header_list[$i]['offset'])) { |
|
| 4854 | + if (@fseek($this->zip_fd, $v_header_list[$i]['offset'])) { |
|
| 4855 | 4855 | // ----- Close the zip file |
| 4856 | 4856 | $this->privCloseFd(); |
| 4857 | 4857 | $v_temp_zip->privCloseFd(); |
@@ -4910,7 +4910,7 @@ discard block |
||
| 4910 | 4910 | $v_offset = @ftell($v_temp_zip->zip_fd); |
| 4911 | 4911 | |
| 4912 | 4912 | // ----- Re-Create the Central Dir files header |
| 4913 | - for ($i=0; $i<sizeof($v_header_list); $i++) { |
|
| 4913 | + for ($i = 0; $i < sizeof($v_header_list); $i++) { |
|
| 4914 | 4914 | // ----- Create the file header |
| 4915 | 4915 | if (($v_result = $v_temp_zip->privWriteCentralFileHeader($v_header_list[$i])) != 1) { |
| 4916 | 4916 | $v_temp_zip->privCloseFd(); |
@@ -4933,7 +4933,7 @@ discard block |
||
| 4933 | 4933 | } |
| 4934 | 4934 | |
| 4935 | 4935 | // ----- Calculate the size of the central header |
| 4936 | - $v_size = @ftell($v_temp_zip->zip_fd)-$v_offset; |
|
| 4936 | + $v_size = @ftell($v_temp_zip->zip_fd) - $v_offset; |
|
| 4937 | 4937 | |
| 4938 | 4938 | // ----- Create the central dir footer |
| 4939 | 4939 | if (($v_result = $v_temp_zip->privWriteCentralHeader(sizeof($v_header_list), $v_size, $v_offset, $v_comment)) != 1) { |
@@ -4995,15 +4995,15 @@ discard block |
||
| 4995 | 4995 | // 1 : OK |
| 4996 | 4996 | // -1 : Unable to create directory |
| 4997 | 4997 | // -------------------------------------------------------------------------------- |
| 4998 | - function privDirCheck($p_dir, $p_is_dir=false) |
|
| 4998 | + function privDirCheck($p_dir, $p_is_dir = false) |
|
| 4999 | 4999 | { |
| 5000 | 5000 | $v_result = 1; |
| 5001 | 5001 | |
| 5002 | 5002 | |
| 5003 | 5003 | // ----- Remove the final '/' |
| 5004 | - if (($p_is_dir) && (substr($p_dir, -1)=='/')) |
|
| 5004 | + if (($p_is_dir) && (substr($p_dir, -1) == '/')) |
|
| 5005 | 5005 | { |
| 5006 | - $p_dir = substr($p_dir, 0, strlen($p_dir)-1); |
|
| 5006 | + $p_dir = substr($p_dir, 0, strlen($p_dir) - 1); |
|
| 5007 | 5007 | } |
| 5008 | 5008 | |
| 5009 | 5009 | // ----- Check the directory availability |
@@ -5052,7 +5052,7 @@ discard block |
||
| 5052 | 5052 | // -------------------------------------------------------------------------------- |
| 5053 | 5053 | function privMerge(&$p_archive_to_add) |
| 5054 | 5054 | { |
| 5055 | - $v_result=1; |
|
| 5055 | + $v_result = 1; |
|
| 5056 | 5056 | |
| 5057 | 5057 | // ----- Look if the archive_to_add exists |
| 5058 | 5058 | if (!is_file($p_archive_to_add->zipname)) |
@@ -5077,7 +5077,7 @@ discard block |
||
| 5077 | 5077 | } |
| 5078 | 5078 | |
| 5079 | 5079 | // ----- Open the zip file |
| 5080 | - if (($v_result=$this->privOpenFd('rb')) != 1) |
|
| 5080 | + if (($v_result = $this->privOpenFd('rb')) != 1) |
|
| 5081 | 5081 | { |
| 5082 | 5082 | // ----- Return |
| 5083 | 5083 | return $v_result; |
@@ -5095,7 +5095,7 @@ discard block |
||
| 5095 | 5095 | @rewind($this->zip_fd); |
| 5096 | 5096 | |
| 5097 | 5097 | // ----- Open the archive_to_add file |
| 5098 | - if (($v_result=$p_archive_to_add->privOpenFd('rb')) != 1) |
|
| 5098 | + if (($v_result = $p_archive_to_add->privOpenFd('rb')) != 1) |
|
| 5099 | 5099 | { |
| 5100 | 5100 | $this->privCloseFd(); |
| 5101 | 5101 | |
@@ -5117,7 +5117,7 @@ discard block |
||
| 5117 | 5117 | @rewind($p_archive_to_add->zip_fd); |
| 5118 | 5118 | |
| 5119 | 5119 | // ----- Creates a temporay file |
| 5120 | - $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp'; |
|
| 5120 | + $v_zip_temp_name = PCLZIP_TEMPORARY_DIR . uniqid('pclzip-') . '.tmp'; |
|
| 5121 | 5121 | |
| 5122 | 5122 | // ----- Open the temporary file in write mode |
| 5123 | 5123 | if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0) |
@@ -5125,7 +5125,7 @@ discard block |
||
| 5125 | 5125 | $this->privCloseFd(); |
| 5126 | 5126 | $p_archive_to_add->privCloseFd(); |
| 5127 | 5127 | |
| 5128 | - PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode'); |
|
| 5128 | + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \'' . $v_zip_temp_name . '\' in binary write mode'); |
|
| 5129 | 5129 | |
| 5130 | 5130 | // ----- Return |
| 5131 | 5131 | return PclZip::errorCode(); |
@@ -5176,10 +5176,10 @@ discard block |
||
| 5176 | 5176 | } |
| 5177 | 5177 | |
| 5178 | 5178 | // ----- Merge the file comments |
| 5179 | - $v_comment = $v_central_dir['comment'].' '.$v_central_dir_to_add['comment']; |
|
| 5179 | + $v_comment = $v_central_dir['comment'] . ' ' . $v_central_dir_to_add['comment']; |
|
| 5180 | 5180 | |
| 5181 | 5181 | // ----- Calculate the size of the (new) central header |
| 5182 | - $v_size = @ftell($v_zip_temp_fd)-$v_offset; |
|
| 5182 | + $v_size = @ftell($v_zip_temp_fd) - $v_offset; |
|
| 5183 | 5183 | |
| 5184 | 5184 | // ----- Swap the file descriptor |
| 5185 | 5185 | // Here is a trick : I swap the temporary fd with the zip fd, in order to use |
@@ -5189,7 +5189,7 @@ discard block |
||
| 5189 | 5189 | $v_zip_temp_fd = $v_swap; |
| 5190 | 5190 | |
| 5191 | 5191 | // ----- Create the central dir footer |
| 5192 | - if (($v_result = $this->privWriteCentralHeader($v_central_dir['entries']+$v_central_dir_to_add['entries'], $v_size, $v_offset, $v_comment)) != 1) |
|
| 5192 | + if (($v_result = $this->privWriteCentralHeader($v_central_dir['entries'] + $v_central_dir_to_add['entries'], $v_size, $v_offset, $v_comment)) != 1) |
|
| 5193 | 5193 | { |
| 5194 | 5194 | $this->privCloseFd(); |
| 5195 | 5195 | $p_archive_to_add->privCloseFd(); |
@@ -5237,7 +5237,7 @@ discard block |
||
| 5237 | 5237 | // -------------------------------------------------------------------------------- |
| 5238 | 5238 | function privDuplicate($p_archive_filename) |
| 5239 | 5239 | { |
| 5240 | - $v_result=1; |
|
| 5240 | + $v_result = 1; |
|
| 5241 | 5241 | |
| 5242 | 5242 | // ----- Look if the $p_archive_filename exists |
| 5243 | 5243 | if (!is_file($p_archive_filename)) |
@@ -5251,7 +5251,7 @@ discard block |
||
| 5251 | 5251 | } |
| 5252 | 5252 | |
| 5253 | 5253 | // ----- Open the zip file |
| 5254 | - if (($v_result=$this->privOpenFd('wb')) != 1) |
|
| 5254 | + if (($v_result = $this->privOpenFd('wb')) != 1) |
|
| 5255 | 5255 | { |
| 5256 | 5256 | // ----- Return |
| 5257 | 5257 | return $v_result; |
@@ -5262,7 +5262,7 @@ discard block |
||
| 5262 | 5262 | { |
| 5263 | 5263 | $this->privCloseFd(); |
| 5264 | 5264 | |
| 5265 | - PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive file \''.$p_archive_filename.'\' in binary write mode'); |
|
| 5265 | + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive file \'' . $p_archive_filename . '\' in binary write mode'); |
|
| 5266 | 5266 | |
| 5267 | 5267 | // ----- Return |
| 5268 | 5268 | return PclZip::errorCode(); |
@@ -5295,7 +5295,7 @@ discard block |
||
| 5295 | 5295 | // Description : |
| 5296 | 5296 | // Parameters : |
| 5297 | 5297 | // -------------------------------------------------------------------------------- |
| 5298 | - function privErrorLog($p_error_code=0, $p_error_string='') |
|
| 5298 | + function privErrorLog($p_error_code = 0, $p_error_string = '') |
|
| 5299 | 5299 | { |
| 5300 | 5300 | if (PCLZIP_ERROR_EXTERNAL == 1) { |
| 5301 | 5301 | PclError($p_error_code, $p_error_string); |
@@ -5332,10 +5332,10 @@ discard block |
||
| 5332 | 5332 | // -------------------------------------------------------------------------------- |
| 5333 | 5333 | function privDisableMagicQuotes() |
| 5334 | 5334 | { |
| 5335 | - $v_result=1; |
|
| 5335 | + $v_result = 1; |
|
| 5336 | 5336 | |
| 5337 | 5337 | // ----- Look if function exists |
| 5338 | - if ( (!function_exists("get_magic_quotes_runtime")) |
|
| 5338 | + if ((!function_exists("get_magic_quotes_runtime")) |
|
| 5339 | 5339 | || (!function_exists("set_magic_quotes_runtime"))) { |
| 5340 | 5340 | return $v_result; |
| 5341 | 5341 | } |
@@ -5366,10 +5366,10 @@ discard block |
||
| 5366 | 5366 | // -------------------------------------------------------------------------------- |
| 5367 | 5367 | function privSwapBackMagicQuotes() |
| 5368 | 5368 | { |
| 5369 | - $v_result=1; |
|
| 5369 | + $v_result = 1; |
|
| 5370 | 5370 | |
| 5371 | 5371 | // ----- Look if function exists |
| 5372 | - if ( (!function_exists("get_magic_quotes_runtime")) |
|
| 5372 | + if ((!function_exists("get_magic_quotes_runtime")) |
|
| 5373 | 5373 | || (!function_exists("set_magic_quotes_runtime"))) { |
| 5374 | 5374 | return $v_result; |
| 5375 | 5375 | } |
@@ -5410,7 +5410,7 @@ discard block |
||
| 5410 | 5410 | |
| 5411 | 5411 | // ----- Study directories from last to first |
| 5412 | 5412 | $v_skip = 0; |
| 5413 | - for ($i=sizeof($v_list)-1; $i>=0; $i--) { |
|
| 5413 | + for ($i = sizeof($v_list) - 1; $i >= 0; $i--) { |
|
| 5414 | 5414 | // ----- Look for current path |
| 5415 | 5415 | if ($v_list[$i] == ".") { |
| 5416 | 5416 | // ----- Ignore this directory |
@@ -5422,7 +5422,7 @@ discard block |
||
| 5422 | 5422 | else if ($v_list[$i] == "") { |
| 5423 | 5423 | // ----- First '/' i.e. root slash |
| 5424 | 5424 | if ($i == 0) { |
| 5425 | - $v_result = "/".$v_result; |
|
| 5425 | + $v_result = "/" . $v_result; |
|
| 5426 | 5426 | if ($v_skip > 0) { |
| 5427 | 5427 | // ----- It is an invalid path, so the path is not modified |
| 5428 | 5428 | // TBC |
@@ -5431,7 +5431,7 @@ discard block |
||
| 5431 | 5431 | } |
| 5432 | 5432 | } |
| 5433 | 5433 | // ----- Last '/' i.e. indicates a directory |
| 5434 | - else if ($i == (sizeof($v_list)-1)) { |
|
| 5434 | + else if ($i == (sizeof($v_list) - 1)) { |
|
| 5435 | 5435 | $v_result = $v_list[$i]; |
| 5436 | 5436 | } |
| 5437 | 5437 | // ----- Double '/' inside the path |
@@ -5446,7 +5446,7 @@ discard block |
||
| 5446 | 5446 | $v_skip--; |
| 5447 | 5447 | } |
| 5448 | 5448 | else { |
| 5449 | - $v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:""); |
|
| 5449 | + $v_result = $v_list[$i] . ($i != (sizeof($v_list) - 1) ? "/" . $v_result : ""); |
|
| 5450 | 5450 | } |
| 5451 | 5451 | } |
| 5452 | 5452 | } |
@@ -5454,7 +5454,7 @@ discard block |
||
| 5454 | 5454 | // ----- Look for skip |
| 5455 | 5455 | if ($v_skip > 0) { |
| 5456 | 5456 | while ($v_skip > 0) { |
| 5457 | - $v_result = '../'.$v_result; |
|
| 5457 | + $v_result = '../' . $v_result; |
|
| 5458 | 5458 | $v_skip--; |
| 5459 | 5459 | } |
| 5460 | 5460 | } |
@@ -5485,13 +5485,13 @@ discard block |
||
| 5485 | 5485 | $v_result = 1; |
| 5486 | 5486 | |
| 5487 | 5487 | // ----- Look for path beginning by ./ |
| 5488 | - if ( ($p_dir == '.') |
|
| 5489 | - || ((strlen($p_dir) >=2) && (substr($p_dir, 0, 2) == './'))) { |
|
| 5490 | - $p_dir = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_dir, 1); |
|
| 5488 | + if (($p_dir == '.') |
|
| 5489 | + || ((strlen($p_dir) >= 2) && (substr($p_dir, 0, 2) == './'))) { |
|
| 5490 | + $p_dir = PclZipUtilTranslateWinPath(getcwd(), FALSE) . '/' . substr($p_dir, 1); |
|
| 5491 | 5491 | } |
| 5492 | - if ( ($p_path == '.') |
|
| 5493 | - || ((strlen($p_path) >=2) && (substr($p_path, 0, 2) == './'))) { |
|
| 5494 | - $p_path = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_path, 1); |
|
| 5492 | + if (($p_path == '.') |
|
| 5493 | + || ((strlen($p_path) >= 2) && (substr($p_path, 0, 2) == './'))) { |
|
| 5494 | + $p_path = PclZipUtilTranslateWinPath(getcwd(), FALSE) . '/' . substr($p_path, 1); |
|
| 5495 | 5495 | } |
| 5496 | 5496 | |
| 5497 | 5497 | // ----- Explode dir and path by directory separator |
@@ -5516,7 +5516,7 @@ discard block |
||
| 5516 | 5516 | } |
| 5517 | 5517 | |
| 5518 | 5518 | // ----- Compare the items |
| 5519 | - if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ( $v_list_path[$j] != '')) { |
|
| 5519 | + if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ($v_list_path[$j] != '')) { |
|
| 5520 | 5520 | $v_result = 0; |
| 5521 | 5521 | } |
| 5522 | 5522 | |
@@ -5557,11 +5557,11 @@ discard block |
||
| 5557 | 5557 | // 3 : src & dest gzip |
| 5558 | 5558 | // Return Values : |
| 5559 | 5559 | // -------------------------------------------------------------------------------- |
| 5560 | - function PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode=0) |
|
| 5560 | + function PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode = 0) |
|
| 5561 | 5561 | { |
| 5562 | 5562 | $v_result = 1; |
| 5563 | 5563 | |
| 5564 | - if ($p_mode==0) |
|
| 5564 | + if ($p_mode == 0) |
|
| 5565 | 5565 | { |
| 5566 | 5566 | while ($p_size != 0) |
| 5567 | 5567 | { |
@@ -5571,7 +5571,7 @@ discard block |
||
| 5571 | 5571 | $p_size -= $v_read_size; |
| 5572 | 5572 | } |
| 5573 | 5573 | } |
| 5574 | - else if ($p_mode==1) |
|
| 5574 | + else if ($p_mode == 1) |
|
| 5575 | 5575 | { |
| 5576 | 5576 | while ($p_size != 0) |
| 5577 | 5577 | { |
@@ -5581,7 +5581,7 @@ discard block |
||
| 5581 | 5581 | $p_size -= $v_read_size; |
| 5582 | 5582 | } |
| 5583 | 5583 | } |
| 5584 | - else if ($p_mode==2) |
|
| 5584 | + else if ($p_mode == 2) |
|
| 5585 | 5585 | { |
| 5586 | 5586 | while ($p_size != 0) |
| 5587 | 5587 | { |
@@ -5591,7 +5591,7 @@ discard block |
||
| 5591 | 5591 | $p_size -= $v_read_size; |
| 5592 | 5592 | } |
| 5593 | 5593 | } |
| 5594 | - else if ($p_mode==3) |
|
| 5594 | + else if ($p_mode == 3) |
|
| 5595 | 5595 | { |
| 5596 | 5596 | while ($p_size != 0) |
| 5597 | 5597 | { |
@@ -5655,7 +5655,7 @@ discard block |
||
| 5655 | 5655 | $v_list = get_defined_constants(); |
| 5656 | 5656 | for (reset($v_list); $v_key = key($v_list); next($v_list)) { |
| 5657 | 5657 | $v_prefix = substr($v_key, 0, 10); |
| 5658 | - if (( ($v_prefix == 'PCLZIP_OPT') |
|
| 5658 | + if ((($v_prefix == 'PCLZIP_OPT') |
|
| 5659 | 5659 | || ($v_prefix == 'PCLZIP_CB_') |
| 5660 | 5660 | || ($v_prefix == 'PCLZIP_ATT')) |
| 5661 | 5661 | && ($v_list[$v_key] == $p_option)) { |
@@ -5680,15 +5680,15 @@ discard block |
||
| 5680 | 5680 | // Return Values : |
| 5681 | 5681 | // The path translated. |
| 5682 | 5682 | // -------------------------------------------------------------------------------- |
| 5683 | - function PclZipUtilTranslateWinPath($p_path, $p_remove_disk_letter=true) |
|
| 5683 | + function PclZipUtilTranslateWinPath($p_path, $p_remove_disk_letter = true) |
|
| 5684 | 5684 | { |
| 5685 | 5685 | if (stristr(php_uname(), 'windows')) { |
| 5686 | 5686 | // ----- Look for potential disk letter |
| 5687 | 5687 | if (($p_remove_disk_letter) && (($v_position = strpos($p_path, ':')) != false)) { |
| 5688 | - $p_path = substr($p_path, $v_position+1); |
|
| 5688 | + $p_path = substr($p_path, $v_position + 1); |
|
| 5689 | 5689 | } |
| 5690 | 5690 | // ----- Change potential windows directory separator |
| 5691 | - if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) { |
|
| 5691 | + if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0, 1) == '\\')) { |
|
| 5692 | 5692 | $p_path = strtr($p_path, '\\', '/'); |
| 5693 | 5693 | } |
| 5694 | 5694 | } |
@@ -1,4 +1,6 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
| 2 | + exit; |
|
| 3 | +} |
|
| 2 | 4 | // -------------------------------------------------------------------------------- |
| 3 | 5 | // PhpConcept Library - Zip Module 2.8.2 |
| 4 | 6 | // -------------------------------------------------------------------------------- |
@@ -330,8 +332,7 @@ discard block |
||
| 330 | 332 | // ----- Look for the optional second argument |
| 331 | 333 | if ($v_size == 2) { |
| 332 | 334 | $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1]; |
| 333 | - } |
|
| 334 | - else if ($v_size > 2) { |
|
| 335 | + } else if ($v_size > 2) { |
|
| 335 | 336 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, |
| 336 | 337 | "Invalid number / type of arguments"); |
| 337 | 338 | return 0; |
@@ -380,8 +381,7 @@ discard block |
||
| 380 | 381 | foreach ($v_string_list as $v_string) { |
| 381 | 382 | if ($v_string != '') { |
| 382 | 383 | $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string; |
| 383 | - } |
|
| 384 | - else { |
|
| 384 | + } else { |
|
| 385 | 385 | } |
| 386 | 386 | } |
| 387 | 387 | } |
@@ -515,8 +515,7 @@ discard block |
||
| 515 | 515 | // ----- Look for the optional second argument |
| 516 | 516 | if ($v_size == 2) { |
| 517 | 517 | $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1]; |
| 518 | - } |
|
| 519 | - else if ($v_size > 2) { |
|
| 518 | + } else if ($v_size > 2) { |
|
| 520 | 519 | // ----- Error log |
| 521 | 520 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments"); |
| 522 | 521 | |
@@ -792,8 +791,7 @@ discard block |
||
| 792 | 791 | // ----- Look for the optional second argument |
| 793 | 792 | if ($v_size == 2) { |
| 794 | 793 | $v_remove_path = $v_arg_list[1]; |
| 795 | - } |
|
| 796 | - else if ($v_size > 2) { |
|
| 794 | + } else if ($v_size > 2) { |
|
| 797 | 795 | // ----- Error log |
| 798 | 796 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments"); |
| 799 | 797 | |
@@ -937,8 +935,7 @@ discard block |
||
| 937 | 935 | } |
| 938 | 936 | if (!isset($v_options[PCLZIP_OPT_EXTRACT_AS_STRING])) { |
| 939 | 937 | $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE; |
| 940 | - } |
|
| 941 | - else { |
|
| 938 | + } else { |
|
| 942 | 939 | } |
| 943 | 940 | } |
| 944 | 941 | |
@@ -953,8 +950,7 @@ discard block |
||
| 953 | 950 | // ----- Look for the optional second argument |
| 954 | 951 | if ($v_size == 2) { |
| 955 | 952 | $v_remove_path = $v_arg_list[1]; |
| 956 | - } |
|
| 957 | - else if ($v_size > 2) { |
|
| 953 | + } else if ($v_size > 2) { |
|
| 958 | 954 | // ----- Error log |
| 959 | 955 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments"); |
| 960 | 956 | |
@@ -1190,8 +1186,7 @@ discard block |
||
| 1190 | 1186 | // ----- Error log |
| 1191 | 1187 | PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "No file with filename '".$p_archive."'"); |
| 1192 | 1188 | $v_result = PCLZIP_ERR_MISSING_FILE; |
| 1193 | - } |
|
| 1194 | - else { |
|
| 1189 | + } else { |
|
| 1195 | 1190 | // ----- Duplicate the archive |
| 1196 | 1191 | $v_result = $this->privDuplicate($p_archive); |
| 1197 | 1192 | } |
@@ -1279,8 +1274,7 @@ discard block |
||
| 1279 | 1274 | { |
| 1280 | 1275 | if (PCLZIP_ERROR_EXTERNAL == 1) { |
| 1281 | 1276 | return(PclErrorCode()); |
| 1282 | - } |
|
| 1283 | - else { |
|
| 1277 | + } else { |
|
| 1284 | 1278 | return($this->error_code); |
| 1285 | 1279 | } |
| 1286 | 1280 | } |
@@ -1318,15 +1312,13 @@ discard block |
||
| 1318 | 1312 | |
| 1319 | 1313 | if (isset($v_name[$this->error_code])) { |
| 1320 | 1314 | $v_value = $v_name[$this->error_code]; |
| 1321 | - } |
|
| 1322 | - else { |
|
| 1315 | + } else { |
|
| 1323 | 1316 | $v_value = 'NoName'; |
| 1324 | 1317 | } |
| 1325 | 1318 | |
| 1326 | 1319 | if ($p_with_code) { |
| 1327 | 1320 | return($v_value.' ('.$this->error_code.')'); |
| 1328 | - } |
|
| 1329 | - else { |
|
| 1321 | + } else { |
|
| 1330 | 1322 | return($v_value); |
| 1331 | 1323 | } |
| 1332 | 1324 | } |
@@ -1341,12 +1333,10 @@ discard block |
||
| 1341 | 1333 | { |
| 1342 | 1334 | if (PCLZIP_ERROR_EXTERNAL == 1) { |
| 1343 | 1335 | return(PclErrorString()); |
| 1344 | - } |
|
| 1345 | - else { |
|
| 1336 | + } else { |
|
| 1346 | 1337 | if ($p_full) { |
| 1347 | 1338 | return($this->errorName(true)." : ".$this->error_string); |
| 1348 | - } |
|
| 1349 | - else { |
|
| 1339 | + } else { |
|
| 1350 | 1340 | return($this->error_string." [code ".$this->error_code."]"); |
| 1351 | 1341 | } |
| 1352 | 1342 | } |
@@ -1531,8 +1521,7 @@ discard block |
||
| 1531 | 1521 | && ($p_options_list[$i+1] != '')) { |
| 1532 | 1522 | $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE); |
| 1533 | 1523 | $i++; |
| 1534 | - } |
|
| 1535 | - else { |
|
| 1524 | + } else { |
|
| 1536 | 1525 | } |
| 1537 | 1526 | break; |
| 1538 | 1527 | |
@@ -1550,11 +1539,9 @@ discard block |
||
| 1550 | 1539 | // ----- Get the value |
| 1551 | 1540 | if (is_string($p_options_list[$i+1])) { |
| 1552 | 1541 | $v_result_list[$p_options_list[$i]][0] = $p_options_list[$i+1]; |
| 1553 | - } |
|
| 1554 | - else if (is_array($p_options_list[$i+1])) { |
|
| 1542 | + } else if (is_array($p_options_list[$i+1])) { |
|
| 1555 | 1543 | $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; |
| 1556 | - } |
|
| 1557 | - else { |
|
| 1544 | + } else { |
|
| 1558 | 1545 | // ----- Error log |
| 1559 | 1546 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
| 1560 | 1547 | |
@@ -1583,8 +1570,7 @@ discard block |
||
| 1583 | 1570 | // ----- Get the value |
| 1584 | 1571 | if (is_string($p_options_list[$i+1])) { |
| 1585 | 1572 | $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; |
| 1586 | - } |
|
| 1587 | - else { |
|
| 1573 | + } else { |
|
| 1588 | 1574 | // ----- Error log |
| 1589 | 1575 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
| 1590 | 1576 | |
@@ -1613,8 +1599,7 @@ discard block |
||
| 1613 | 1599 | // ----- Get the value |
| 1614 | 1600 | if (is_string($p_options_list[$i+1])) { |
| 1615 | 1601 | $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; |
| 1616 | - } |
|
| 1617 | - else { |
|
| 1602 | + } else { |
|
| 1618 | 1603 | // ----- Error log |
| 1619 | 1604 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, |
| 1620 | 1605 | "Wrong parameter value for option '" |
@@ -1647,14 +1632,11 @@ discard block |
||
| 1647 | 1632 | |
| 1648 | 1633 | // ----- Parse items |
| 1649 | 1634 | $v_work_list = explode(",", $p_options_list[$i+1]); |
| 1650 | - } |
|
| 1651 | - else if (is_integer($p_options_list[$i+1])) { |
|
| 1635 | + } else if (is_integer($p_options_list[$i+1])) { |
|
| 1652 | 1636 | $v_work_list[0] = $p_options_list[$i+1].'-'.$p_options_list[$i+1]; |
| 1653 | - } |
|
| 1654 | - else if (is_array($p_options_list[$i+1])) { |
|
| 1637 | + } else if (is_array($p_options_list[$i+1])) { |
|
| 1655 | 1638 | $v_work_list = $p_options_list[$i+1]; |
| 1656 | - } |
|
| 1657 | - else { |
|
| 1639 | + } else { |
|
| 1658 | 1640 | // ----- Error log |
| 1659 | 1641 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Value must be integer, string or array for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
| 1660 | 1642 | |
@@ -1681,13 +1663,11 @@ discard block |
||
| 1681 | 1663 | // ----- Set the option value |
| 1682 | 1664 | $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0]; |
| 1683 | 1665 | $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[0]; |
| 1684 | - } |
|
| 1685 | - elseif ($v_size_item_list == 2) { |
|
| 1666 | + } elseif ($v_size_item_list == 2) { |
|
| 1686 | 1667 | // ----- Set the option value |
| 1687 | 1668 | $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0]; |
| 1688 | 1669 | $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[1]; |
| 1689 | - } |
|
| 1690 | - else { |
|
| 1670 | + } else { |
|
| 1691 | 1671 | // ----- Error log |
| 1692 | 1672 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Too many values in index range for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
| 1693 | 1673 | |
@@ -1843,14 +1823,17 @@ discard block |
||
| 1843 | 1823 | $v_memory_limit = trim($v_memory_limit); |
| 1844 | 1824 | $last = strtolower(substr($v_memory_limit, -1)); |
| 1845 | 1825 | |
| 1846 | - if($last == 'g') |
|
| 1847 | - //$v_memory_limit = $v_memory_limit*1024*1024*1024; |
|
| 1826 | + if($last == 'g') { |
|
| 1827 | + //$v_memory_limit = $v_memory_limit*1024*1024*1024; |
|
| 1848 | 1828 | $v_memory_limit = $v_memory_limit*1073741824; |
| 1849 | - if($last == 'm') |
|
| 1850 | - //$v_memory_limit = $v_memory_limit*1024*1024; |
|
| 1829 | + } |
|
| 1830 | + if($last == 'm') { |
|
| 1831 | + //$v_memory_limit = $v_memory_limit*1024*1024; |
|
| 1851 | 1832 | $v_memory_limit = $v_memory_limit*1048576; |
| 1852 | - if($last == 'k') |
|
| 1853 | - $v_memory_limit = $v_memory_limit*1024; |
|
| 1833 | + } |
|
| 1834 | + if($last == 'k') { |
|
| 1835 | + $v_memory_limit = $v_memory_limit*1024; |
|
| 1836 | + } |
|
| 1854 | 1837 | |
| 1855 | 1838 | $p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] = floor($v_memory_limit*PCLZIP_TEMPORARY_FILE_RATIO); |
| 1856 | 1839 | |
@@ -2023,15 +2006,12 @@ discard block |
||
| 2023 | 2006 | if (file_exists($v_descr['filename'])) { |
| 2024 | 2007 | if (@is_file($v_descr['filename'])) { |
| 2025 | 2008 | $v_descr['type'] = 'file'; |
| 2026 | - } |
|
| 2027 | - else if (@is_dir($v_descr['filename'])) { |
|
| 2009 | + } else if (@is_dir($v_descr['filename'])) { |
|
| 2028 | 2010 | $v_descr['type'] = 'folder'; |
| 2029 | - } |
|
| 2030 | - else if (@is_link($v_descr['filename'])) { |
|
| 2011 | + } else if (@is_link($v_descr['filename'])) { |
|
| 2031 | 2012 | // skip |
| 2032 | 2013 | continue; |
| 2033 | - } |
|
| 2034 | - else { |
|
| 2014 | + } else { |
|
| 2035 | 2015 | // skip |
| 2036 | 2016 | continue; |
| 2037 | 2017 | } |
@@ -2080,8 +2060,7 @@ discard block |
||
| 2080 | 2060 | && (!isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))) { |
| 2081 | 2061 | if ($v_descr['stored_filename'] != '') { |
| 2082 | 2062 | $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_descr['stored_filename'].'/'.$v_item_handler; |
| 2083 | - } |
|
| 2084 | - else { |
|
| 2063 | + } else { |
|
| 2085 | 2064 | $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_item_handler; |
| 2086 | 2065 | } |
| 2087 | 2066 | } |
@@ -2090,8 +2069,7 @@ discard block |
||
| 2090 | 2069 | } |
| 2091 | 2070 | |
| 2092 | 2071 | @closedir($v_folder_handler); |
| 2093 | - } |
|
| 2094 | - else { |
|
| 2072 | + } else { |
|
| 2095 | 2073 | // TBC : unable to open folder in read mode |
| 2096 | 2074 | } |
| 2097 | 2075 | |
@@ -2104,8 +2082,7 @@ discard block |
||
| 2104 | 2082 | |
| 2105 | 2083 | // ----- Concat the resulting list |
| 2106 | 2084 | $v_result_list = array_merge($v_result_list, $v_dirlist_descr); |
| 2107 | - } |
|
| 2108 | - else { |
|
| 2085 | + } else { |
|
| 2109 | 2086 | } |
| 2110 | 2087 | |
| 2111 | 2088 | // ----- Free local array |
@@ -2379,8 +2356,9 @@ discard block |
||
| 2379 | 2356 | { |
| 2380 | 2357 | $v_result=1; |
| 2381 | 2358 | |
| 2382 | - if ($this->zip_fd != 0) |
|
| 2383 | - @fclose($this->zip_fd); |
|
| 2359 | + if ($this->zip_fd != 0) { |
|
| 2360 | + @fclose($this->zip_fd); |
|
| 2361 | + } |
|
| 2384 | 2362 | $this->zip_fd = 0; |
| 2385 | 2363 | |
| 2386 | 2364 | // ----- Return |
@@ -2597,11 +2575,9 @@ discard block |
||
| 2597 | 2575 | // ----- Look for filetime |
| 2598 | 2576 | if (isset($p_filedescr['mtime'])) { |
| 2599 | 2577 | $p_header['mtime'] = $p_filedescr['mtime']; |
| 2600 | - } |
|
| 2601 | - else if ($p_filedescr['type'] == 'virtual_file') { |
|
| 2578 | + } else if ($p_filedescr['type'] == 'virtual_file') { |
|
| 2602 | 2579 | $p_header['mtime'] = time(); |
| 2603 | - } |
|
| 2604 | - else { |
|
| 2580 | + } else { |
|
| 2605 | 2581 | $p_header['mtime'] = filemtime($p_filename); |
| 2606 | 2582 | } |
| 2607 | 2583 | |
@@ -2609,8 +2585,7 @@ discard block |
||
| 2609 | 2585 | if (isset($p_filedescr['comment'])) { |
| 2610 | 2586 | $p_header['comment_len'] = strlen($p_filedescr['comment']); |
| 2611 | 2587 | $p_header['comment'] = $p_filedescr['comment']; |
| 2612 | - } |
|
| 2613 | - else { |
|
| 2588 | + } else { |
|
| 2614 | 2589 | $p_header['comment_len'] = 0; |
| 2615 | 2590 | $p_header['comment'] = ''; |
| 2616 | 2591 | } |
@@ -2921,20 +2896,17 @@ discard block |
||
| 2921 | 2896 | $p_filename = $p_filedescr['filename']; |
| 2922 | 2897 | if (isset($p_options[PCLZIP_OPT_ADD_PATH])) { |
| 2923 | 2898 | $p_add_dir = $p_options[PCLZIP_OPT_ADD_PATH]; |
| 2924 | - } |
|
| 2925 | - else { |
|
| 2899 | + } else { |
|
| 2926 | 2900 | $p_add_dir = ''; |
| 2927 | 2901 | } |
| 2928 | 2902 | if (isset($p_options[PCLZIP_OPT_REMOVE_PATH])) { |
| 2929 | 2903 | $p_remove_dir = $p_options[PCLZIP_OPT_REMOVE_PATH]; |
| 2930 | - } |
|
| 2931 | - else { |
|
| 2904 | + } else { |
|
| 2932 | 2905 | $p_remove_dir = ''; |
| 2933 | 2906 | } |
| 2934 | 2907 | if (isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])) { |
| 2935 | 2908 | $p_remove_all_dir = $p_options[PCLZIP_OPT_REMOVE_ALL_PATH]; |
| 2936 | - } |
|
| 2937 | - else { |
|
| 2909 | + } else { |
|
| 2938 | 2910 | $p_remove_all_dir = 0; |
| 2939 | 2911 | } |
| 2940 | 2912 | |
@@ -2957,8 +2929,7 @@ discard block |
||
| 2957 | 2929 | $v_dir = $v_path_info['dirname'].'/'; |
| 2958 | 2930 | } |
| 2959 | 2931 | $v_stored_filename = $v_dir.$p_filedescr['new_short_name']; |
| 2960 | - } |
|
| 2961 | - else { |
|
| 2932 | + } else { |
|
| 2962 | 2933 | // ----- Calculate the stored filename |
| 2963 | 2934 | $v_stored_filename = $p_filename; |
| 2964 | 2935 | } |
@@ -2969,8 +2940,9 @@ discard block |
||
| 2969 | 2940 | } |
| 2970 | 2941 | // ----- Look for partial path remove |
| 2971 | 2942 | else if ($p_remove_dir != "") { |
| 2972 | - if (substr($p_remove_dir, -1) != '/') |
|
| 2973 | - $p_remove_dir .= "/"; |
|
| 2943 | + if (substr($p_remove_dir, -1) != '/') { |
|
| 2944 | + $p_remove_dir .= "/"; |
|
| 2945 | + } |
|
| 2974 | 2946 | |
| 2975 | 2947 | if ( (substr($p_filename, 0, 2) == "./") |
| 2976 | 2948 | || (substr($p_remove_dir, 0, 2) == "./")) { |
@@ -2990,8 +2962,7 @@ discard block |
||
| 2990 | 2962 | if ($v_compare > 0) { |
| 2991 | 2963 | if ($v_compare == 2) { |
| 2992 | 2964 | $v_stored_filename = ""; |
| 2993 | - } |
|
| 2994 | - else { |
|
| 2965 | + } else { |
|
| 2995 | 2966 | $v_stored_filename = substr($v_stored_filename, |
| 2996 | 2967 | strlen($p_remove_dir)); |
| 2997 | 2968 | } |
@@ -3003,10 +2974,11 @@ discard block |
||
| 3003 | 2974 | |
| 3004 | 2975 | // ----- Look for path to add |
| 3005 | 2976 | if ($p_add_dir != "") { |
| 3006 | - if (substr($p_add_dir, -1) == "/") |
|
| 3007 | - $v_stored_filename = $p_add_dir.$v_stored_filename; |
|
| 3008 | - else |
|
| 3009 | - $v_stored_filename = $p_add_dir."/".$v_stored_filename; |
|
| 2977 | + if (substr($p_add_dir, -1) == "/") { |
|
| 2978 | + $v_stored_filename = $p_add_dir.$v_stored_filename; |
|
| 2979 | + } else { |
|
| 2980 | + $v_stored_filename = $p_add_dir."/".$v_stored_filename; |
|
| 2981 | + } |
|
| 3010 | 2982 | } |
| 3011 | 2983 | } |
| 3012 | 2984 | |
@@ -3289,8 +3261,9 @@ discard block |
||
| 3289 | 3261 | if ( ($p_path == "") |
| 3290 | 3262 | || ( (substr($p_path, 0, 1) != "/") |
| 3291 | 3263 | && (substr($p_path, 0, 3) != "../") |
| 3292 | - && (substr($p_path,1,2)!=":/"))) |
|
| 3293 | - $p_path = "./".$p_path; |
|
| 3264 | + && (substr($p_path,1,2)!=":/"))) { |
|
| 3265 | + $p_path = "./".$p_path; |
|
| 3266 | + } |
|
| 3294 | 3267 | |
| 3295 | 3268 | // ----- Reduce the path last (and duplicated) '/' |
| 3296 | 3269 | if (($p_path != "./") && ($p_path != "/")) |
@@ -3777,8 +3750,7 @@ discard block |
||
| 3777 | 3750 | // ----- Change the file status |
| 3778 | 3751 | if ( (isset($p_options[PCLZIP_OPT_REPLACE_NEWER])) |
| 3779 | 3752 | && ($p_options[PCLZIP_OPT_REPLACE_NEWER]===true)) { |
| 3780 | - } |
|
| 3781 | - else { |
|
| 3753 | + } else { |
|
| 3782 | 3754 | $p_entry['status'] = "newer_exist"; |
| 3783 | 3755 | |
| 3784 | 3756 | // ----- Look for PCLZIP_OPT_STOP_ON_ERROR |
@@ -3794,19 +3766,19 @@ discard block |
||
| 3794 | 3766 | return PclZip::errorCode(); |
| 3795 | 3767 | } |
| 3796 | 3768 | } |
| 3797 | - } |
|
| 3798 | - else { |
|
| 3769 | + } else { |
|
| 3799 | 3770 | } |
| 3800 | 3771 | } |
| 3801 | 3772 | |
| 3802 | 3773 | // ----- Check the directory availability and create it if necessary |
| 3803 | 3774 | else { |
| 3804 | - if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/')) |
|
| 3805 | - $v_dir_to_check = $p_entry['filename']; |
|
| 3806 | - else if (!strstr($p_entry['filename'], "/")) |
|
| 3807 | - $v_dir_to_check = ""; |
|
| 3808 | - else |
|
| 3809 | - $v_dir_to_check = dirname($p_entry['filename']); |
|
| 3775 | + if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/')) { |
|
| 3776 | + $v_dir_to_check = $p_entry['filename']; |
|
| 3777 | + } else if (!strstr($p_entry['filename'], "/")) { |
|
| 3778 | + $v_dir_to_check = ""; |
|
| 3779 | + } else { |
|
| 3780 | + $v_dir_to_check = dirname($p_entry['filename']); |
|
| 3781 | + } |
|
| 3810 | 3782 | |
| 3811 | 3783 | if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external']&0x00000010)==0x00000010))) != 1) { |
| 3812 | 3784 | |
@@ -3862,8 +3834,7 @@ discard block |
||
| 3862 | 3834 | touch($p_entry['filename'], $p_entry['mtime']); |
| 3863 | 3835 | |
| 3864 | 3836 | |
| 3865 | - } |
|
| 3866 | - else { |
|
| 3837 | + } else { |
|
| 3867 | 3838 | // ----- TBC |
| 3868 | 3839 | // Need to be finished |
| 3869 | 3840 | if (($p_entry['flag'] & 1) == 1) { |
@@ -4106,8 +4077,7 @@ discard block |
||
| 4106 | 4077 | // ----- Send the file to the output |
| 4107 | 4078 | echo $v_buffer; |
| 4108 | 4079 | unset($v_buffer); |
| 4109 | - } |
|
| 4110 | - else { |
|
| 4080 | + } else { |
|
| 4111 | 4081 | |
| 4112 | 4082 | // ----- Read the compressed file in a buffer (one shot) |
| 4113 | 4083 | $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']); |
@@ -4217,8 +4187,7 @@ discard block |
||
| 4217 | 4187 | |
| 4218 | 4188 | // ----- Reading the file |
| 4219 | 4189 | $p_string = @fread($this->zip_fd, $p_entry['compressed_size']); |
| 4220 | - } |
|
| 4221 | - else { |
|
| 4190 | + } else { |
|
| 4222 | 4191 | |
| 4223 | 4192 | // ----- Reading the file |
| 4224 | 4193 | $v_data = @fread($this->zip_fd, $p_entry['compressed_size']); |
@@ -4230,8 +4199,7 @@ discard block |
||
| 4230 | 4199 | } |
| 4231 | 4200 | |
| 4232 | 4201 | // ----- Trace |
| 4233 | - } |
|
| 4234 | - else { |
|
| 4202 | + } else { |
|
| 4235 | 4203 | // TBC : error : can not extract a folder in a string |
| 4236 | 4204 | } |
| 4237 | 4205 | |
@@ -4324,8 +4292,7 @@ discard block |
||
| 4324 | 4292 | // ----- Get extra_fields |
| 4325 | 4293 | if ($v_data['extra_len'] != 0) { |
| 4326 | 4294 | $p_header['extra'] = fread($this->zip_fd, $v_data['extra_len']); |
| 4327 | - } |
|
| 4328 | - else { |
|
| 4295 | + } else { |
|
| 4329 | 4296 | $p_header['extra'] = ''; |
| 4330 | 4297 | } |
| 4331 | 4298 | |
@@ -4356,8 +4323,7 @@ discard block |
||
| 4356 | 4323 | // ----- Get UNIX date format |
| 4357 | 4324 | $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year); |
| 4358 | 4325 | |
| 4359 | - } |
|
| 4360 | - else |
|
| 4326 | + } else |
|
| 4361 | 4327 | { |
| 4362 | 4328 | $p_header['mtime'] = time(); |
| 4363 | 4329 | } |
@@ -4422,22 +4388,25 @@ discard block |
||
| 4422 | 4388 | $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); |
| 4423 | 4389 | |
| 4424 | 4390 | // ----- Get filename |
| 4425 | - if ($p_header['filename_len'] != 0) |
|
| 4426 | - $p_header['filename'] = fread($this->zip_fd, $p_header['filename_len']); |
|
| 4427 | - else |
|
| 4428 | - $p_header['filename'] = ''; |
|
| 4391 | + if ($p_header['filename_len'] != 0) { |
|
| 4392 | + $p_header['filename'] = fread($this->zip_fd, $p_header['filename_len']); |
|
| 4393 | + } else { |
|
| 4394 | + $p_header['filename'] = ''; |
|
| 4395 | + } |
|
| 4429 | 4396 | |
| 4430 | 4397 | // ----- Get extra |
| 4431 | - if ($p_header['extra_len'] != 0) |
|
| 4432 | - $p_header['extra'] = fread($this->zip_fd, $p_header['extra_len']); |
|
| 4433 | - else |
|
| 4434 | - $p_header['extra'] = ''; |
|
| 4398 | + if ($p_header['extra_len'] != 0) { |
|
| 4399 | + $p_header['extra'] = fread($this->zip_fd, $p_header['extra_len']); |
|
| 4400 | + } else { |
|
| 4401 | + $p_header['extra'] = ''; |
|
| 4402 | + } |
|
| 4435 | 4403 | |
| 4436 | 4404 | // ----- Get comment |
| 4437 | - if ($p_header['comment_len'] != 0) |
|
| 4438 | - $p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']); |
|
| 4439 | - else |
|
| 4440 | - $p_header['comment'] = ''; |
|
| 4405 | + if ($p_header['comment_len'] != 0) { |
|
| 4406 | + $p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']); |
|
| 4407 | + } else { |
|
| 4408 | + $p_header['comment'] = ''; |
|
| 4409 | + } |
|
| 4441 | 4410 | |
| 4442 | 4411 | // ----- Extract properties |
| 4443 | 4412 | |
@@ -4459,8 +4428,7 @@ discard block |
||
| 4459 | 4428 | // ----- Get UNIX date format |
| 4460 | 4429 | $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year); |
| 4461 | 4430 | |
| 4462 | - } |
|
| 4463 | - else |
|
| 4431 | + } else |
|
| 4464 | 4432 | { |
| 4465 | 4433 | $p_header['mtime'] = time(); |
| 4466 | 4434 | } |
@@ -4573,8 +4541,9 @@ discard block |
||
| 4573 | 4541 | // ----- Go back to the maximum possible size of the Central Dir End Record |
| 4574 | 4542 | if (!$v_found) { |
| 4575 | 4543 | $v_maximum_size = 65557; // 0xFFFF + 22; |
| 4576 | - if ($v_maximum_size > $v_size) |
|
| 4577 | - $v_maximum_size = $v_size; |
|
| 4544 | + if ($v_maximum_size > $v_size) { |
|
| 4545 | + $v_maximum_size = $v_size; |
|
| 4546 | + } |
|
| 4578 | 4547 | @fseek($this->zip_fd, $v_size-$v_maximum_size); |
| 4579 | 4548 | if (@ftell($this->zip_fd) != ($v_size-$v_maximum_size)) |
| 4580 | 4549 | { |
@@ -4659,9 +4628,9 @@ discard block |
||
| 4659 | 4628 | // ----- Get comment |
| 4660 | 4629 | if ($v_data['comment_size'] != 0) { |
| 4661 | 4630 | $p_central_dir['comment'] = fread($this->zip_fd, $v_data['comment_size']); |
| 4631 | + } else { |
|
| 4632 | + $p_central_dir['comment'] = ''; |
|
| 4662 | 4633 | } |
| 4663 | - else |
|
| 4664 | - $p_central_dir['comment'] = ''; |
|
| 4665 | 4634 | |
| 4666 | 4635 | $p_central_dir['entries'] = $v_data['entries']; |
| 4667 | 4636 | $p_central_dir['disk_entries'] = $v_data['disk_entries']; |
@@ -4761,8 +4730,7 @@ discard block |
||
| 4761 | 4730 | if ( (strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) |
| 4762 | 4731 | && (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])) { |
| 4763 | 4732 | $v_found = true; |
| 4764 | - } |
|
| 4765 | - elseif ( (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */ |
|
| 4733 | + } elseif ( (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */ |
|
| 4766 | 4734 | && ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_options[PCLZIP_OPT_BY_NAME][$j])) { |
| 4767 | 4735 | $v_found = true; |
| 4768 | 4736 | } |
@@ -4813,8 +4781,7 @@ discard block |
||
| 4813 | 4781 | break; |
| 4814 | 4782 | } |
| 4815 | 4783 | } |
| 4816 | - } |
|
| 4817 | - else { |
|
| 4784 | + } else { |
|
| 4818 | 4785 | $v_found = true; |
| 4819 | 4786 | } |
| 4820 | 4787 | |
@@ -4822,8 +4789,7 @@ discard block |
||
| 4822 | 4789 | if ($v_found) |
| 4823 | 4790 | { |
| 4824 | 4791 | unset($v_header_list[$v_nb_extracted]); |
| 4825 | - } |
|
| 4826 | - else |
|
| 4792 | + } else |
|
| 4827 | 4793 | { |
| 4828 | 4794 | $v_nb_extracted++; |
| 4829 | 4795 | } |
@@ -5299,8 +5265,7 @@ discard block |
||
| 5299 | 5265 | { |
| 5300 | 5266 | if (PCLZIP_ERROR_EXTERNAL == 1) { |
| 5301 | 5267 | PclError($p_error_code, $p_error_string); |
| 5302 | - } |
|
| 5303 | - else { |
|
| 5268 | + } else { |
|
| 5304 | 5269 | $this->error_code = $p_error_code; |
| 5305 | 5270 | $this->error_string = $p_error_string; |
| 5306 | 5271 | } |
@@ -5316,8 +5281,7 @@ discard block |
||
| 5316 | 5281 | { |
| 5317 | 5282 | if (PCLZIP_ERROR_EXTERNAL == 1) { |
| 5318 | 5283 | PclErrorReset(); |
| 5319 | - } |
|
| 5320 | - else { |
|
| 5284 | + } else { |
|
| 5321 | 5285 | $this->error_code = 0; |
| 5322 | 5286 | $this->error_string = ''; |
| 5323 | 5287 | } |
@@ -5415,11 +5379,9 @@ discard block |
||
| 5415 | 5379 | if ($v_list[$i] == ".") { |
| 5416 | 5380 | // ----- Ignore this directory |
| 5417 | 5381 | // Should be the first $i=0, but no check is done |
| 5418 | - } |
|
| 5419 | - else if ($v_list[$i] == "..") { |
|
| 5382 | + } else if ($v_list[$i] == "..") { |
|
| 5420 | 5383 | $v_skip++; |
| 5421 | - } |
|
| 5422 | - else if ($v_list[$i] == "") { |
|
| 5384 | + } else if ($v_list[$i] == "") { |
|
| 5423 | 5385 | // ----- First '/' i.e. root slash |
| 5424 | 5386 | if ($i == 0) { |
| 5425 | 5387 | $v_result = "/".$v_result; |
@@ -5439,13 +5401,11 @@ discard block |
||
| 5439 | 5401 | // ----- Ignore only the double '//' in path, |
| 5440 | 5402 | // but not the first and last '/' |
| 5441 | 5403 | } |
| 5442 | - } |
|
| 5443 | - else { |
|
| 5404 | + } else { |
|
| 5444 | 5405 | // ----- Look for item to skip |
| 5445 | 5406 | if ($v_skip > 0) { |
| 5446 | 5407 | $v_skip--; |
| 5447 | - } |
|
| 5448 | - else { |
|
| 5408 | + } else { |
|
| 5449 | 5409 | $v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:""); |
| 5450 | 5410 | } |
| 5451 | 5411 | } |
@@ -5528,14 +5488,17 @@ discard block |
||
| 5528 | 5488 | // ----- Look if everything seems to be the same |
| 5529 | 5489 | if ($v_result) { |
| 5530 | 5490 | // ----- Skip all the empty items |
| 5531 | - while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) $j++; |
|
| 5532 | - while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) $i++; |
|
| 5491 | + while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) { |
|
| 5492 | + $j++; |
|
| 5493 | + } |
|
| 5494 | + while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) { |
|
| 5495 | + $i++; |
|
| 5496 | + } |
|
| 5533 | 5497 | |
| 5534 | 5498 | if (($i >= $v_list_dir_size) && ($j >= $v_list_path_size)) { |
| 5535 | 5499 | // ----- There are exactly the same |
| 5536 | 5500 | $v_result = 2; |
| 5537 | - } |
|
| 5538 | - else if ($i < $v_list_dir_size) { |
|
| 5501 | + } else if ($i < $v_list_dir_size) { |
|
| 5539 | 5502 | // ----- The path is shorter than the dir |
| 5540 | 5503 | $v_result = 0; |
| 5541 | 5504 | } |
@@ -5570,8 +5533,7 @@ discard block |
||
| 5570 | 5533 | @fwrite($p_dest, $v_buffer, $v_read_size); |
| 5571 | 5534 | $p_size -= $v_read_size; |
| 5572 | 5535 | } |
| 5573 | - } |
|
| 5574 | - else if ($p_mode==1) |
|
| 5536 | + } else if ($p_mode==1) |
|
| 5575 | 5537 | { |
| 5576 | 5538 | while ($p_size != 0) |
| 5577 | 5539 | { |
@@ -5580,8 +5542,7 @@ discard block |
||
| 5580 | 5542 | @fwrite($p_dest, $v_buffer, $v_read_size); |
| 5581 | 5543 | $p_size -= $v_read_size; |
| 5582 | 5544 | } |
| 5583 | - } |
|
| 5584 | - else if ($p_mode==2) |
|
| 5545 | + } else if ($p_mode==2) |
|
| 5585 | 5546 | { |
| 5586 | 5547 | while ($p_size != 0) |
| 5587 | 5548 | { |
@@ -5590,8 +5551,7 @@ discard block |
||
| 5590 | 5551 | @gzwrite($p_dest, $v_buffer, $v_read_size); |
| 5591 | 5552 | $p_size -= $v_read_size; |
| 5592 | 5553 | } |
| 5593 | - } |
|
| 5594 | - else if ($p_mode==3) |
|
| 5554 | + } else if ($p_mode==3) |
|
| 5595 | 5555 | { |
| 5596 | 5556 | while ($p_size != 0) |
| 5597 | 5557 | { |
@@ -5629,8 +5589,7 @@ discard block |
||
| 5629 | 5589 | // ----- Try to copy & unlink the src |
| 5630 | 5590 | if (!@copy($p_src, $p_dest)) { |
| 5631 | 5591 | $v_result = 0; |
| 5632 | - } |
|
| 5633 | - else if (!@unlink($p_src)) { |
|
| 5592 | + } else if (!@unlink($p_src)) { |
|
| 5634 | 5593 | $v_result = 0; |
| 5635 | 5594 | } |
| 5636 | 5595 | } |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | * Open a Zip archive |
| 40 | 40 | * |
| 41 | 41 | * @param string $filename the name of the archive to open |
| 42 | - * @return true if openning has succeeded |
|
| 42 | + * @return boolean if openning has succeeded |
|
| 43 | 43 | */ |
| 44 | 44 | public function open($filename) |
| 45 | 45 | { |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | * |
| 79 | 79 | * @param string $localname the local path to the file in the archive |
| 80 | 80 | * @param string $contents the content of the file |
| 81 | - * @return true if the file has been successful added |
|
| 81 | + * @return boolean if the file has been successful added |
|
| 82 | 82 | */ |
| 83 | 83 | public function addFromString($localname, $contents) |
| 84 | 84 | { |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | * |
| 109 | 109 | * @param string $filename the path to the file we want to add |
| 110 | 110 | * @param string $localname the local path to the file in the archive |
| 111 | - * @return true if the file has been successful added |
|
| 111 | + * @return boolean if the file has been successful added |
|
| 112 | 112 | */ |
| 113 | 113 | public function addFile($filename, $localname = null) |
| 114 | 114 | { |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | } |
| 142 | 142 | /** |
| 143 | 143 | * Close the Zip archive |
| 144 | - * @return true |
|
| 144 | + * @return boolean |
|
| 145 | 145 | */ |
| 146 | 146 | public function close() |
| 147 | 147 | { |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | } |
| 159 | 159 | /** |
| 160 | 160 | * Empty the temporary working directory recursively |
| 161 | - * @param $dir the temporary working directory |
|
| 161 | + * @param string $dir the temporary working directory |
|
| 162 | 162 | * @return void |
| 163 | 163 | */ |
| 164 | 164 | private function _rrmdir($dir) |
@@ -23,11 +23,11 @@ |
||
| 23 | 23 | protected $openned = false; |
| 24 | 24 | protected $filename; |
| 25 | 25 | protected $pclzip; |
| 26 | - /** |
|
| 27 | - * Class constructor |
|
| 28 | - * |
|
| 29 | - * @throws PclZipProxyException |
|
| 30 | - */ |
|
| 26 | + /** |
|
| 27 | + * Class constructor |
|
| 28 | + * |
|
| 29 | + * @throws PclZipProxyException |
|
| 30 | + */ |
|
| 31 | 31 | public function __construct() |
| 32 | 32 | { |
| 33 | 33 | if (! class_exists('PclZip')) { |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) exit; |
|
| 2 | 2 | require_once 'pclzip/pclzip.lib.php'; |
| 3 | 3 | require_once 'ZipInterface.php'; |
| 4 | 4 | class PclZipProxyException extends Exception |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | */ |
| 31 | 31 | public function __construct() |
| 32 | 32 | { |
| 33 | - if (! class_exists('PclZip')) { |
|
| 33 | + if (!class_exists('PclZip')) { |
|
| 34 | 34 | throw new PclZipProxyException('PclZip class not loaded - PclZip library |
| 35 | 35 | is required for using PclZipProxy'); ; |
| 36 | 36 | } |
@@ -1,4 +1,6 @@ |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
| 2 | + exit; |
|
| 3 | +} |
|
| 2 | 4 | require_once 'pclzip/pclzip.lib.php'; |
| 3 | 5 | require_once 'ZipInterface.php'; |
| 4 | 6 | class PclZipProxyException extends Exception |
@@ -481,7 +481,7 @@ |
||
| 481 | 481 | } |
| 482 | 482 | |
| 483 | 483 | /** SIGN UP - Display the commercial & newsletter form |
| 484 | - * @return void |
|
| 484 | + * @return string |
|
| 485 | 485 | */ |
| 486 | 486 | function display_commercial_newsletter_form() { |
| 487 | 487 | $output = ''; |
@@ -1,8 +1,8 @@ |
||
| 1 | 1 | <?php if ( !defined( 'ABSPATH' ) ) exit; |
| 2 | 2 | class wps_account_ctr { |
| 3 | 3 | /** Define the main directory containing the template for the current plugin |
| 4 | - * @var string |
|
| 5 | - */ |
|
| 4 | + * @var string |
|
| 5 | + */ |
|
| 6 | 6 | private $template_dir; |
| 7 | 7 | /** |
| 8 | 8 | * Define the directory name for the module in order to check into frontend |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) exit; |
|
| 2 | 2 | class wps_account_ctr { |
| 3 | 3 | /** Define the main directory containing the template for the current plugin |
| 4 | 4 | * @var string |
@@ -19,50 +19,50 @@ discard block |
||
| 19 | 19 | $this->template_dir = WPS_ACCOUNT_PATH . WPS_ACCOUNT_DIR . "/templates/"; |
| 20 | 20 | /** Shortcodes **/ |
| 21 | 21 | // Sign up Display Shortcode |
| 22 | - add_shortcode( 'wps_signup', array( &$this, 'display_signup' ) ); |
|
| 22 | + add_shortcode('wps_signup', array(&$this, 'display_signup')); |
|
| 23 | 23 | // Log in Form Display Shortcode |
| 24 | - add_shortcode( 'wpshop_login', array( &$this, 'get_login_form')); |
|
| 24 | + add_shortcode('wpshop_login', array(&$this, 'get_login_form')); |
|
| 25 | 25 | //Log in first step |
| 26 | - add_shortcode( 'wps_first_login', array( &$this, 'get_login_first_step')); |
|
| 26 | + add_shortcode('wps_first_login', array(&$this, 'get_login_first_step')); |
|
| 27 | 27 | // Forgot password Form |
| 28 | - add_shortcode( 'wps_forgot_password', array( &$this, 'get_forgot_password_form')); |
|
| 28 | + add_shortcode('wps_forgot_password', array(&$this, 'get_forgot_password_form')); |
|
| 29 | 29 | // Renew password form |
| 30 | - add_shortcode( 'wps_renew_password', array( &$this, 'get_renew_password_form')); |
|
| 30 | + add_shortcode('wps_renew_password', array(&$this, 'get_renew_password_form')); |
|
| 31 | 31 | //Account informations |
| 32 | - add_shortcode( 'wps_account_informations', array($this, 'display_account_informations') ); |
|
| 32 | + add_shortcode('wps_account_informations', array($this, 'display_account_informations')); |
|
| 33 | 33 | //Account form |
| 34 | - add_shortcode( 'wps_account_informations_form', array($this, 'account_informations_form') ); |
|
| 34 | + add_shortcode('wps_account_informations_form', array($this, 'account_informations_form')); |
|
| 35 | 35 | |
| 36 | 36 | /** Ajax Actions **/ |
| 37 | 37 | // add_action('wap_ajax_wps_display_connexion_form', array(&$this, 'wps_ajax_get_login_form_interface') ); |
| 38 | 38 | // add_action('wap_ajax_nopriv_wps_display_connexion_form', array(&$this, 'wps_ajax_get_login_form_interface') ); |
| 39 | 39 | |
| 40 | - add_action('wp_ajax_wps_login_request', array(&$this, 'control_login_form_request') ); |
|
| 41 | - add_action('wp_ajax_nopriv_wps_login_request', array(&$this, 'control_login_form_request') ); |
|
| 40 | + add_action('wp_ajax_wps_login_request', array(&$this, 'control_login_form_request')); |
|
| 41 | + add_action('wp_ajax_nopriv_wps_login_request', array(&$this, 'control_login_form_request')); |
|
| 42 | 42 | |
| 43 | - add_action('wp_ajax_wps_forgot_password_request', array(&$this, 'wps_forgot_password_request') ); |
|
| 44 | - add_action('wp_ajax_nopriv_wps_forgot_password_request', array(&$this, 'wps_forgot_password_request') ); |
|
| 43 | + add_action('wp_ajax_wps_forgot_password_request', array(&$this, 'wps_forgot_password_request')); |
|
| 44 | + add_action('wp_ajax_nopriv_wps_forgot_password_request', array(&$this, 'wps_forgot_password_request')); |
|
| 45 | 45 | |
| 46 | - add_action('wp_ajax_wps_forgot_password_renew', array(&$this, 'wps_forgot_password_renew') ); |
|
| 47 | - add_action('wp_ajax_nopriv_wps_forgot_password_renew', array(&$this, 'wps_forgot_password_renew') ); |
|
| 46 | + add_action('wp_ajax_wps_forgot_password_renew', array(&$this, 'wps_forgot_password_renew')); |
|
| 47 | + add_action('wp_ajax_nopriv_wps_forgot_password_renew', array(&$this, 'wps_forgot_password_renew')); |
|
| 48 | 48 | |
| 49 | - add_action('wp_ajax_wps_signup_request', array(&$this, 'wps_save_signup_form') ); |
|
| 50 | - add_action('wp_ajax_nopriv_wps_signup_request', array(&$this, 'wps_save_signup_form_nopriv') ); |
|
| 49 | + add_action('wp_ajax_wps_signup_request', array(&$this, 'wps_save_signup_form')); |
|
| 50 | + add_action('wp_ajax_nopriv_wps_signup_request', array(&$this, 'wps_save_signup_form_nopriv')); |
|
| 51 | 51 | |
| 52 | - add_action('wp_ajax_wps_login_first_request', array(&$this, 'wps_login_first_request') ); |
|
| 53 | - add_action('wp_ajax_nopriv_wps_login_first_request', array(&$this, 'wps_login_first_request') ); |
|
| 52 | + add_action('wp_ajax_wps_login_first_request', array(&$this, 'wps_login_first_request')); |
|
| 53 | + add_action('wp_ajax_nopriv_wps_login_first_request', array(&$this, 'wps_login_first_request')); |
|
| 54 | 54 | |
| 55 | - add_action( 'wp_ajax_wps_save_account_informations', array($this, 'wps_save_account_informations') ); |
|
| 55 | + add_action('wp_ajax_wps_save_account_informations', array($this, 'wps_save_account_informations')); |
|
| 56 | 56 | |
| 57 | - add_action( 'wp_ajax_wps_account_reload_informations', array($this, 'wps_account_reload_informations') ); |
|
| 57 | + add_action('wp_ajax_wps_account_reload_informations', array($this, 'wps_account_reload_informations')); |
|
| 58 | 58 | |
| 59 | - add_action( 'wp_ajax_wps_fill_forgot_password_modal', array($this, 'wps_fill_forgot_password_modal') ); |
|
| 60 | - add_action( 'wp_ajax_nopriv_wps_fill_forgot_password_modal', array($this, 'wps_fill_forgot_password_modal') ); |
|
| 59 | + add_action('wp_ajax_wps_fill_forgot_password_modal', array($this, 'wps_fill_forgot_password_modal')); |
|
| 60 | + add_action('wp_ajax_nopriv_wps_fill_forgot_password_modal', array($this, 'wps_fill_forgot_password_modal')); |
|
| 61 | 61 | |
| 62 | - add_action( 'wp_ajax_wps_fill_account_informations_modal', array($this, 'wps_fill_account_informations_modal') ); |
|
| 63 | - add_action( 'wp_ajax_nopriv_wps_fill_account_informations_modal', array($this, 'wps_fill_account_informations_modal') ); |
|
| 62 | + add_action('wp_ajax_wps_fill_account_informations_modal', array($this, 'wps_fill_account_informations_modal')); |
|
| 63 | + add_action('wp_ajax_nopriv_wps_fill_account_informations_modal', array($this, 'wps_fill_account_informations_modal')); |
|
| 64 | 64 | |
| 65 | - add_action( 'wp_enqueue_scripts', array( $this, 'add_scripts') ); |
|
| 65 | + add_action('wp_enqueue_scripts', array($this, 'add_scripts')); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | /** |
@@ -70,32 +70,32 @@ discard block |
||
| 70 | 70 | */ |
| 71 | 71 | function add_scripts() { |
| 72 | 72 | wp_enqueue_script('jquery'); |
| 73 | - wp_enqueue_script( 'wps_forgot_password_js', WPS_ACCOUNT_URL.'wps_customer/assets/frontend/js/wps_forgot_password.js' ); |
|
| 74 | - wp_enqueue_script( 'wps_login_js', WPS_ACCOUNT_URL.'wps_customer/assets/frontend/js/wps_login.js' ); |
|
| 75 | - wp_enqueue_script( 'wps_signup_js', WPS_ACCOUNT_URL.'wps_customer/assets/frontend/js/wps_signup.js' ); |
|
| 76 | - wp_enqueue_script( 'wps_account_js', WPS_ACCOUNT_URL.'wps_customer/assets/frontend/js/wps_account.js' ); |
|
| 73 | + wp_enqueue_script('wps_forgot_password_js', WPS_ACCOUNT_URL . 'wps_customer/assets/frontend/js/wps_forgot_password.js'); |
|
| 74 | + wp_enqueue_script('wps_login_js', WPS_ACCOUNT_URL . 'wps_customer/assets/frontend/js/wps_login.js'); |
|
| 75 | + wp_enqueue_script('wps_signup_js', WPS_ACCOUNT_URL . 'wps_customer/assets/frontend/js/wps_signup.js'); |
|
| 76 | + wp_enqueue_script('wps_account_js', WPS_ACCOUNT_URL . 'wps_customer/assets/frontend/js/wps_account.js'); |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | /** LOG IN - Display log in Form **/ |
| 80 | - function get_login_form( $force_login = false ) { |
|
| 80 | + function get_login_form($force_login = false) { |
|
| 81 | 81 | $args = array(); |
| 82 | - if ( get_current_user_id() != 0 ) { |
|
| 83 | - return __( 'You are already logged', 'wpshop'); |
|
| 82 | + if (get_current_user_id() != 0) { |
|
| 83 | + return __('You are already logged', 'wpshop'); |
|
| 84 | 84 | } |
| 85 | 85 | else { |
| 86 | - $action = !empty( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ''; |
|
| 87 | - $key = !empty( $_GET['key'] ) ? sanitize_text_field( $_GET['key'] ) : ''; |
|
| 88 | - $login = !empty( $_GET['login'] ) ? sanitize_text_field( $_GET['login'] ) : 0; |
|
| 89 | - if ( !empty($action) && $action == 'retrieve_password' && !empty($key) && !empty($login) && !$force_login ) { |
|
| 86 | + $action = !empty($_GET['action']) ? sanitize_text_field($_GET['action']) : ''; |
|
| 87 | + $key = !empty($_GET['key']) ? sanitize_text_field($_GET['key']) : ''; |
|
| 88 | + $login = !empty($_GET['login']) ? sanitize_text_field($_GET['login']) : 0; |
|
| 89 | + if (!empty($action) && $action == 'retrieve_password' && !empty($key) && !empty($login) && !$force_login) { |
|
| 90 | 90 | $output = self::get_renew_password_form(); |
| 91 | 91 | } |
| 92 | 92 | else { |
| 93 | 93 | ob_start(); |
| 94 | - require_once( wpshop_tools::get_template_part( WPS_ACCOUNT_DIR, $this->template_dir, "frontend", "login/login-form") ); |
|
| 94 | + require_once(wpshop_tools::get_template_part(WPS_ACCOUNT_DIR, $this->template_dir, "frontend", "login/login-form")); |
|
| 95 | 95 | $output = ob_get_contents(); |
| 96 | 96 | ob_end_clean(); |
| 97 | - if ( !$force_login ) { |
|
| 98 | - $output .= do_shortcode( '[wps_signup]' ); |
|
| 97 | + if (!$force_login) { |
|
| 98 | + $output .= do_shortcode('[wps_signup]'); |
|
| 99 | 99 | } |
| 100 | 100 | } |
| 101 | 101 | return $output; |
@@ -105,53 +105,53 @@ discard block |
||
| 105 | 105 | /** LOG IN - AJAX - Action to connect **/ |
| 106 | 106 | function control_login_form_request() { |
| 107 | 107 | |
| 108 | - $_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : ''; |
|
| 108 | + $_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : ''; |
|
| 109 | 109 | |
| 110 | - if ( !wp_verify_nonce( $_wpnonce, 'control_login_form_request' ) ) |
|
| 110 | + if (!wp_verify_nonce($_wpnonce, 'control_login_form_request')) |
|
| 111 | 111 | wp_die(); |
| 112 | 112 | |
| 113 | 113 | $result = ''; |
| 114 | 114 | $status = false; |
| 115 | - $origin = sanitize_text_field( $_POST['wps-checking-origin'] ); |
|
| 116 | - $wps_login_user_login = !empty( $_POST['wps_login_user_login'] ) ? sanitize_text_field( $_POST['wps_login_user_login' ] ) : ''; |
|
| 117 | - $wps_login_password = !empty( $_POST['wps_login_password'] ) ? sanitize_text_field( $_POST['wps_login_password' ] ) : ''; |
|
| 118 | - $page_account_id = wpshop_tools::get_page_id( get_option( 'wpshop_myaccount_page_id') ); |
|
| 119 | - if ( !empty($wps_login_user_login) && !empty($wps_login_password) ) { |
|
| 115 | + $origin = sanitize_text_field($_POST['wps-checking-origin']); |
|
| 116 | + $wps_login_user_login = !empty($_POST['wps_login_user_login']) ? sanitize_text_field($_POST['wps_login_user_login']) : ''; |
|
| 117 | + $wps_login_password = !empty($_POST['wps_login_password']) ? sanitize_text_field($_POST['wps_login_password']) : ''; |
|
| 118 | + $page_account_id = wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id')); |
|
| 119 | + if (!empty($wps_login_user_login) && !empty($wps_login_password)) { |
|
| 120 | 120 | $creds = array(); |
| 121 | 121 | // Test if an user exist with this login |
| 122 | - $user_checking = get_user_by( 'login', $wps_login_user_login ); |
|
| 123 | - if( !empty($user_checking) ) { |
|
| 122 | + $user_checking = get_user_by('login', $wps_login_user_login); |
|
| 123 | + if (!empty($user_checking)) { |
|
| 124 | 124 | $creds['user_login'] = $wps_login_user_login; |
| 125 | 125 | } |
| 126 | 126 | else { |
| 127 | - if ( is_email($wps_login_user_login) ) { |
|
| 128 | - $user_checking = get_user_by( 'email', $wps_login_user_login ); |
|
| 127 | + if (is_email($wps_login_user_login)) { |
|
| 128 | + $user_checking = get_user_by('email', $wps_login_user_login); |
|
| 129 | 129 | $creds['user_login'] = $user_checking->user_login; |
| 130 | 130 | } |
| 131 | 131 | } |
| 132 | - $creds['user_password'] = wpshop_tools::varSanitizer( $_POST['wps_login_password'] ); |
|
| 133 | - $creds['remember'] = !empty( $_POST['wps_login_remember_me'] ) ? (int) $_POST['wps_login_remember_me'] : false; |
|
| 134 | - $user = wp_signon( $creds, false ); |
|
| 135 | - if ( is_wp_error($user) ) { |
|
| 136 | - $result = '<div class="wps-alert-error">' .__('Connexion error', 'wpshop'). '</div>'; |
|
| 132 | + $creds['user_password'] = wpshop_tools::varSanitizer($_POST['wps_login_password']); |
|
| 133 | + $creds['remember'] = !empty($_POST['wps_login_remember_me']) ? (int)$_POST['wps_login_remember_me'] : false; |
|
| 134 | + $user = wp_signon($creds, false); |
|
| 135 | + if (is_wp_error($user)) { |
|
| 136 | + $result = '<div class="wps-alert-error">' . __('Connexion error', 'wpshop') . '</div>'; |
|
| 137 | 137 | } |
| 138 | 138 | else { |
| 139 | - $permalink_option = get_option( 'permalink_structure' ); |
|
| 140 | - $checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) ); |
|
| 141 | - if( $origin == $page_account_id ) { |
|
| 142 | - $result = get_permalink( $page_account_id ); |
|
| 139 | + $permalink_option = get_option('permalink_structure'); |
|
| 140 | + $checkout_page_id = wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id')); |
|
| 141 | + if ($origin == $page_account_id) { |
|
| 142 | + $result = get_permalink($page_account_id); |
|
| 143 | 143 | } |
| 144 | 144 | else { |
| 145 | - $result = get_permalink( $checkout_page_id ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step=3'; |
|
| 145 | + $result = get_permalink($checkout_page_id) . ((!empty($permalink_option)) ? '?' : '&') . 'order_step=3'; |
|
| 146 | 146 | } |
| 147 | 147 | $status = true; |
| 148 | 148 | } |
| 149 | 149 | } |
| 150 | 150 | else { |
| 151 | - $result = '<div class="wps-alert-error">' .__('E-Mail and Password are required', 'wpshop'). '</div>'; |
|
| 151 | + $result = '<div class="wps-alert-error">' . __('E-Mail and Password are required', 'wpshop') . '</div>'; |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - echo json_encode( array( $status, $result) ); |
|
| 154 | + echo json_encode(array($status, $result)); |
|
| 155 | 155 | die(); |
| 156 | 156 | } |
| 157 | 157 | |
@@ -159,13 +159,13 @@ discard block |
||
| 159 | 159 | * LOG IN - AJAX - Display log in Form in Ajax |
| 160 | 160 | */ |
| 161 | 161 | function wps_ajax_get_login_form_interface() { |
| 162 | - $_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : ''; |
|
| 162 | + $_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : ''; |
|
| 163 | 163 | |
| 164 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_ajax_get_login_form_interface' ) ) |
|
| 164 | + if (!wp_verify_nonce($_wpnonce, 'wps_ajax_get_login_form_interface')) |
|
| 165 | 165 | wp_die(); |
| 166 | 166 | |
| 167 | - $response = array( 'status' => true, 'response' => self::get_login_form() ); |
|
| 168 | - echo json_encode( $response ); |
|
| 167 | + $response = array('status' => true, 'response' => self::get_login_form()); |
|
| 168 | + echo json_encode($response); |
|
| 169 | 169 | die(); |
| 170 | 170 | } |
| 171 | 171 | |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | function get_login_first_step() { |
| 174 | 174 | $output = ''; |
| 175 | 175 | ob_start(); |
| 176 | - require_once( wpshop_tools::get_template_part( WPS_ACCOUNT_DIR, $this->template_dir,"frontend", "login/login-form", "first") ); |
|
| 176 | + require_once(wpshop_tools::get_template_part(WPS_ACCOUNT_DIR, $this->template_dir, "frontend", "login/login-form", "first")); |
|
| 177 | 177 | $output .= ob_get_contents(); |
| 178 | 178 | ob_end_clean(); |
| 179 | 179 | return $output; |
@@ -183,39 +183,39 @@ discard block |
||
| 183 | 183 | * LOG IN - First Step log in request |
| 184 | 184 | */ |
| 185 | 185 | function wps_login_first_request() { |
| 186 | - $_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : ''; |
|
| 186 | + $_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : ''; |
|
| 187 | 187 | |
| 188 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_login_first_request' ) ) |
|
| 188 | + if (!wp_verify_nonce($_wpnonce, 'wps_login_first_request')) |
|
| 189 | 189 | wp_die(); |
| 190 | 190 | |
| 191 | 191 | $status = false; $login_action = false; $response = ''; |
| 192 | - $user_email = ( !empty($_POST['email_address']) ) ? wpshop_tools::varSanitizer( $_POST['email_address'] ) : null; |
|
| 193 | - if ( !empty($user_email) ) { |
|
| 192 | + $user_email = (!empty($_POST['email_address'])) ? wpshop_tools::varSanitizer($_POST['email_address']) : null; |
|
| 193 | + if (!empty($user_email)) { |
|
| 194 | 194 | $status = true; |
| 195 | 195 | /** Check if a user exist with it's email **/ |
| 196 | - $checking_user = get_user_by( 'login', $user_email); |
|
| 197 | - if ( !empty($checking_user) ) { |
|
| 196 | + $checking_user = get_user_by('login', $user_email); |
|
| 197 | + if (!empty($checking_user)) { |
|
| 198 | 198 | $login_action = true; |
| 199 | - $user_firstname = get_user_meta( $checking_user->ID, 'first_name', true ); |
|
| 199 | + $user_firstname = get_user_meta($checking_user->ID, 'first_name', true); |
|
| 200 | 200 | $response = $user_firstname; |
| 201 | 201 | } |
| 202 | 202 | else { |
| 203 | - $checking_user = get_user_by( 'email', $user_email); |
|
| 204 | - if ( !empty( $checking_user ) ) { |
|
| 203 | + $checking_user = get_user_by('email', $user_email); |
|
| 204 | + if (!empty($checking_user)) { |
|
| 205 | 205 | $login_action = true; |
| 206 | - $user_firstname = get_user_meta( $checking_user->ID, 'first_name', true ); |
|
| 206 | + $user_firstname = get_user_meta($checking_user->ID, 'first_name', true); |
|
| 207 | 207 | $response = $user_firstname; |
| 208 | 208 | } |
| 209 | 209 | } |
| 210 | 210 | |
| 211 | - if( !$login_action && is_email($user_email) ) { |
|
| 211 | + if (!$login_action && is_email($user_email)) { |
|
| 212 | 212 | $response = $user_email; |
| 213 | 213 | } |
| 214 | 214 | } |
| 215 | 215 | else { |
| 216 | - $response = '<div class="wps-alert-error">' .__( 'An e-mail address is required', 'wpshop' ). '</div>'; |
|
| 216 | + $response = '<div class="wps-alert-error">' . __('An e-mail address is required', 'wpshop') . '</div>'; |
|
| 217 | 217 | } |
| 218 | - echo json_encode( array( 'status'=> $status, 'response' => $response, 'login_action' => $login_action) ); |
|
| 218 | + echo json_encode(array('status'=> $status, 'response' => $response, 'login_action' => $login_action)); |
|
| 219 | 219 | die(); |
| 220 | 220 | } |
| 221 | 221 | |
@@ -224,9 +224,9 @@ discard block |
||
| 224 | 224 | */ |
| 225 | 225 | function get_forgot_password_form() { |
| 226 | 226 | $output = ''; |
| 227 | - if ( get_current_user_id() == 0 ) { |
|
| 227 | + if (get_current_user_id() == 0) { |
|
| 228 | 228 | ob_start(); |
| 229 | - require_once( wpshop_tools::get_template_part( WPS_ACCOUNT_DIR, $this->template_dir, "frontend", "forgot-password/forgot-password") ); |
|
| 229 | + require_once(wpshop_tools::get_template_part(WPS_ACCOUNT_DIR, $this->template_dir, "frontend", "forgot-password/forgot-password")); |
|
| 230 | 230 | $output = ob_get_contents(); |
| 231 | 231 | ob_end_clean(); |
| 232 | 232 | } |
@@ -237,16 +237,16 @@ discard block |
||
| 237 | 237 | * FORGOT PASSWORD - AJAX - Fill the forgot password modal |
| 238 | 238 | */ |
| 239 | 239 | function wps_fill_forgot_password_modal() { |
| 240 | - $_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : ''; |
|
| 240 | + $_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : ''; |
|
| 241 | 241 | |
| 242 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_fill_forgot_password_modal' ) ) |
|
| 242 | + if (!wp_verify_nonce($_wpnonce, 'wps_fill_forgot_password_modal')) |
|
| 243 | 243 | wp_die(); |
| 244 | 244 | |
| 245 | 245 | $status = false; $title = $content = ''; |
| 246 | - $title = __( 'Forgot password', 'wpshop' ); |
|
| 246 | + $title = __('Forgot password', 'wpshop'); |
|
| 247 | 247 | $content = do_shortcode('[wps_forgot_password]'); |
| 248 | 248 | $status = true; |
| 249 | - echo json_encode( array('status' => $status, 'title' => $title, 'content' => $content) ); |
|
| 249 | + echo json_encode(array('status' => $status, 'title' => $title, 'content' => $content)); |
|
| 250 | 250 | wp_die(); |
| 251 | 251 | } |
| 252 | 252 | |
@@ -254,48 +254,48 @@ discard block |
||
| 254 | 254 | * FORGOT PASSWORD- AJAX - Forgot Password Request |
| 255 | 255 | */ |
| 256 | 256 | function wps_forgot_password_request() { |
| 257 | - $_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : ''; |
|
| 257 | + $_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : ''; |
|
| 258 | 258 | |
| 259 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_forgot_password_request' ) ) |
|
| 259 | + if (!wp_verify_nonce($_wpnonce, 'wps_forgot_password_request')) |
|
| 260 | 260 | wp_die(); |
| 261 | 261 | |
| 262 | 262 | global $wpdb; |
| 263 | 263 | $status = false; $result = ''; |
| 264 | - $user_login = ( !empty( $_POST['wps_user_login']) ) ? wpshop_tools::varSanitizer($_POST['wps_user_login']) : null; |
|
| 265 | - if ( !empty($user_login) ) { |
|
| 264 | + $user_login = (!empty($_POST['wps_user_login'])) ? wpshop_tools::varSanitizer($_POST['wps_user_login']) : null; |
|
| 265 | + if (!empty($user_login)) { |
|
| 266 | 266 | $existing_user = false; |
| 267 | 267 | $key_for_update = 'user_login'; |
| 268 | 268 | $exist_user = get_user_by('login', $user_login); |
| 269 | - if( !empty($exist_user) ) { |
|
| 269 | + if (!empty($exist_user)) { |
|
| 270 | 270 | $existing_user = true; |
| 271 | 271 | } |
| 272 | 272 | else { |
| 273 | 273 | $exist_user = get_user_by('email', $user_login); |
| 274 | 274 | $key_for_update = 'user_email'; |
| 275 | - if ( !empty($exist_user) ) { |
|
| 275 | + if (!empty($exist_user)) { |
|
| 276 | 276 | $existing_user = true; |
| 277 | 277 | } |
| 278 | 278 | } |
| 279 | 279 | |
| 280 | - if ( $existing_user ) { |
|
| 280 | + if ($existing_user) { |
|
| 281 | 281 | $key = $wpdb->get_var($wpdb->prepare("SELECT user_activation_key FROM $wpdb->users WHERE $key_for_update = %s", $user_login)); |
| 282 | - if ( empty($key) ) { |
|
| 282 | + if (empty($key)) { |
|
| 283 | 283 | $key = wp_generate_password(20, false); |
| 284 | 284 | $wpdb->update($wpdb->users, array('user_activation_key' => $key), array('user_login' => $user_login)); |
| 285 | 285 | } |
| 286 | 286 | $this->send_forgot_password_email($key, $user_login, $exist_user); |
| 287 | - $result = '<div class="wps-alert-info">' .__('An e-mail with an password renew link has been sent to you', 'wpshop'). '</div>'; |
|
| 287 | + $result = '<div class="wps-alert-info">' . __('An e-mail with an password renew link has been sent to you', 'wpshop') . '</div>'; |
|
| 288 | 288 | $status = true; |
| 289 | 289 | } |
| 290 | 290 | else { |
| 291 | - $result = '<div class="wps-alert-error">' .__('No customer account corresponds to this email', 'wpshop'). '</div>'; |
|
| 291 | + $result = '<div class="wps-alert-error">' . __('No customer account corresponds to this email', 'wpshop') . '</div>'; |
|
| 292 | 292 | } |
| 293 | 293 | } |
| 294 | 294 | else { |
| 295 | - $result = '<div class="wps-alert-error">' .__('Please fill the required field', 'wpshop'). '</div>'; |
|
| 295 | + $result = '<div class="wps-alert-error">' . __('Please fill the required field', 'wpshop') . '</div>'; |
|
| 296 | 296 | } |
| 297 | - $response = array( $status, $result ); |
|
| 298 | - echo json_encode( $response ); |
|
| 297 | + $response = array($status, $result); |
|
| 298 | + echo json_encode($response); |
|
| 299 | 299 | die(); |
| 300 | 300 | } |
| 301 | 301 | |
@@ -304,67 +304,67 @@ discard block |
||
| 304 | 304 | * @param string $key |
| 305 | 305 | * @param string $user_login |
| 306 | 306 | */ |
| 307 | - function send_forgot_password_email($key, $user_login, $exist_user){ |
|
| 307 | + function send_forgot_password_email($key, $user_login, $exist_user) { |
|
| 308 | 308 | $user_data = $exist_user->data; |
| 309 | 309 | $email = $user_data->user_email; |
| 310 | 310 | $wps_message = new wps_message_ctr(); |
| 311 | - $first_name = get_user_meta( $user_data->ID, 'first_name', true ); |
|
| 312 | - $last_name = get_user_meta( $user_data->ID, 'last_name', true ); |
|
| 313 | - $permalink_option = get_option( 'permalink_structure' ); |
|
| 314 | - $link = '<a href="' .get_permalink( wpshop_tools::get_page_id( get_option('wpshop_checkout_page_id') ) ).( (!empty($permalink_option)) ? '?' : '&').'order_step=2&action=retrieve_password&key=' .$key. '&login=' .rawurlencode($user_login). '">' .get_permalink( wpshop_tools::get_page_id( get_option('wpshop_checkout_page_id') ) ). '&action=retrieve_password&key=' .$key. '&login=' .rawurlencode($user_login). '</a>'; |
|
| 315 | - if( !empty($key) && !empty( $user_login ) ) { |
|
| 311 | + $first_name = get_user_meta($user_data->ID, 'first_name', true); |
|
| 312 | + $last_name = get_user_meta($user_data->ID, 'last_name', true); |
|
| 313 | + $permalink_option = get_option('permalink_structure'); |
|
| 314 | + $link = '<a href="' . get_permalink(wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id'))) . ((!empty($permalink_option)) ? '?' : '&') . 'order_step=2&action=retrieve_password&key=' . $key . '&login=' . rawurlencode($user_login) . '">' . get_permalink(wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id'))) . '&action=retrieve_password&key=' . $key . '&login=' . rawurlencode($user_login) . '</a>'; |
|
| 315 | + if (!empty($key) && !empty($user_login)) { |
|
| 316 | 316 | $wps_message->wpshop_prepared_email($email, |
| 317 | 317 | 'WPSHOP_FORGOT_PASSWORD_MESSAGE', |
| 318 | - array( 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'forgot_password_link' => $link) |
|
| 318 | + array('customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'forgot_password_link' => $link) |
|
| 319 | 319 | ); |
| 320 | 320 | } |
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | /** FORGOT PASSWORD - AJAX - Make renew password action **/ |
| 324 | 324 | function wps_forgot_password_renew() { |
| 325 | - check_ajax_referer( 'wps_forgot_password_renew' ); |
|
| 325 | + check_ajax_referer('wps_forgot_password_renew'); |
|
| 326 | 326 | |
| 327 | 327 | global $wpdb; |
| 328 | 328 | $status = false; $result = $form = ''; |
| 329 | - $password = ( !empty( $_POST['pass1']) ) ? wpshop_tools::varSanitizer( $_POST['pass1'] ) : null; |
|
| 330 | - $confirm_password = ( !empty( $_POST['pass2']) ) ? wpshop_tools::varSanitizer( $_POST['pass2'] ) : null; |
|
| 331 | - $activation_key = ( !empty( $_POST['activation_key']) ) ? wpshop_tools::varSanitizer( $_POST['activation_key'] ) : null; |
|
| 332 | - $login = ( !empty( $_POST['user_login']) ) ? wpshop_tools::varSanitizer( $_POST['user_login'] ) : null; |
|
| 333 | - if ( !empty($password) && !empty($confirm_password) && $confirm_password == $password ) { |
|
| 334 | - if ( !empty($activation_key) && !empty($login) ) { |
|
| 329 | + $password = (!empty($_POST['pass1'])) ? wpshop_tools::varSanitizer($_POST['pass1']) : null; |
|
| 330 | + $confirm_password = (!empty($_POST['pass2'])) ? wpshop_tools::varSanitizer($_POST['pass2']) : null; |
|
| 331 | + $activation_key = (!empty($_POST['activation_key'])) ? wpshop_tools::varSanitizer($_POST['activation_key']) : null; |
|
| 332 | + $login = (!empty($_POST['user_login'])) ? wpshop_tools::varSanitizer($_POST['user_login']) : null; |
|
| 333 | + if (!empty($password) && !empty($confirm_password) && $confirm_password == $password) { |
|
| 334 | + if (!empty($activation_key) && !empty($login)) { |
|
| 335 | 335 | $existing_user = false; |
| 336 | - $user = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->users WHERE user_activation_key = %s AND user_login = %s", $activation_key, $login ) ); |
|
| 337 | - if( !empty($user) ) { |
|
| 336 | + $user = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->users WHERE user_activation_key = %s AND user_login = %s", $activation_key, $login)); |
|
| 337 | + if (!empty($user)) { |
|
| 338 | 338 | $existing_user = true; |
| 339 | 339 | } |
| 340 | 340 | else { |
| 341 | - $user = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->users WHERE user_activation_key = %s AND user_email = %s", $activation_key, $login ) ); |
|
| 342 | - if( !empty($user) ) { |
|
| 341 | + $user = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->users WHERE user_activation_key = %s AND user_email = %s", $activation_key, $login)); |
|
| 342 | + if (!empty($user)) { |
|
| 343 | 343 | $existing_user = true; |
| 344 | 344 | } |
| 345 | 345 | } |
| 346 | 346 | |
| 347 | - if ( $existing_user ){ |
|
| 347 | + if ($existing_user) { |
|
| 348 | 348 | wp_set_password($password, $user->ID); |
| 349 | 349 | wp_password_change_notification($user); |
| 350 | 350 | $status = true; |
| 351 | - $result = '<div class="wps-alert-success">' .__('Your password has been updated', 'wpshop'). '. <a href="#" id="display_connexion_form"> ' .__('Connect you', 'wpshop').' !</a></div>'; |
|
| 352 | - $form = self::get_login_form( true ); |
|
| 351 | + $result = '<div class="wps-alert-success">' . __('Your password has been updated', 'wpshop') . '. <a href="#" id="display_connexion_form"> ' . __('Connect you', 'wpshop') . ' !</a></div>'; |
|
| 352 | + $form = self::get_login_form(true); |
|
| 353 | 353 | } |
| 354 | 354 | else { |
| 355 | - $result = '<div class=" wps-alert-error">' .__('Invalid activation key', 'wpshop'). '</div>'; |
|
| 355 | + $result = '<div class=" wps-alert-error">' . __('Invalid activation key', 'wpshop') . '</div>'; |
|
| 356 | 356 | } |
| 357 | 357 | } |
| 358 | 358 | else { |
| 359 | - $result = '<div class=" wps-alert-error">' .__('Invalid activation key', 'wpshop'). '</div>'; |
|
| 359 | + $result = '<div class=" wps-alert-error">' . __('Invalid activation key', 'wpshop') . '</div>'; |
|
| 360 | 360 | } |
| 361 | 361 | } |
| 362 | 362 | else { |
| 363 | - $result = '<div class="wps-alert-error">' .__('Password and confirmation password are differents', 'wpshop'). '</div>'; |
|
| 363 | + $result = '<div class="wps-alert-error">' . __('Password and confirmation password are differents', 'wpshop') . '</div>'; |
|
| 364 | 364 | } |
| 365 | 365 | |
| 366 | - $response = array( $status, $result, $form ); |
|
| 367 | - echo json_encode( $response); |
|
| 366 | + $response = array($status, $result, $form); |
|
| 367 | + echo json_encode($response); |
|
| 368 | 368 | die(); |
| 369 | 369 | } |
| 370 | 370 | |
@@ -373,9 +373,9 @@ discard block |
||
| 373 | 373 | * @return string |
| 374 | 374 | */ |
| 375 | 375 | function get_renew_password_form() { |
| 376 | - if ( get_current_user_id() == 0 ) { |
|
| 376 | + if (get_current_user_id() == 0) { |
|
| 377 | 377 | ob_start(); |
| 378 | - require_once( wpshop_tools::get_template_part( WPS_ACCOUNT_DIR, $this->template_dir,"frontend", "forgot-password/password-renew") ); |
|
| 378 | + require_once(wpshop_tools::get_template_part(WPS_ACCOUNT_DIR, $this->template_dir, "frontend", "forgot-password/password-renew")); |
|
| 379 | 379 | $output = ob_get_contents(); |
| 380 | 380 | ob_end_clean(); |
| 381 | 381 | } |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | |
| 385 | 385 | /** FORGOT PASSWORD - AJAX - Get Forgot Password form **/ |
| 386 | 386 | function wps_ajax_get_forgot_password_form() { |
| 387 | - echo json_encode( array(self::get_forgot_password_form() ) ); |
|
| 387 | + echo json_encode(array(self::get_forgot_password_form())); |
|
| 388 | 388 | die(); |
| 389 | 389 | } |
| 390 | 390 | |
@@ -392,29 +392,29 @@ discard block |
||
| 392 | 392 | * SIGN UP - Display Sign up form |
| 393 | 393 | * @return string |
| 394 | 394 | */ |
| 395 | - function display_signup( $args = array() ) { |
|
| 395 | + function display_signup($args = array()) { |
|
| 396 | 396 | global $wpdb; |
| 397 | 397 | $output = ''; |
| 398 | - if ( get_current_user_id() == 0 || !empty($args) ) { |
|
| 398 | + if (get_current_user_id() == 0 || !empty($args)) { |
|
| 399 | 399 | $fields_to_output = $signup_fields = array(); |
| 400 | 400 | |
| 401 | - $password_attribute = $signup_form_attributes = array(); |
|
| 401 | + $password_attribute = $signup_form_attributes = array(); |
|
| 402 | 402 | |
| 403 | - $entity_id = wpshop_entities::get_entity_identifier_from_code( WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS ); |
|
| 403 | + $entity_id = wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS); |
|
| 404 | 404 | |
| 405 | - $query = $wpdb->prepare('SELECT id FROM '.WPSHOP_DBT_ATTRIBUTE_SET.' WHERE entity_id = %d', $entity_id); |
|
| 406 | - $customer_entity_id = $wpdb->get_var( $query ); |
|
| 405 | + $query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE entity_id = %d', $entity_id); |
|
| 406 | + $customer_entity_id = $wpdb->get_var($query); |
|
| 407 | 407 | $attributes_set = wpshop_attributes_set::getElement($customer_entity_id); |
| 408 | - $account_attributes = wpshop_attributes_set::getAttributeSetDetails( ( !empty($attributes_set->id) ) ? $attributes_set->id : '', "'valid'"); |
|
| 409 | - $query = $wpdb->prepare('SELECT id FROM '.WPSHOP_DBT_ATTRIBUTE_GROUP.' WHERE attribute_set_id = %d AND status = %s', $attributes_set->id, 'valid' ); |
|
| 410 | - $customer_attributes_sections = $wpdb->get_results( $query ); |
|
| 411 | - foreach( $customer_attributes_sections as $k => $customer_attributes_section ) { |
|
| 412 | - foreach( $account_attributes[$customer_attributes_section->id]['attribut'] as $attribute ) { |
|
| 408 | + $account_attributes = wpshop_attributes_set::getAttributeSetDetails((!empty($attributes_set->id)) ? $attributes_set->id : '', "'valid'"); |
|
| 409 | + $query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE_GROUP . ' WHERE attribute_set_id = %d AND status = %s', $attributes_set->id, 'valid'); |
|
| 410 | + $customer_attributes_sections = $wpdb->get_results($query); |
|
| 411 | + foreach ($customer_attributes_sections as $k => $customer_attributes_section) { |
|
| 412 | + foreach ($account_attributes[$customer_attributes_section->id]['attribut'] as $attribute) { |
|
| 413 | 413 | $signup_fields[] = $attribute; |
| 414 | 414 | } |
| 415 | 415 | } |
| 416 | 416 | ob_start(); |
| 417 | - require( wpshop_tools::get_template_part( WPS_ACCOUNT_DIR, $this->template_dir,"frontend", "signup/signup") ); |
|
| 417 | + require(wpshop_tools::get_template_part(WPS_ACCOUNT_DIR, $this->template_dir, "frontend", "signup/signup")); |
|
| 418 | 418 | $output = ob_get_contents(); |
| 419 | 419 | ob_end_clean(); |
| 420 | 420 | } |
@@ -422,119 +422,119 @@ discard block |
||
| 422 | 422 | } |
| 423 | 423 | |
| 424 | 424 | function wps_save_signup_form_nopriv() { |
| 425 | - $this->wps_save_signup_form( true ); |
|
| 425 | + $this->wps_save_signup_form(true); |
|
| 426 | 426 | } |
| 427 | 427 | |
| 428 | 428 | /** |
| 429 | 429 | * SIGN UP - Save sign up form |
| 430 | 430 | */ |
| 431 | - function wps_save_signup_form( $connect = false ) { |
|
| 432 | - $_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : ''; |
|
| 431 | + function wps_save_signup_form($connect = false) { |
|
| 432 | + $_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : ''; |
|
| 433 | 433 | |
| 434 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_save_signup_form' ) ) |
|
| 434 | + if (!wp_verify_nonce($_wpnonce, 'wps_save_signup_form')) |
|
| 435 | 435 | wp_die(); |
| 436 | 436 | |
| 437 | 437 | global $wpdb, $wpshop; |
| 438 | - $user_id = ( !empty( $_POST['wps_sign_up_request_from_admin'] ) ) ? (int) $_POST['wps_sign_up_request_from_admin'] : get_current_user_id(); |
|
| 438 | + $user_id = (!empty($_POST['wps_sign_up_request_from_admin'])) ? (int)$_POST['wps_sign_up_request_from_admin'] : get_current_user_id(); |
|
| 439 | 439 | $wps_message = new wps_message_ctr(); |
| 440 | 440 | $status = $account_creation = false; $result = ''; |
| 441 | - $exclude_user_meta = array( 'user_email', 'user_pass' ); |
|
| 442 | - $attribute = !empty( $_POST['attribute'] ) ? (array) $_POST['attribute'] : array(); |
|
| 443 | - $element_id = wpshop_entities::get_entity_identifier_from_code( WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS ); |
|
| 444 | - if ( !empty( $element_id) ){ |
|
| 445 | - $query = $wpdb->prepare('SELECT id FROM ' .WPSHOP_DBT_ATTRIBUTE_SET. ' WHERE entity_id = %d', $element_id ); |
|
| 446 | - $attribute_set_id = $wpdb->get_var( $query ); |
|
| 447 | - if ( !empty($attribute_set_id) ){ |
|
| 448 | - $group = wps_address::get_addresss_form_fields_by_type( $attribute_set_id ); |
|
| 449 | - foreach ( $group as $attribute_sets ) { |
|
| 450 | - foreach ( $attribute_sets as $attribute_set_field ) { |
|
| 451 | - if( !empty($user_id) ) { |
|
| 452 | - foreach( $attribute_set_field['content'] as $attribute_code => $att_def ) { |
|
| 453 | - if( $attribute_code != 'account_user_email' ) { |
|
| 441 | + $exclude_user_meta = array('user_email', 'user_pass'); |
|
| 442 | + $attribute = !empty($_POST['attribute']) ? (array)$_POST['attribute'] : array(); |
|
| 443 | + $element_id = wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS); |
|
| 444 | + if (!empty($element_id)) { |
|
| 445 | + $query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE entity_id = %d', $element_id); |
|
| 446 | + $attribute_set_id = $wpdb->get_var($query); |
|
| 447 | + if (!empty($attribute_set_id)) { |
|
| 448 | + $group = wps_address::get_addresss_form_fields_by_type($attribute_set_id); |
|
| 449 | + foreach ($group as $attribute_sets) { |
|
| 450 | + foreach ($attribute_sets as $attribute_set_field) { |
|
| 451 | + if (!empty($user_id)) { |
|
| 452 | + foreach ($attribute_set_field['content'] as $attribute_code => $att_def) { |
|
| 453 | + if ($attribute_code != 'account_user_email') { |
|
| 454 | 454 | $attribute_set_field['content'][$attribute_code]['required'] = 'no'; |
| 455 | 455 | } |
| 456 | 456 | } |
| 457 | 457 | } |
| 458 | - $validate = $wpshop->validateForm($attribute_set_field['content'], $attribute ); |
|
| 458 | + $validate = $wpshop->validateForm($attribute_set_field['content'], $attribute); |
|
| 459 | 459 | } |
| 460 | - if ( empty($wpshop->errors) ) { |
|
| 461 | - $user_name = !empty($attribute['varchar']['user_login']) ? sanitize_text_field( $attribute['varchar']['user_login'] ) : sanitize_email( $attribute['varchar']['user_email'] ); |
|
| 462 | - $user_pass = ( !empty($attribute['varchar']['user_pass']) && !empty($_POST['wps_signup_account_creation']) ) ? sanitize_text_field( $attribute['varchar']['user_pass'] ) : wp_generate_password( 12, false ); |
|
| 460 | + if (empty($wpshop->errors)) { |
|
| 461 | + $user_name = !empty($attribute['varchar']['user_login']) ? sanitize_text_field($attribute['varchar']['user_login']) : sanitize_email($attribute['varchar']['user_email']); |
|
| 462 | + $user_pass = (!empty($attribute['varchar']['user_pass']) && !empty($_POST['wps_signup_account_creation'])) ? sanitize_text_field($attribute['varchar']['user_pass']) : wp_generate_password(12, false); |
|
| 463 | 463 | |
| 464 | - if ( $user_id == 0 ) { |
|
| 465 | - $user_id = wp_create_user($user_name, $user_pass, sanitize_email( $attribute['varchar']['user_email'] ) ); |
|
| 466 | - if ( !is_object( $user_id) ) { |
|
| 464 | + if ($user_id == 0) { |
|
| 465 | + $user_id = wp_create_user($user_name, $user_pass, sanitize_email($attribute['varchar']['user_email'])); |
|
| 466 | + if (!is_object($user_id)) { |
|
| 467 | 467 | $account_creation = true; |
| 468 | 468 | /** Update newsletter user preferences **/ |
| 469 | 469 | $newsletter_preferences = array(); |
| 470 | - $newsletters_site = !empty( $_POST['newsletters_site'] ) ? (bool) $_POST['newsletters_site'] : false; |
|
| 471 | - if( $newsletters_site ) { |
|
| 470 | + $newsletters_site = !empty($_POST['newsletters_site']) ? (bool)$_POST['newsletters_site'] : false; |
|
| 471 | + if ($newsletters_site) { |
|
| 472 | 472 | $newsletter_preferences['newsletters_site'] = 1; |
| 473 | 473 | } |
| 474 | - $newsletters_site_partners = !empty( $_POST['newsletters_site_partners'] ) ? (bool) $_POST['newsletters_site_partners'] : false; |
|
| 475 | - if( $newsletters_site_partners ) { |
|
| 474 | + $newsletters_site_partners = !empty($_POST['newsletters_site_partners']) ? (bool)$_POST['newsletters_site_partners'] : false; |
|
| 475 | + if ($newsletters_site_partners) { |
|
| 476 | 476 | $newsletter_preferences['newsletters_site_partners'] = 1; |
| 477 | 477 | } |
| 478 | 478 | |
| 479 | - update_user_meta( $user_id, 'user_preferences', $newsletter_preferences); |
|
| 479 | + update_user_meta($user_id, 'user_preferences', $newsletter_preferences); |
|
| 480 | 480 | } |
| 481 | 481 | } |
| 482 | 482 | |
| 483 | - $customer_entity_request = $wpdb->prepare( 'SELECT ID FROM ' .$wpdb->posts. ' WHERE post_type = %s AND post_author = %d', WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, $user_id); |
|
| 484 | - $customer_post_ID = $wpdb->get_var( $customer_entity_request ); |
|
| 483 | + $customer_entity_request = $wpdb->prepare('SELECT ID FROM ' . $wpdb->posts . ' WHERE post_type = %s AND post_author = %d', WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, $user_id); |
|
| 484 | + $customer_post_ID = $wpdb->get_var($customer_entity_request); |
|
| 485 | 485 | |
| 486 | - if( !empty( $attribute ) ) { |
|
| 486 | + if (!empty($attribute)) { |
|
| 487 | 487 | $user_info = $address_forms = $all_addresses_form = array(); |
| 488 | - $billing_option = get_option( 'wpshop_billing_address' ); |
|
| 489 | - foreach( $attribute as $type => $attributes ) { |
|
| 490 | - if( !empty( $billing_option['integrate_into_register_form'] ) && $billing_option['integrate_into_register_form'] == 'yes' && ctype_digit( (string) $type ) ) { |
|
| 488 | + $billing_option = get_option('wpshop_billing_address'); |
|
| 489 | + foreach ($attribute as $type => $attributes) { |
|
| 490 | + if (!empty($billing_option['integrate_into_register_form']) && $billing_option['integrate_into_register_form'] == 'yes' && ctype_digit((string)$type)) { |
|
| 491 | 491 | //wps_address::save_address_infos( (int) $type ); |
| 492 | - foreach( $attributes as $sub_type => $sub_attributes ) { |
|
| 493 | - if( !is_array( $sub_attributes ) ) { |
|
| 494 | - $address_forms[$type][$sub_type] = sanitize_text_field( $sub_attributes ); |
|
| 492 | + foreach ($attributes as $sub_type => $sub_attributes) { |
|
| 493 | + if (!is_array($sub_attributes)) { |
|
| 494 | + $address_forms[$type][$sub_type] = sanitize_text_field($sub_attributes); |
|
| 495 | 495 | continue; |
| 496 | 496 | } |
| 497 | - foreach( $sub_attributes as $sub_meta => $sub_attribute_value ) { |
|
| 498 | - $address_forms[$type][$sub_type][$sub_meta] = sanitize_text_field( $sub_attribute_value ); |
|
| 497 | + foreach ($sub_attributes as $sub_meta => $sub_attribute_value) { |
|
| 498 | + $address_forms[$type][$sub_type][$sub_meta] = sanitize_text_field($sub_attribute_value); |
|
| 499 | 499 | } |
| 500 | 500 | } |
| 501 | 501 | } else { |
| 502 | - foreach( $attributes as $meta => $attribute_value ) { |
|
| 503 | - $user_info[$meta] = sanitize_text_field( $attribute_value ); |
|
| 504 | - if( !empty( $billing_option['integrate_into_register_form'] ) && $billing_option['integrate_into_register_form'] == 'yes' && isset( $billing_option['integrate_into_register_form_matching_field'], $billing_option['integrate_into_register_form_matching_field'][$meta] ) ) { |
|
| 502 | + foreach ($attributes as $meta => $attribute_value) { |
|
| 503 | + $user_info[$meta] = sanitize_text_field($attribute_value); |
|
| 504 | + if (!empty($billing_option['integrate_into_register_form']) && $billing_option['integrate_into_register_form'] == 'yes' && isset($billing_option['integrate_into_register_form_matching_field'], $billing_option['integrate_into_register_form_matching_field'][$meta])) { |
|
| 505 | 505 | $all_addresses_form[$type][$meta] = $user_info[$meta]; |
| 506 | 506 | } |
| 507 | 507 | } |
| 508 | 508 | } |
| 509 | 509 | } |
| 510 | - wps_customer_ctr::save_customer_synchronize( $customer_post_ID, $user_id, $user_info ); |
|
| 511 | - foreach( $address_forms as $type_of_form => $address_form ) { |
|
| 512 | - $address_form = array_merge_recursive( $all_addresses_form, $address_form ); |
|
| 513 | - wps_address::save_address_infos( (int) $type_of_form, 0, array( 'type_of_form' => (int) $type_of_form, 'attribute' => array( $type_of_form => $address_form ) ), $customer_post_ID ); |
|
| 510 | + wps_customer_ctr::save_customer_synchronize($customer_post_ID, $user_id, $user_info); |
|
| 511 | + foreach ($address_forms as $type_of_form => $address_form) { |
|
| 512 | + $address_form = array_merge_recursive($all_addresses_form, $address_form); |
|
| 513 | + wps_address::save_address_infos((int)$type_of_form, 0, array('type_of_form' => (int)$type_of_form, 'attribute' => array($type_of_form => $address_form)), $customer_post_ID); |
|
| 514 | 514 | } |
| 515 | 515 | } |
| 516 | 516 | |
| 517 | - if ( !empty( $_SESSION ) && !empty( $_SESSION[ 'cart' ] ) ) { |
|
| 518 | - $permalink_option = get_option( 'permalink_structure' ); |
|
| 519 | - $checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' )); |
|
| 520 | - $result = get_permalink( $checkout_page_id ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step=3'; |
|
| 517 | + if (!empty($_SESSION) && !empty($_SESSION['cart'])) { |
|
| 518 | + $permalink_option = get_option('permalink_structure'); |
|
| 519 | + $checkout_page_id = wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id')); |
|
| 520 | + $result = get_permalink($checkout_page_id) . ((!empty($permalink_option)) ? '?' : '&') . 'order_step=3'; |
|
| 521 | 521 | } |
| 522 | 522 | else { |
| 523 | - $account_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_myaccount_page_id' )); |
|
| 524 | - $result = get_permalink( $account_page_id ); |
|
| 523 | + $account_page_id = wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id')); |
|
| 524 | + $result = get_permalink($account_page_id); |
|
| 525 | 525 | } |
| 526 | 526 | $status = true; |
| 527 | 527 | |
| 528 | - if ( $account_creation && !empty( $user_id ) && $connect ) { |
|
| 528 | + if ($account_creation && !empty($user_id) && $connect) { |
|
| 529 | 529 | $secure_cookie = is_ssl() ? true : false; |
| 530 | - wp_set_auth_cookie( $user_id, true, $secure_cookie ); |
|
| 530 | + wp_set_auth_cookie($user_id, true, $secure_cookie); |
|
| 531 | 531 | } |
| 532 | - $wps_message->wpshop_prepared_email( sanitize_email($attribute['varchar']['user_email']), 'WPSHOP_SIGNUP_MESSAGE', array('customer_first_name' => ( !empty($attribute['varchar']['first_name']) ) ? sanitize_text_field( $attribute['varchar']['first_name'] ) : '', 'customer_last_name' => ( !empty($attribute['varchar']['last_name']) ) ? sanitize_text_field( $attribute['varchar']['last_name'] ) : '', 'customer_user_email' => ( !empty($attribute['varchar']['user_email']) ) ? sanitize_email( $attribute['varchar']['user_email'] ) : '') ); |
|
| 532 | + $wps_message->wpshop_prepared_email(sanitize_email($attribute['varchar']['user_email']), 'WPSHOP_SIGNUP_MESSAGE', array('customer_first_name' => (!empty($attribute['varchar']['first_name'])) ? sanitize_text_field($attribute['varchar']['first_name']) : '', 'customer_last_name' => (!empty($attribute['varchar']['last_name'])) ? sanitize_text_field($attribute['varchar']['last_name']) : '', 'customer_user_email' => (!empty($attribute['varchar']['user_email'])) ? sanitize_email($attribute['varchar']['user_email']) : '')); |
|
| 533 | 533 | |
| 534 | 534 | } else { |
| 535 | - $result = '<div class="wps-alert-error">' .__('Some errors have been detected', 'wpshop') . ' : <ul>'; |
|
| 536 | - foreach( $wpshop->errors as $error ){ |
|
| 537 | - $result .= '<li>' .$error. '</li>'; |
|
| 535 | + $result = '<div class="wps-alert-error">' . __('Some errors have been detected', 'wpshop') . ' : <ul>'; |
|
| 536 | + foreach ($wpshop->errors as $error) { |
|
| 537 | + $result .= '<li>' . $error . '</li>'; |
|
| 538 | 538 | } |
| 539 | 539 | $result .= '</div>'; |
| 540 | 540 | } |
@@ -543,7 +543,7 @@ discard block |
||
| 543 | 543 | } |
| 544 | 544 | } |
| 545 | 545 | |
| 546 | - wp_die( json_encode( array( $status, $result, $user_id ) ) ); |
|
| 546 | + wp_die(json_encode(array($status, $result, $user_id))); |
|
| 547 | 547 | } |
| 548 | 548 | |
| 549 | 549 | /** SIGN UP - Display the commercial & newsletter form |
@@ -551,10 +551,10 @@ discard block |
||
| 551 | 551 | */ |
| 552 | 552 | function display_commercial_newsletter_form() { |
| 553 | 553 | $output = ''; |
| 554 | - $user_preferences = get_user_meta( get_current_user_id(), 'user_preferences', true ); |
|
| 555 | - $wpshop_cart_option = get_option( 'wpshop_cart_option' ); |
|
| 554 | + $user_preferences = get_user_meta(get_current_user_id(), 'user_preferences', true); |
|
| 555 | + $wpshop_cart_option = get_option('wpshop_cart_option'); |
|
| 556 | 556 | ob_start(); |
| 557 | - require_once( wpshop_tools::get_template_part( WPS_ACCOUNT_DIR, $this->template_dir, "frontend", "signup/signup", "newsletter") ); |
|
| 557 | + require_once(wpshop_tools::get_template_part(WPS_ACCOUNT_DIR, $this->template_dir, "frontend", "signup/signup", "newsletter")); |
|
| 558 | 558 | $output = ob_get_contents(); |
| 559 | 559 | ob_end_clean(); |
| 560 | 560 | |
@@ -565,88 +565,88 @@ discard block |
||
| 565 | 565 | * ACCOUNT - Display Account informations |
| 566 | 566 | * @return string |
| 567 | 567 | */ |
| 568 | - function display_account_informations( $customer_id = '', $force_edition_form = false, $customer_link = false ) { |
|
| 568 | + function display_account_informations($customer_id = '', $force_edition_form = false, $customer_link = false) { |
|
| 569 | 569 | global $wpdb; |
| 570 | 570 | $output = $attributes_sections_tpl = $attribute_details = ''; |
| 571 | - $is_from_admin = ( !empty($customer_id) ) ? true : false; |
|
| 572 | - $customer_id = ( !empty($customer_id) ) ? $customer_id : get_current_user_id(); |
|
| 573 | - if( $customer_id != 0 ) { |
|
| 571 | + $is_from_admin = (!empty($customer_id)) ? true : false; |
|
| 572 | + $customer_id = (!empty($customer_id)) ? $customer_id : get_current_user_id(); |
|
| 573 | + if ($customer_id != 0) { |
|
| 574 | 574 | $screen = get_current_screen(); |
| 575 | - if( ( is_admin() && isset( $screen ) && is_object( $screen ) && $screen->post_type == WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS ) || $force_edition_form ) { |
|
| 576 | - $customer_entity_type_id = wpshop_entities::get_entity_identifier_from_code( WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS ); |
|
| 577 | - $query = $wpdb->prepare( 'SELECT ID FROM ' .$wpdb->posts. ' WHERE post_type = %s AND post_author = %d', WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, $customer_id ); |
|
| 578 | - $cid = $wpdb->get_var( $query ); |
|
| 575 | + if ((is_admin() && isset($screen) && is_object($screen) && $screen->post_type == WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS) || $force_edition_form) { |
|
| 576 | + $customer_entity_type_id = wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS); |
|
| 577 | + $query = $wpdb->prepare('SELECT ID FROM ' . $wpdb->posts . ' WHERE post_type = %s AND post_author = %d', WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, $customer_id); |
|
| 578 | + $cid = $wpdb->get_var($query); |
|
| 579 | 579 | |
| 580 | 580 | $fields_to_output = $signup_fields = array(); |
| 581 | 581 | |
| 582 | - $password_attribute = $signup_form_attributes = array(); |
|
| 582 | + $password_attribute = $signup_form_attributes = array(); |
|
| 583 | 583 | |
| 584 | - $entity_id = wpshop_entities::get_entity_identifier_from_code( WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS ); |
|
| 584 | + $entity_id = wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS); |
|
| 585 | 585 | |
| 586 | - $query = $wpdb->prepare('SELECT id FROM '.WPSHOP_DBT_ATTRIBUTE_SET.' WHERE entity_id = %d', $entity_id); |
|
| 587 | - $customer_entity_id = $wpdb->get_var( $query ); |
|
| 586 | + $query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE entity_id = %d', $entity_id); |
|
| 587 | + $customer_entity_id = $wpdb->get_var($query); |
|
| 588 | 588 | $attributes_set = wpshop_attributes_set::getElement($customer_entity_id); |
| 589 | - $account_attributes = wpshop_attributes_set::getAttributeSetDetails( ( !empty($attributes_set->id) ) ? $attributes_set->id : '', "'valid'"); |
|
| 590 | - $query = $wpdb->prepare('SELECT * FROM '.WPSHOP_DBT_ATTRIBUTE_GROUP.' WHERE attribute_set_id = %d', $attributes_set->id ); |
|
| 591 | - $customer_attributes_sections = $wpdb->get_results( $query ); |
|
| 592 | - foreach( $customer_attributes_sections as $k => $attributes_section ) { |
|
| 589 | + $account_attributes = wpshop_attributes_set::getAttributeSetDetails((!empty($attributes_set->id)) ? $attributes_set->id : '', "'valid'"); |
|
| 590 | + $query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_GROUP . ' WHERE attribute_set_id = %d', $attributes_set->id); |
|
| 591 | + $customer_attributes_sections = $wpdb->get_results($query); |
|
| 592 | + foreach ($customer_attributes_sections as $k => $attributes_section) { |
|
| 593 | 593 | $signup_fields[$attributes_section->name] = array(); |
| 594 | - if ( !empty( $account_attributes[$attributes_section->id] ) ) { |
|
| 595 | - foreach( $account_attributes[$attributes_section->id]['attribut'] as $attribute ) { |
|
| 594 | + if (!empty($account_attributes[$attributes_section->id])) { |
|
| 595 | + foreach ($account_attributes[$attributes_section->id]['attribut'] as $attribute) { |
|
| 596 | 596 | $signup_fields[$attributes_section->name][] = $attribute; |
| 597 | 597 | } |
| 598 | 598 | } |
| 599 | 599 | } |
| 600 | 600 | ob_start(); |
| 601 | - require( wpshop_tools::get_template_part( WPS_ACCOUNT_DIR, $this->template_dir,"backend", "customer-informations/customer_informations_form") ); |
|
| 601 | + require(wpshop_tools::get_template_part(WPS_ACCOUNT_DIR, $this->template_dir, "backend", "customer-informations/customer_informations_form")); |
|
| 602 | 602 | $output = ob_get_contents(); |
| 603 | 603 | ob_end_clean(); |
| 604 | 604 | } else { |
| 605 | - $customer_entity_id = wpshop_entities::get_entity_identifier_from_code( WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS ); |
|
| 606 | - $query = $wpdb->prepare( 'SELECT ID FROM ' .$wpdb->posts. ' WHERE post_type = %s AND post_author = %d', WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, $customer_id ); |
|
| 607 | - $cid = $wpdb->get_var( $query ); |
|
| 608 | - |
|
| 609 | - if( !empty($customer_entity_id) ) { |
|
| 610 | - $query = $wpdb->prepare( 'SELECT * FROM '.WPSHOP_DBT_ATTRIBUTE_SET. ' WHERE entity_id = %d AND status = %s AND default_set = %s', $customer_entity_id, 'valid', 'yes' ); |
|
| 611 | - $attributes_sets = $wpdb->get_results( $query ); |
|
| 612 | - foreach( $attributes_sets as $attributes_set ) { |
|
| 613 | - if( !empty($attributes_set->id) ) { |
|
| 614 | - $query = $wpdb->prepare( 'SELECT * FROM '. WPSHOP_DBT_ATTRIBUTE_GROUP. ' WHERE attribute_set_id = %d AND status = %s', $attributes_set->id, 'valid'); |
|
| 615 | - $attributes_sections = $wpdb->get_results( $query ); |
|
| 616 | - |
|
| 617 | - if( !empty($attributes_sections) ) { |
|
| 618 | - foreach( $attributes_sections as $attributes_section ) { |
|
| 619 | - $query = $wpdb->prepare( 'SELECT * FROM ' .WPSHOP_DBT_ATTRIBUTE_DETAILS. ' WHERE status = %s AND entity_type_id = %d AND attribute_set_id = %d AND attribute_group_id = %d', 'valid', $customer_entity_id, $attributes_set->id, $attributes_section->id); |
|
| 620 | - $attributes_details = $wpdb->get_results( $query ); |
|
| 621 | - |
|
| 622 | - foreach( $attributes_details as $attributes_detail ) { |
|
| 623 | - $query = $wpdb->prepare( 'SELECT * FROM ' .WPSHOP_DBT_ATTRIBUTE. ' WHERE id = %d AND status = %s', $attributes_detail->attribute_id, 'valid' ); |
|
| 624 | - $attribute_def = $wpdb->get_row( $query ); |
|
| 625 | - |
|
| 626 | - $query = $wpdb->prepare( 'SELECT value FROM '.WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX.strtolower($attribute_def->data_type). ' WHERE entity_type_id = %d AND attribute_id = %d AND entity_id = %d ', $customer_entity_id, $attribute_def->id, $cid ); |
|
| 627 | - $attribute_value = $wpdb->get_var( $query ); |
|
| 605 | + $customer_entity_id = wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS); |
|
| 606 | + $query = $wpdb->prepare('SELECT ID FROM ' . $wpdb->posts . ' WHERE post_type = %s AND post_author = %d', WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, $customer_id); |
|
| 607 | + $cid = $wpdb->get_var($query); |
|
| 608 | + |
|
| 609 | + if (!empty($customer_entity_id)) { |
|
| 610 | + $query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE entity_id = %d AND status = %s AND default_set = %s', $customer_entity_id, 'valid', 'yes'); |
|
| 611 | + $attributes_sets = $wpdb->get_results($query); |
|
| 612 | + foreach ($attributes_sets as $attributes_set) { |
|
| 613 | + if (!empty($attributes_set->id)) { |
|
| 614 | + $query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_GROUP . ' WHERE attribute_set_id = %d AND status = %s', $attributes_set->id, 'valid'); |
|
| 615 | + $attributes_sections = $wpdb->get_results($query); |
|
| 616 | + |
|
| 617 | + if (!empty($attributes_sections)) { |
|
| 618 | + foreach ($attributes_sections as $attributes_section) { |
|
| 619 | + $query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_DETAILS . ' WHERE status = %s AND entity_type_id = %d AND attribute_set_id = %d AND attribute_group_id = %d', 'valid', $customer_entity_id, $attributes_set->id, $attributes_section->id); |
|
| 620 | + $attributes_details = $wpdb->get_results($query); |
|
| 621 | + |
|
| 622 | + foreach ($attributes_details as $attributes_detail) { |
|
| 623 | + $query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE . ' WHERE id = %d AND status = %s', $attributes_detail->attribute_id, 'valid'); |
|
| 624 | + $attribute_def = $wpdb->get_row($query); |
|
| 625 | + |
|
| 626 | + $query = $wpdb->prepare('SELECT value FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . strtolower($attribute_def->data_type) . ' WHERE entity_type_id = %d AND attribute_id = %d AND entity_id = %d ', $customer_entity_id, $attribute_def->id, $cid); |
|
| 627 | + $attribute_value = $wpdb->get_var($query); |
|
| 628 | 628 | |
| 629 | 629 | /** Check attribute type for specific type display */ |
| 630 | - if ( "datetime" == $attribute_def->data_type ) { |
|
| 631 | - $attribute_value = mysql2date( get_option( 'date_format' ) . ( ( substr( $attribute_value, -9 ) != ' 00:00:00' ) ? ' ' . get_option( 'time_format' ) : '' ), $attribute_value, true); |
|
| 630 | + if ("datetime" == $attribute_def->data_type) { |
|
| 631 | + $attribute_value = mysql2date(get_option('date_format') . ((substr($attribute_value, -9) != ' 00:00:00') ? ' ' . get_option('time_format') : ''), $attribute_value, true); |
|
| 632 | 632 | } |
| 633 | 633 | |
| 634 | 634 | /** Check attribute input type in order to get specific value */ |
| 635 | - if ( in_array( $attribute_def->backend_input, array( 'multiple-select', 'select', 'radio', 'checkbox' ) ) ) { |
|
| 636 | - if ( $attribute_def->data_type_to_use == 'custom' ) { |
|
| 637 | - $query = $wpdb->prepare("SELECT label FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . " WHERE attribute_id = %d AND status = 'valid' AND id = %d", $attribute_def->id, $attribute_value ); |
|
| 638 | - $attribute_value = $wpdb->get_var( $query ); |
|
| 635 | + if (in_array($attribute_def->backend_input, array('multiple-select', 'select', 'radio', 'checkbox'))) { |
|
| 636 | + if ($attribute_def->data_type_to_use == 'custom') { |
|
| 637 | + $query = $wpdb->prepare("SELECT label FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . " WHERE attribute_id = %d AND status = 'valid' AND id = %d", $attribute_def->id, $attribute_value); |
|
| 638 | + $attribute_value = $wpdb->get_var($query); |
|
| 639 | 639 | } |
| 640 | - else if ( $attribute_def->data_type_to_use == 'internal') { |
|
| 641 | - $associated_post = get_post( $atribute_value ); |
|
| 640 | + else if ($attribute_def->data_type_to_use == 'internal') { |
|
| 641 | + $associated_post = get_post($atribute_value); |
|
| 642 | 642 | $attribute_value = $associated_post->post_title; |
| 643 | 643 | } |
| 644 | 644 | } |
| 645 | 645 | |
| 646 | - if( !empty( $attribute_def ) ) { |
|
| 647 | - if( $attribute_def->frontend_input != 'password' ) { |
|
| 646 | + if (!empty($attribute_def)) { |
|
| 647 | + if ($attribute_def->frontend_input != 'password') { |
|
| 648 | 648 | ob_start(); |
| 649 | - require( wpshop_tools::get_template_part( WPS_ACCOUNT_DIR, $this->template_dir,"frontend", "account/account_informations_element") ); |
|
| 649 | + require(wpshop_tools::get_template_part(WPS_ACCOUNT_DIR, $this->template_dir, "frontend", "account/account_informations_element")); |
|
| 650 | 650 | $attribute_details .= ob_get_contents(); |
| 651 | 651 | ob_end_clean(); |
| 652 | 652 | } |
@@ -654,7 +654,7 @@ discard block |
||
| 654 | 654 | } |
| 655 | 655 | |
| 656 | 656 | ob_start(); |
| 657 | - require( wpshop_tools::get_template_part( WPS_ACCOUNT_DIR, $this->template_dir,"frontend", "account/account_informations_group_element") ); |
|
| 657 | + require(wpshop_tools::get_template_part(WPS_ACCOUNT_DIR, $this->template_dir, "frontend", "account/account_informations_group_element")); |
|
| 658 | 658 | $attributes_sections_tpl .= ob_get_contents(); |
| 659 | 659 | ob_end_clean(); |
| 660 | 660 | |
@@ -665,7 +665,7 @@ discard block |
||
| 665 | 665 | } |
| 666 | 666 | } |
| 667 | 667 | ob_start(); |
| 668 | - require_once( wpshop_tools::get_template_part( WPS_ACCOUNT_DIR, $this->template_dir, "frontend", "account/account_informations") ); |
|
| 668 | + require_once(wpshop_tools::get_template_part(WPS_ACCOUNT_DIR, $this->template_dir, "frontend", "account/account_informations")); |
|
| 669 | 669 | $output = ob_get_contents(); |
| 670 | 670 | ob_end_clean(); |
| 671 | 671 | } |
@@ -679,85 +679,85 @@ discard block |
||
| 679 | 679 | function account_informations_form() { |
| 680 | 680 | global $wpdb; |
| 681 | 681 | $output = ''; |
| 682 | - if ( get_current_user_id() != 0 ) { |
|
| 682 | + if (get_current_user_id() != 0) { |
|
| 683 | 683 | // Customer ID data |
| 684 | - $customer_entity_type_id = wpshop_entities::get_entity_identifier_from_code( WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS ); |
|
| 685 | - $query = $wpdb->prepare( 'SELECT ID FROM ' .$wpdb->posts. ' WHERE post_type = %s AND post_author = %d', WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, get_current_user_id() ); |
|
| 686 | - $cid = $wpdb->get_var( $query ); |
|
| 684 | + $customer_entity_type_id = wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS); |
|
| 685 | + $query = $wpdb->prepare('SELECT ID FROM ' . $wpdb->posts . ' WHERE post_type = %s AND post_author = %d', WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, get_current_user_id()); |
|
| 686 | + $cid = $wpdb->get_var($query); |
|
| 687 | 687 | |
| 688 | 688 | $fields_to_output = $signup_fields = array(); |
| 689 | 689 | |
| 690 | - $password_attribute = $signup_form_attributes = array(); |
|
| 690 | + $password_attribute = $signup_form_attributes = array(); |
|
| 691 | 691 | |
| 692 | - $entity_id = wpshop_entities::get_entity_identifier_from_code( WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS ); |
|
| 692 | + $entity_id = wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS); |
|
| 693 | 693 | |
| 694 | - $query = $wpdb->prepare('SELECT id FROM '.WPSHOP_DBT_ATTRIBUTE_SET.' WHERE entity_id = %d', $entity_id); |
|
| 695 | - $customer_entity_id = $wpdb->get_var( $query ); |
|
| 694 | + $query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE entity_id = %d', $entity_id); |
|
| 695 | + $customer_entity_id = $wpdb->get_var($query); |
|
| 696 | 696 | $attributes_set = wpshop_attributes_set::getElement($customer_entity_id); |
| 697 | - $account_attributes = wpshop_attributes_set::getAttributeSetDetails( ( !empty($attributes_set->id) ) ? $attributes_set->id : '', "'valid'"); |
|
| 698 | - $query = $wpdb->prepare('SELECT id FROM '.WPSHOP_DBT_ATTRIBUTE_GROUP.' WHERE attribute_set_id = %d', $attributes_set->id ); |
|
| 699 | - $customer_attributes_sections = $wpdb->get_results( $query ); |
|
| 700 | - foreach( $customer_attributes_sections as $k => $customer_attributes_section ) { |
|
| 701 | - if ( !empty( $account_attributes[$customer_attributes_section->id] ) ) { |
|
| 702 | - foreach( $account_attributes[$customer_attributes_section->id]['attribut'] as $attribute ) { |
|
| 697 | + $account_attributes = wpshop_attributes_set::getAttributeSetDetails((!empty($attributes_set->id)) ? $attributes_set->id : '', "'valid'"); |
|
| 698 | + $query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE_GROUP . ' WHERE attribute_set_id = %d', $attributes_set->id); |
|
| 699 | + $customer_attributes_sections = $wpdb->get_results($query); |
|
| 700 | + foreach ($customer_attributes_sections as $k => $customer_attributes_section) { |
|
| 701 | + if (!empty($account_attributes[$customer_attributes_section->id])) { |
|
| 702 | + foreach ($account_attributes[$customer_attributes_section->id]['attribut'] as $attribute) { |
|
| 703 | 703 | $signup_fields[] = $attribute; |
| 704 | 704 | } |
| 705 | 705 | } |
| 706 | 706 | } |
| 707 | 707 | |
| 708 | 708 | ob_start(); |
| 709 | - require( wpshop_tools::get_template_part( WPS_ACCOUNT_DIR, $this->template_dir,"frontend", "account/account_form") ); |
|
| 709 | + require(wpshop_tools::get_template_part(WPS_ACCOUNT_DIR, $this->template_dir, "frontend", "account/account_form")); |
|
| 710 | 710 | $output = ob_get_contents(); |
| 711 | 711 | ob_end_clean(); |
| 712 | 712 | } |
| 713 | 713 | return $output; |
| 714 | 714 | } |
| 715 | 715 | |
| 716 | - function save_account_informations( $cid, $args, $admin = true ) { |
|
| 716 | + function save_account_informations($cid, $args, $admin = true) { |
|
| 717 | 717 | global $wpdb, $wpshop; |
| 718 | 718 | |
| 719 | - $exclude_user_meta = array( 'user_email', 'user_pass' ); |
|
| 719 | + $exclude_user_meta = array('user_email', 'user_pass'); |
|
| 720 | 720 | $wps_entities = new wpshop_entities(); |
| 721 | - $element_id = $wps_entities->get_entity_identifier_from_code( WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS ); |
|
| 721 | + $element_id = $wps_entities->get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS); |
|
| 722 | 722 | |
| 723 | - $query = $wpdb->prepare( 'SELECT post_author FROM ' .$wpdb->posts. ' WHERE post_type = %s AND ID = %d', WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, $cid ); |
|
| 724 | - $user_id = $wpdb->get_var( $query ); |
|
| 723 | + $query = $wpdb->prepare('SELECT post_author FROM ' . $wpdb->posts . ' WHERE post_type = %s AND ID = %d', WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, $cid); |
|
| 724 | + $user_id = $wpdb->get_var($query); |
|
| 725 | 725 | |
| 726 | 726 | $user_name = !empty($args['attribute']['varchar']['user_login']) ? $args['attribute']['varchar']['user_login'] : $args['attribute']['varchar']['user_email']; |
| 727 | 727 | $user_pass = !empty($args['attribute']['varchar']['user_pass']) ? $args['attribute']['varchar']['user_pass'] : ''; |
| 728 | 728 | |
| 729 | - $query = $wpdb->prepare('SELECT id FROM ' .WPSHOP_DBT_ATTRIBUTE_SET. ' WHERE entity_id = %d', $element_id ); |
|
| 730 | - $attribute_set_id = $wpdb->get_var( $query ); |
|
| 731 | - if ( !empty($attribute_set_id) ) { |
|
| 732 | - $group = wps_address::get_addresss_form_fields_by_type( $attribute_set_id ); |
|
| 729 | + $query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE entity_id = %d', $element_id); |
|
| 730 | + $attribute_set_id = $wpdb->get_var($query); |
|
| 731 | + if (!empty($attribute_set_id)) { |
|
| 732 | + $group = wps_address::get_addresss_form_fields_by_type($attribute_set_id); |
|
| 733 | 733 | //Save data in attribute tables, ckeck first if exist to know if Insert or Update |
| 734 | - wpshop_attributes::saveAttributeForEntity( $args['attribute'], $element_id, $cid ); |
|
| 735 | - foreach ( $group as $attribute_sets ) { |
|
| 736 | - foreach ( $attribute_sets as $attribute_set_field ) { |
|
| 737 | - if( $admin ) { |
|
| 738 | - $validate = $wpshop->validateForm($attribute_set_field['content'], $args['attribute'] ); |
|
| 734 | + wpshop_attributes::saveAttributeForEntity($args['attribute'], $element_id, $cid); |
|
| 735 | + foreach ($group as $attribute_sets) { |
|
| 736 | + foreach ($attribute_sets as $attribute_set_field) { |
|
| 737 | + if ($admin) { |
|
| 738 | + $validate = $wpshop->validateForm($attribute_set_field['content'], $args['attribute']); |
|
| 739 | 739 | } |
| 740 | - if ( empty($wpshop->errors) || !$admin ) { |
|
| 740 | + if (empty($wpshop->errors) || !$admin) { |
|
| 741 | 741 | $wpshop_attributes = new wpshop_attributes(); |
| 742 | - foreach( $attribute_set_field['content'] as $attribute ) { |
|
| 743 | - $attribute_def = wpshop_attributes::getElement( $attribute['name'], "'valid'", 'code'); |
|
| 744 | - if ( !in_array( $attribute['name'], $exclude_user_meta ) ) { |
|
| 745 | - update_user_meta( $user_id, $attribute['name'], wpshop_tools::varSanitizer( $args['attribute'][$attribute['data_type']][$attribute['name']]) ); |
|
| 742 | + foreach ($attribute_set_field['content'] as $attribute) { |
|
| 743 | + $attribute_def = wpshop_attributes::getElement($attribute['name'], "'valid'", 'code'); |
|
| 744 | + if (!in_array($attribute['name'], $exclude_user_meta)) { |
|
| 745 | + update_user_meta($user_id, $attribute['name'], wpshop_tools::varSanitizer($args['attribute'][$attribute['data_type']][$attribute['name']])); |
|
| 746 | 746 | } |
| 747 | 747 | else { |
| 748 | - wp_update_user( array('ID' => $user_id, $attribute['name'] => wpshop_tools::varSanitizer( $args['attribute'][$attribute['data_type']][$attribute['name']]) ) ); |
|
| 748 | + wp_update_user(array('ID' => $user_id, $attribute['name'] => wpshop_tools::varSanitizer($args['attribute'][$attribute['data_type']][$attribute['name']]))); |
|
| 749 | 749 | } |
| 750 | 750 | } |
| 751 | 751 | |
| 752 | 752 | /** Update newsletter user preferences **/ |
| 753 | 753 | $newsletter_preferences = array(); |
| 754 | - if( !empty($args['newsletters_site']) ) { |
|
| 754 | + if (!empty($args['newsletters_site'])) { |
|
| 755 | 755 | $newsletter_preferences['newsletters_site'] = 1; |
| 756 | 756 | } |
| 757 | - if( !empty($args['newsletters_site_partners']) ) { |
|
| 757 | + if (!empty($args['newsletters_site_partners'])) { |
|
| 758 | 758 | $newsletter_preferences['newsletters_site_partners'] = 1; |
| 759 | 759 | } |
| 760 | - update_user_meta( $user_id, 'user_preferences', $newsletter_preferences); |
|
| 760 | + update_user_meta($user_id, 'user_preferences', $newsletter_preferences); |
|
| 761 | 761 | } else { |
| 762 | 762 | return $wpshop->errors; |
| 763 | 763 | } |
@@ -769,22 +769,22 @@ discard block |
||
| 769 | 769 | /** |
| 770 | 770 | * ACCOUNT - Save account informations |
| 771 | 771 | */ |
| 772 | - function wps_save_account_informations () { |
|
| 773 | - check_ajax_referer( 'wps_save_account_informations' ); |
|
| 772 | + function wps_save_account_informations() { |
|
| 773 | + check_ajax_referer('wps_save_account_informations'); |
|
| 774 | 774 | |
| 775 | 775 | global $wpdb; |
| 776 | 776 | $status = false; $response = ''; |
| 777 | 777 | |
| 778 | 778 | $user_id = get_current_user_id(); |
| 779 | - if ( !empty($user_id) ) { |
|
| 780 | - $query = $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type = %s AND post_author = %d", WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, $user_id ); |
|
| 781 | - $cid = $wpdb->get_var( $query ); |
|
| 779 | + if (!empty($user_id)) { |
|
| 780 | + $query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type = %s AND post_author = %d", WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, $user_id); |
|
| 781 | + $cid = $wpdb->get_var($query); |
|
| 782 | 782 | } |
| 783 | 783 | |
| 784 | - $errors = $this->save_account_informations( $cid, $_POST ); |
|
| 785 | - if( !empty( $errors ) ) { |
|
| 786 | - $response = '<div class="wps-alert-error">' .__('Some errors have been detected', 'wpshop') . ' : <ul>'; |
|
| 787 | - foreach( $errors as $error ){ |
|
| 784 | + $errors = $this->save_account_informations($cid, $_POST); |
|
| 785 | + if (!empty($errors)) { |
|
| 786 | + $response = '<div class="wps-alert-error">' . __('Some errors have been detected', 'wpshop') . ' : <ul>'; |
|
| 787 | + foreach ($errors as $error) { |
|
| 788 | 788 | $response .= '<li>' . $error . '</li>'; |
| 789 | 789 | } |
| 790 | 790 | $response .= '</div>'; |
@@ -793,7 +793,7 @@ discard block |
||
| 793 | 793 | $status = true; |
| 794 | 794 | } |
| 795 | 795 | |
| 796 | - wp_die( json_encode( array( 'status' => $status, 'response' => $response) ) ); |
|
| 796 | + wp_die(json_encode(array('status' => $status, 'response' => $response))); |
|
| 797 | 797 | } |
| 798 | 798 | |
| 799 | 799 | /** |
@@ -804,23 +804,23 @@ discard block |
||
| 804 | 804 | |
| 805 | 805 | $status = false; |
| 806 | 806 | $response = do_shortcode('[wps_account_informations]'); |
| 807 | - if( !empty($response) ) { |
|
| 807 | + if (!empty($response)) { |
|
| 808 | 808 | $status = true; |
| 809 | 809 | } |
| 810 | 810 | |
| 811 | - wp_die( json_encode( array( 'status' => $status, 'response' => $response ) ) ); |
|
| 811 | + wp_die(json_encode(array('status' => $status, 'response' => $response))); |
|
| 812 | 812 | } |
| 813 | 813 | |
| 814 | 814 | /** |
| 815 | 815 | * ACCOUNT - AJAX - Fill account informations modal |
| 816 | 816 | */ |
| 817 | 817 | function wps_fill_account_informations_modal() { |
| 818 | - check_ajax_referer( 'wps_fill_account_informations_modal' ); |
|
| 818 | + check_ajax_referer('wps_fill_account_informations_modal'); |
|
| 819 | 819 | |
| 820 | 820 | $title = $content = ''; |
| 821 | 821 | $title = __('Edit your account informations', 'wpshop'); |
| 822 | - $content = do_shortcode( '[wps_account_informations_form]' ); |
|
| 823 | - echo json_encode( array( 'status' => true, 'title' => $title, 'content' => $content) ); |
|
| 822 | + $content = do_shortcode('[wps_account_informations_form]'); |
|
| 823 | + echo json_encode(array('status' => true, 'title' => $title, 'content' => $content)); |
|
| 824 | 824 | wp_die(); |
| 825 | 825 | } |
| 826 | 826 | |
@@ -1,4 +1,6 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
| 2 | + exit; |
|
| 3 | +} |
|
| 2 | 4 | class wps_account_ctr { |
| 3 | 5 | /** Define the main directory containing the template for the current plugin |
| 4 | 6 | * @var string |
@@ -81,15 +83,13 @@ discard block |
||
| 81 | 83 | $args = array(); |
| 82 | 84 | if ( get_current_user_id() != 0 ) { |
| 83 | 85 | return __( 'You are already logged', 'wpshop'); |
| 84 | - } |
|
| 85 | - else { |
|
| 86 | + } else { |
|
| 86 | 87 | $action = !empty( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ''; |
| 87 | 88 | $key = !empty( $_GET['key'] ) ? sanitize_text_field( $_GET['key'] ) : ''; |
| 88 | 89 | $login = !empty( $_GET['login'] ) ? sanitize_text_field( $_GET['login'] ) : 0; |
| 89 | 90 | if ( !empty($action) && $action == 'retrieve_password' && !empty($key) && !empty($login) && !$force_login ) { |
| 90 | 91 | $output = self::get_renew_password_form(); |
| 91 | - } |
|
| 92 | - else { |
|
| 92 | + } else { |
|
| 93 | 93 | ob_start(); |
| 94 | 94 | require_once( wpshop_tools::get_template_part( WPS_ACCOUNT_DIR, $this->template_dir, "frontend", "login/login-form") ); |
| 95 | 95 | $output = ob_get_contents(); |
@@ -107,8 +107,9 @@ discard block |
||
| 107 | 107 | |
| 108 | 108 | $_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : ''; |
| 109 | 109 | |
| 110 | - if ( !wp_verify_nonce( $_wpnonce, 'control_login_form_request' ) ) |
|
| 111 | - wp_die(); |
|
| 110 | + if ( !wp_verify_nonce( $_wpnonce, 'control_login_form_request' ) ) { |
|
| 111 | + wp_die(); |
|
| 112 | + } |
|
| 112 | 113 | |
| 113 | 114 | $result = ''; |
| 114 | 115 | $status = false; |
@@ -122,8 +123,7 @@ discard block |
||
| 122 | 123 | $user_checking = get_user_by( 'login', $wps_login_user_login ); |
| 123 | 124 | if( !empty($user_checking) ) { |
| 124 | 125 | $creds['user_login'] = $wps_login_user_login; |
| 125 | - } |
|
| 126 | - else { |
|
| 126 | + } else { |
|
| 127 | 127 | if ( is_email($wps_login_user_login) ) { |
| 128 | 128 | $user_checking = get_user_by( 'email', $wps_login_user_login ); |
| 129 | 129 | $creds['user_login'] = $user_checking->user_login; |
@@ -134,20 +134,17 @@ discard block |
||
| 134 | 134 | $user = wp_signon( $creds, false ); |
| 135 | 135 | if ( is_wp_error($user) ) { |
| 136 | 136 | $result = '<div class="wps-alert-error">' .__('Connexion error', 'wpshop'). '</div>'; |
| 137 | - } |
|
| 138 | - else { |
|
| 137 | + } else { |
|
| 139 | 138 | $permalink_option = get_option( 'permalink_structure' ); |
| 140 | 139 | $checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) ); |
| 141 | 140 | if( $origin == $page_account_id ) { |
| 142 | 141 | $result = get_permalink( $page_account_id ); |
| 143 | - } |
|
| 144 | - else { |
|
| 142 | + } else { |
|
| 145 | 143 | $result = get_permalink( $checkout_page_id ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step=3'; |
| 146 | 144 | } |
| 147 | 145 | $status = true; |
| 148 | 146 | } |
| 149 | - } |
|
| 150 | - else { |
|
| 147 | + } else { |
|
| 151 | 148 | $result = '<div class="wps-alert-error">' .__('E-Mail and Password are required', 'wpshop'). '</div>'; |
| 152 | 149 | } |
| 153 | 150 | |
@@ -161,8 +158,9 @@ discard block |
||
| 161 | 158 | function wps_ajax_get_login_form_interface() { |
| 162 | 159 | $_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : ''; |
| 163 | 160 | |
| 164 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_ajax_get_login_form_interface' ) ) |
|
| 165 | - wp_die(); |
|
| 161 | + if ( !wp_verify_nonce( $_wpnonce, 'wps_ajax_get_login_form_interface' ) ) { |
|
| 162 | + wp_die(); |
|
| 163 | + } |
|
| 166 | 164 | |
| 167 | 165 | $response = array( 'status' => true, 'response' => self::get_login_form() ); |
| 168 | 166 | echo json_encode( $response ); |
@@ -185,8 +183,9 @@ discard block |
||
| 185 | 183 | function wps_login_first_request() { |
| 186 | 184 | $_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : ''; |
| 187 | 185 | |
| 188 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_login_first_request' ) ) |
|
| 189 | - wp_die(); |
|
| 186 | + if ( !wp_verify_nonce( $_wpnonce, 'wps_login_first_request' ) ) { |
|
| 187 | + wp_die(); |
|
| 188 | + } |
|
| 190 | 189 | |
| 191 | 190 | $status = false; $login_action = false; $response = ''; |
| 192 | 191 | $user_email = ( !empty($_POST['email_address']) ) ? wpshop_tools::varSanitizer( $_POST['email_address'] ) : null; |
@@ -198,8 +197,7 @@ discard block |
||
| 198 | 197 | $login_action = true; |
| 199 | 198 | $user_firstname = get_user_meta( $checking_user->ID, 'first_name', true ); |
| 200 | 199 | $response = $user_firstname; |
| 201 | - } |
|
| 202 | - else { |
|
| 200 | + } else { |
|
| 203 | 201 | $checking_user = get_user_by( 'email', $user_email); |
| 204 | 202 | if ( !empty( $checking_user ) ) { |
| 205 | 203 | $login_action = true; |
@@ -211,8 +209,7 @@ discard block |
||
| 211 | 209 | if( !$login_action && is_email($user_email) ) { |
| 212 | 210 | $response = $user_email; |
| 213 | 211 | } |
| 214 | - } |
|
| 215 | - else { |
|
| 212 | + } else { |
|
| 216 | 213 | $response = '<div class="wps-alert-error">' .__( 'An e-mail address is required', 'wpshop' ). '</div>'; |
| 217 | 214 | } |
| 218 | 215 | echo json_encode( array( 'status'=> $status, 'response' => $response, 'login_action' => $login_action) ); |
@@ -239,8 +236,9 @@ discard block |
||
| 239 | 236 | function wps_fill_forgot_password_modal() { |
| 240 | 237 | $_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : ''; |
| 241 | 238 | |
| 242 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_fill_forgot_password_modal' ) ) |
|
| 243 | - wp_die(); |
|
| 239 | + if ( !wp_verify_nonce( $_wpnonce, 'wps_fill_forgot_password_modal' ) ) { |
|
| 240 | + wp_die(); |
|
| 241 | + } |
|
| 244 | 242 | |
| 245 | 243 | $status = false; $title = $content = ''; |
| 246 | 244 | $title = __( 'Forgot password', 'wpshop' ); |
@@ -256,8 +254,9 @@ discard block |
||
| 256 | 254 | function wps_forgot_password_request() { |
| 257 | 255 | $_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : ''; |
| 258 | 256 | |
| 259 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_forgot_password_request' ) ) |
|
| 260 | - wp_die(); |
|
| 257 | + if ( !wp_verify_nonce( $_wpnonce, 'wps_forgot_password_request' ) ) { |
|
| 258 | + wp_die(); |
|
| 259 | + } |
|
| 261 | 260 | |
| 262 | 261 | global $wpdb; |
| 263 | 262 | $status = false; $result = ''; |
@@ -268,8 +267,7 @@ discard block |
||
| 268 | 267 | $exist_user = get_user_by('login', $user_login); |
| 269 | 268 | if( !empty($exist_user) ) { |
| 270 | 269 | $existing_user = true; |
| 271 | - } |
|
| 272 | - else { |
|
| 270 | + } else { |
|
| 273 | 271 | $exist_user = get_user_by('email', $user_login); |
| 274 | 272 | $key_for_update = 'user_email'; |
| 275 | 273 | if ( !empty($exist_user) ) { |
@@ -286,12 +284,10 @@ discard block |
||
| 286 | 284 | $this->send_forgot_password_email($key, $user_login, $exist_user); |
| 287 | 285 | $result = '<div class="wps-alert-info">' .__('An e-mail with an password renew link has been sent to you', 'wpshop'). '</div>'; |
| 288 | 286 | $status = true; |
| 289 | - } |
|
| 290 | - else { |
|
| 287 | + } else { |
|
| 291 | 288 | $result = '<div class="wps-alert-error">' .__('No customer account corresponds to this email', 'wpshop'). '</div>'; |
| 292 | 289 | } |
| 293 | - } |
|
| 294 | - else { |
|
| 290 | + } else { |
|
| 295 | 291 | $result = '<div class="wps-alert-error">' .__('Please fill the required field', 'wpshop'). '</div>'; |
| 296 | 292 | } |
| 297 | 293 | $response = array( $status, $result ); |
@@ -336,8 +332,7 @@ discard block |
||
| 336 | 332 | $user = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->users WHERE user_activation_key = %s AND user_login = %s", $activation_key, $login ) ); |
| 337 | 333 | if( !empty($user) ) { |
| 338 | 334 | $existing_user = true; |
| 339 | - } |
|
| 340 | - else { |
|
| 335 | + } else { |
|
| 341 | 336 | $user = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->users WHERE user_activation_key = %s AND user_email = %s", $activation_key, $login ) ); |
| 342 | 337 | if( !empty($user) ) { |
| 343 | 338 | $existing_user = true; |
@@ -350,16 +345,13 @@ discard block |
||
| 350 | 345 | $status = true; |
| 351 | 346 | $result = '<div class="wps-alert-success">' .__('Your password has been updated', 'wpshop'). '. <a href="#" id="display_connexion_form"> ' .__('Connect you', 'wpshop').' !</a></div>'; |
| 352 | 347 | $form = self::get_login_form( true ); |
| 353 | - } |
|
| 354 | - else { |
|
| 348 | + } else { |
|
| 355 | 349 | $result = '<div class=" wps-alert-error">' .__('Invalid activation key', 'wpshop'). '</div>'; |
| 356 | 350 | } |
| 357 | - } |
|
| 358 | - else { |
|
| 351 | + } else { |
|
| 359 | 352 | $result = '<div class=" wps-alert-error">' .__('Invalid activation key', 'wpshop'). '</div>'; |
| 360 | 353 | } |
| 361 | - } |
|
| 362 | - else { |
|
| 354 | + } else { |
|
| 363 | 355 | $result = '<div class="wps-alert-error">' .__('Password and confirmation password are differents', 'wpshop'). '</div>'; |
| 364 | 356 | } |
| 365 | 357 | |
@@ -431,8 +423,9 @@ discard block |
||
| 431 | 423 | function wps_save_signup_form( $connect = false ) { |
| 432 | 424 | $_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : ''; |
| 433 | 425 | |
| 434 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_save_signup_form' ) ) |
|
| 435 | - wp_die(); |
|
| 426 | + if ( !wp_verify_nonce( $_wpnonce, 'wps_save_signup_form' ) ) { |
|
| 427 | + wp_die(); |
|
| 428 | + } |
|
| 436 | 429 | |
| 437 | 430 | global $wpdb, $wpshop; |
| 438 | 431 | $user_id = ( !empty( $_POST['wps_sign_up_request_from_admin'] ) ) ? (int) $_POST['wps_sign_up_request_from_admin'] : get_current_user_id(); |
@@ -518,8 +511,7 @@ discard block |
||
| 518 | 511 | $permalink_option = get_option( 'permalink_structure' ); |
| 519 | 512 | $checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' )); |
| 520 | 513 | $result = get_permalink( $checkout_page_id ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step=3'; |
| 521 | - } |
|
| 522 | - else { |
|
| 514 | + } else { |
|
| 523 | 515 | $account_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_myaccount_page_id' )); |
| 524 | 516 | $result = get_permalink( $account_page_id ); |
| 525 | 517 | } |
@@ -636,8 +628,7 @@ discard block |
||
| 636 | 628 | if ( $attribute_def->data_type_to_use == 'custom' ) { |
| 637 | 629 | $query = $wpdb->prepare("SELECT label FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . " WHERE attribute_id = %d AND status = 'valid' AND id = %d", $attribute_def->id, $attribute_value ); |
| 638 | 630 | $attribute_value = $wpdb->get_var( $query ); |
| 639 | - } |
|
| 640 | - else if ( $attribute_def->data_type_to_use == 'internal') { |
|
| 631 | + } else if ( $attribute_def->data_type_to_use == 'internal') { |
|
| 641 | 632 | $associated_post = get_post( $atribute_value ); |
| 642 | 633 | $attribute_value = $associated_post->post_title; |
| 643 | 634 | } |
@@ -743,8 +734,7 @@ discard block |
||
| 743 | 734 | $attribute_def = wpshop_attributes::getElement( $attribute['name'], "'valid'", 'code'); |
| 744 | 735 | if ( !in_array( $attribute['name'], $exclude_user_meta ) ) { |
| 745 | 736 | update_user_meta( $user_id, $attribute['name'], wpshop_tools::varSanitizer( $args['attribute'][$attribute['data_type']][$attribute['name']]) ); |
| 746 | - } |
|
| 747 | - else { |
|
| 737 | + } else { |
|
| 748 | 738 | wp_update_user( array('ID' => $user_id, $attribute['name'] => wpshop_tools::varSanitizer( $args['attribute'][$attribute['data_type']][$attribute['name']]) ) ); |
| 749 | 739 | } |
| 750 | 740 | } |
@@ -788,8 +778,7 @@ discard block |
||
| 788 | 778 | $response .= '<li>' . $error . '</li>'; |
| 789 | 779 | } |
| 790 | 780 | $response .= '</div>'; |
| 791 | - } |
|
| 792 | - else { |
|
| 781 | + } else { |
|
| 793 | 782 | $status = true; |
| 794 | 783 | } |
| 795 | 784 | |
@@ -77,6 +77,12 @@ |
||
| 77 | 77 | } |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | + /** |
|
| 81 | + * @param string $page_title |
|
| 82 | + * @param string $menu_title |
|
| 83 | + * @param string $menu_slug |
|
| 84 | + * @param string[] $callback |
|
| 85 | + */ |
|
| 80 | 86 | public function set_submenu_page_help( $page_title, $menu_title, $menu_slug, $callback ) { |
| 81 | 87 | $this->sub_menus[$menu_slug] = array( |
| 82 | 88 | 'page_title' => $page_title |
@@ -20,8 +20,8 @@ |
||
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
| 23 | - * Appelle le template dans wps_installer backend about / Call the template in wps_installer backend about |
|
| 24 | - */ |
|
| 23 | + * Appelle le template dans wps_installer backend about / Call the template in wps_installer backend about |
|
| 24 | + */ |
|
| 25 | 25 | public function render_menu() { |
| 26 | 26 | require_once( wpshop_tools::get_template_part( WPS_INSTALLER_DIR, WPSINSTALLER_TPL_DIR, "backend", "about" ) ); |
| 27 | 27 | } |
@@ -1,20 +1,20 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) exit; |
|
| 2 | 2 | class wps_help_menus_ctr { |
| 3 | 3 | public $sub_menus; |
| 4 | 4 | |
| 5 | 5 | public function __construct() { |
| 6 | - $this->set_submenu_page_help( __( 'Shortcodes', 'wpshop' ), __( 'Shortcodes', 'wpshop' ), WPSHOP_URL_SLUG_SHORTCODES, array( 'wpshop_display', 'display_page' ) ); |
|
| 6 | + $this->set_submenu_page_help(__('Shortcodes', 'wpshop'), __('Shortcodes', 'wpshop'), WPSHOP_URL_SLUG_SHORTCODES, array('wpshop_display', 'display_page')); |
|
| 7 | 7 | |
| 8 | - add_action( 'admin_menu', array( $this, 'admin_menu' ) ); |
|
| 9 | - add_action( 'menu_order', array( $this, 'admin_menu_order' ), 12 ); |
|
| 10 | - add_action( 'custom_menu_order', array( $this, 'admin_custom_menu_order' ) ); |
|
| 8 | + add_action('admin_menu', array($this, 'admin_menu')); |
|
| 9 | + add_action('menu_order', array($this, 'admin_menu_order'), 12); |
|
| 10 | + add_action('custom_menu_order', array($this, 'admin_custom_menu_order')); |
|
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | 14 | * Ajout du menu pour le logiciel de caisse dans le backend / Create a new administration menu into backend |
| 15 | 15 | */ |
| 16 | 16 | public function admin_menu() { |
| 17 | - add_menu_page( __( 'Help', 'wpshop' ), __( 'Help', 'wpshop' ), 'wpshop_view_dashboard', WPSHOP_URL_SLUG_ABOUT, array($this, 'render_menu'), 'dashicons-editor-help' ); |
|
| 17 | + add_menu_page(__('Help', 'wpshop'), __('Help', 'wpshop'), 'wpshop_view_dashboard', WPSHOP_URL_SLUG_ABOUT, array($this, 'render_menu'), 'dashicons-editor-help'); |
|
| 18 | 18 | |
| 19 | 19 | $this->create_submenu_page_help(); |
| 20 | 20 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | * Appelle le template dans wps_installer backend about / Call the template in wps_installer backend about |
| 24 | 24 | */ |
| 25 | 25 | public function render_menu() { |
| 26 | - require_once( wpshop_tools::get_template_part( WPS_INSTALLER_DIR, WPSINSTALLER_TPL_DIR, "backend", "about" ) ); |
|
| 26 | + require_once(wpshop_tools::get_template_part(WPS_INSTALLER_DIR, WPSINSTALLER_TPL_DIR, "backend", "about")); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | /** |
@@ -33,19 +33,19 @@ discard block |
||
| 33 | 33 | * |
| 34 | 34 | * @return array The new admin menu order with the POS addon placed |
| 35 | 35 | */ |
| 36 | - public function admin_menu_order( $current_menu_order ) { |
|
| 36 | + public function admin_menu_order($current_menu_order) { |
|
| 37 | 37 | /** Create a new menu order */ |
| 38 | 38 | $wps_pos_menu_ordered = array(); |
| 39 | 39 | |
| 40 | 40 | /** Read the current existing menu order for rearrange it */ |
| 41 | - foreach ( $current_menu_order as $menu_item ) { |
|
| 42 | - if ( 'edit.php?post_type=wps_highlighting' == $menu_item ) { |
|
| 41 | + foreach ($current_menu_order as $menu_item) { |
|
| 42 | + if ('edit.php?post_type=wps_highlighting' == $menu_item) { |
|
| 43 | 43 | $wps_pos_menu_ordered[] = 'edit.php?post_type=wps_highlighting'; |
| 44 | 44 | $wps_pos_menu_ordered[] = WPSHOP_URL_SLUG_ABOUT; |
| 45 | 45 | |
| 46 | - unset( $current_menu_order[ array_search( WPSHOP_URL_SLUG_ABOUT, $current_menu_order ) ] ); |
|
| 46 | + unset($current_menu_order[array_search(WPSHOP_URL_SLUG_ABOUT, $current_menu_order)]); |
|
| 47 | 47 | } |
| 48 | - else if ( WPSHOP_URL_SLUG_ABOUT != $menu_item ) { |
|
| 48 | + else if (WPSHOP_URL_SLUG_ABOUT != $menu_item) { |
|
| 49 | 49 | $wps_pos_menu_ordered[] = $menu_item; |
| 50 | 50 | } |
| 51 | 51 | } |
@@ -59,12 +59,12 @@ discard block |
||
| 59 | 59 | * @return boolean A boolean var defining if we apply admin menu reorder for current user |
| 60 | 60 | */ |
| 61 | 61 | public function admin_custom_menu_order() { |
| 62 | - return current_user_can( 'manage_options' ); |
|
| 62 | + return current_user_can('manage_options'); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | public function create_submenu_page_help() { |
| 66 | - if( is_array( $this->sub_menus ) ) { |
|
| 67 | - foreach ( $this->sub_menus as $slug => $data ) |
|
| 66 | + if (is_array($this->sub_menus)) { |
|
| 67 | + foreach ($this->sub_menus as $slug => $data) |
|
| 68 | 68 | { |
| 69 | 69 | add_submenu_page( |
| 70 | 70 | WPSHOP_URL_SLUG_ABOUT |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | } |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - public function set_submenu_page_help( $page_title, $menu_title, $menu_slug, $callback ) { |
|
| 80 | + public function set_submenu_page_help($page_title, $menu_title, $menu_slug, $callback) { |
|
| 81 | 81 | $this->sub_menus[$menu_slug] = array( |
| 82 | 82 | 'page_title' => $page_title |
| 83 | 83 | ,'menu_title' => $menu_title |
@@ -1,4 +1,6 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
| 2 | + exit; |
|
| 3 | +} |
|
| 2 | 4 | class wps_help_menus_ctr { |
| 3 | 5 | public $sub_menus; |
| 4 | 6 | |
@@ -44,8 +46,7 @@ discard block |
||
| 44 | 46 | $wps_pos_menu_ordered[] = WPSHOP_URL_SLUG_ABOUT; |
| 45 | 47 | |
| 46 | 48 | unset( $current_menu_order[ array_search( WPSHOP_URL_SLUG_ABOUT, $current_menu_order ) ] ); |
| 47 | - } |
|
| 48 | - else if ( WPSHOP_URL_SLUG_ABOUT != $menu_item ) { |
|
| 49 | + } else if ( WPSHOP_URL_SLUG_ABOUT != $menu_item ) { |
|
| 49 | 50 | $wps_pos_menu_ordered[] = $menu_item; |
| 50 | 51 | } |
| 51 | 52 | } |
@@ -81,7 +81,7 @@ |
||
| 81 | 81 | * Save the current state of installation process |
| 82 | 82 | * |
| 83 | 83 | * @param string $setted_state A parameter setted for saving the state of installation ( in progress, completed, ignored ) |
| 84 | - * @param array $current_db_version The current value for database version option |
|
| 84 | + * @param string $current_db_version The current value for database version option |
|
| 85 | 85 | */ |
| 86 | 86 | function installer_state_saver( $setted_state, $current_db_version ) { |
| 87 | 87 | $current_db_version['installation_state'] = $setted_state; |
@@ -1,4 +1,6 @@ |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
| 2 | + exit; |
|
| 3 | +} |
|
| 2 | 4 | /** |
| 3 | 5 | * Module controller class definition file |
| 4 | 6 | * |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) exit; |
|
| 2 | 2 | /** |
| 3 | 3 | * Module controller class definition file |
| 4 | 4 | * |
@@ -28,34 +28,34 @@ discard block |
||
| 28 | 28 | * |
| 29 | 29 | * @param integer $the_step_to_save The current step to save |
| 30 | 30 | */ |
| 31 | - function save_step( $the_step_to_save ) { |
|
| 31 | + function save_step($the_step_to_save) { |
|
| 32 | 32 | |
| 33 | - switch ( $the_step_to_save ) { |
|
| 33 | + switch ($the_step_to_save) { |
|
| 34 | 34 | case 1: |
| 35 | 35 | /** Save company informations */ |
| 36 | - $wpshop_company_info = !empty( $_POST['wpshop_company_info'] ) ? sanitize_text_field( $_POST['wpshop_company_info'] ) : ''; |
|
| 37 | - if ( !empty( $wpshop_company_info ) ) { |
|
| 38 | - update_option( 'wpshop_company_info', $wpshop_company_info ); |
|
| 36 | + $wpshop_company_info = !empty($_POST['wpshop_company_info']) ? sanitize_text_field($_POST['wpshop_company_info']) : ''; |
|
| 37 | + if (!empty($wpshop_company_info)) { |
|
| 38 | + update_option('wpshop_company_info', $wpshop_company_info); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** Save the company logo in case a file is sended */ |
| 42 | - $shop_logo = !empty( $_POST['wpshop_logo'] ) ? sanitize_text_field( $_POST['wpshop_logo'] ) : ''; |
|
| 43 | - if ( !empty( $shop_logo ) ) { |
|
| 44 | - update_option( 'wpshop_logo', $shop_logo ); |
|
| 42 | + $shop_logo = !empty($_POST['wpshop_logo']) ? sanitize_text_field($_POST['wpshop_logo']) : ''; |
|
| 43 | + if (!empty($shop_logo)) { |
|
| 44 | + update_option('wpshop_logo', $shop_logo); |
|
| 45 | 45 | } |
| 46 | 46 | break; |
| 47 | 47 | |
| 48 | 48 | case 2: |
| 49 | 49 | /** Save shop type */ |
| 50 | - $wpshop_shop_type = !empty( $_POST['wpshop_shop_type'] ) ? sanitize_text_field( $_POST[ 'wpshop_shop_type' ] ) : ''; |
|
| 51 | - if ( !empty( $wpshop_shop_type ) ) { |
|
| 52 | - update_option( 'wpshop_shop_type', $wpshop_shop_type ); |
|
| 50 | + $wpshop_shop_type = !empty($_POST['wpshop_shop_type']) ? sanitize_text_field($_POST['wpshop_shop_type']) : ''; |
|
| 51 | + if (!empty($wpshop_shop_type)) { |
|
| 52 | + update_option('wpshop_shop_type', $wpshop_shop_type); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | /** Save shop price piloting */ |
| 56 | - $wpshop_shop_price_piloting = !empty( $_POST[ 'wpshop_shop_price_piloting' ] ) ? sanitize_text_field( $_POST[ 'wpshop_shop_price_piloting' ] ) : ''; |
|
| 57 | - if ( !empty( $wpshop_shop_price_piloting ) ) { |
|
| 58 | - update_option( 'wpshop_shop_price_piloting', $wpshop_shop_price_piloting ); |
|
| 56 | + $wpshop_shop_price_piloting = !empty($_POST['wpshop_shop_price_piloting']) ? sanitize_text_field($_POST['wpshop_shop_price_piloting']) : ''; |
|
| 57 | + if (!empty($wpshop_shop_price_piloting)) { |
|
| 58 | + update_option('wpshop_shop_price_piloting', $wpshop_shop_price_piloting); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | /** Insert default pages */ |
@@ -63,21 +63,21 @@ discard block |
||
| 63 | 63 | //add_action( 'init', array( 'wps_message_ctr', 'create_default_message' ) ); |
| 64 | 64 | |
| 65 | 65 | /** In case the user want to insert default datas */ |
| 66 | - $wps_installer_data_insertion = !empty( $_POST[ 'wps-installer-data-insertion' ] ) ? sanitize_text_field( $_POST[ 'wps-installer-data-insertion' ] ) : ''; |
|
| 67 | - if ( !empty( $wps_installer_data_insertion ) && ( 'yes' == $wps_installer_data_insertion ) ) { |
|
| 66 | + $wps_installer_data_insertion = !empty($_POST['wps-installer-data-insertion']) ? sanitize_text_field($_POST['wps-installer-data-insertion']) : ''; |
|
| 67 | + if (!empty($wps_installer_data_insertion) && ('yes' == $wps_installer_data_insertion)) { |
|
| 68 | 68 | /** Insert sample datas */ |
| 69 | - add_action( 'init', array( 'wpshop_install', 'import_sample_datas' ) ); |
|
| 69 | + add_action('init', array('wpshop_install', 'import_sample_datas')); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - $wps_current_db_version = get_option( 'wpshop_db_options', 0 ); |
|
| 73 | - $wps_current_db_version[ 'installation_state' ] = 'completed'; |
|
| 74 | - $wps_current_db_version[ 'installation_date' ] = current_time( 'mysql', 0 ); |
|
| 75 | - update_option( 'wpshop_db_options', $wps_current_db_version ); |
|
| 72 | + $wps_current_db_version = get_option('wpshop_db_options', 0); |
|
| 73 | + $wps_current_db_version['installation_state'] = 'completed'; |
|
| 74 | + $wps_current_db_version['installation_date'] = current_time('mysql', 0); |
|
| 75 | + update_option('wpshop_db_options', $wps_current_db_version); |
|
| 76 | 76 | break; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - if ( !empty( $the_step_to_save ) ) { |
|
| 80 | - update_option( 'wps-installation-current-step', ( WPSINSTALLER_STEPS_COUNT != $the_step_to_save ? $the_step_to_save + 1 : WPSINSTALLER_STEPS_COUNT ) ); |
|
| 79 | + if (!empty($the_step_to_save)) { |
|
| 80 | + update_option('wps-installation-current-step', (WPSINSTALLER_STEPS_COUNT != $the_step_to_save ? $the_step_to_save + 1 : WPSINSTALLER_STEPS_COUNT)); |
|
| 81 | 81 | } |
| 82 | 82 | } |
| 83 | 83 | |
@@ -87,16 +87,16 @@ discard block |
||
| 87 | 87 | * @param string $setted_state A parameter setted for saving the state of installation ( in progress, completed, ignored ) |
| 88 | 88 | * @param array $current_db_version The current value for database version option |
| 89 | 89 | */ |
| 90 | - function installer_state_saver( $setted_state, $current_db_version ) { |
|
| 90 | + function installer_state_saver($setted_state, $current_db_version) { |
|
| 91 | 91 | $current_db_version['installation_state'] = $setted_state; |
| 92 | - $current_db_version[ 'installation_date' ] = current_time( 'mysql', 0 ); |
|
| 92 | + $current_db_version['installation_date'] = current_time('mysql', 0); |
|
| 93 | 93 | update_option('wpshop_db_options', $current_db_version); |
| 94 | 94 | |
| 95 | - if ( "ignored" == $current_db_version['installation_state'] ) { |
|
| 95 | + if ("ignored" == $current_db_version['installation_state']) { |
|
| 96 | 96 | /** Create the different pages */ |
| 97 | - if ( 2 >= get_option( 'wps-installation-current-step' ) ) { |
|
| 98 | - update_option( 'wpshop_shop_price_piloting', 'TTC' ); |
|
| 99 | - update_option( 'wpshop_shop_type', WPSHOP_DEFAULT_SHOP_TYPE ); |
|
| 97 | + if (2 >= get_option('wps-installation-current-step')) { |
|
| 98 | + update_option('wpshop_shop_price_piloting', 'TTC'); |
|
| 99 | + update_option('wpshop_shop_type', WPSHOP_DEFAULT_SHOP_TYPE); |
|
| 100 | 100 | |
| 101 | 101 | /** Insert default pages */ |
| 102 | 102 | //add_action( 'init', array( 'wpshop_install', 'wpshop_insert_default_pages' ) ); |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | /** Save the crrent step to 4 in order to consider that installation is done */ |
| 108 | - update_option( 'wps-installation-current-step', WPSINSTALLER_STEPS_COUNT ); |
|
| 108 | + update_option('wps-installation-current-step', WPSINSTALLER_STEPS_COUNT); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | return $current_db_version; |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | /** |
| 71 | 71 | * Get product Complete Sheet |
| 72 | 72 | * @param integer $pid |
| 73 | - * @return Ambigous <string, string> |
|
| 73 | + * @return string <string, string> |
|
| 74 | 74 | */ |
| 75 | 75 | public static function get_product_complete_sheet_galery( $pid ) { |
| 76 | 76 | $output = ''; |
@@ -157,6 +157,9 @@ discard block |
||
| 157 | 157 | return $output; |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | + /** |
|
| 161 | + * @param integer $product_id |
|
| 162 | + */ |
|
| 160 | 163 | public static function get_product_complete_sheet_attachments( $product_id ) { |
| 161 | 164 | $output = ''; |
| 162 | 165 | |
@@ -1,15 +1,15 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) exit; |
|
| 2 | 2 | class wps_media_manager_frontend_ctr { |
| 3 | 3 | |
| 4 | - public static function get_attachments( $pid, $type = 'gallery' ) { |
|
| 4 | + public static function get_attachments($pid, $type = 'gallery') { |
|
| 5 | 5 | $attachments = array(); |
| 6 | - $media_id_data = get_post_meta( $pid, '_wps_product_media', true ); |
|
| 7 | - if( !empty($media_id_data) ) { |
|
| 8 | - $media_id = explode( ',', $media_id_data ); |
|
| 9 | - foreach($media_id as $id) { |
|
| 10 | - if( ( ( wp_attachment_is_image( $id ) && $type == 'gallery' ) || ( !empty( $id ) && !wp_attachment_is_image( $id ) && $type == 'attachments' ) ) ) { |
|
| 11 | - $attachment_data = get_post( $id ); |
|
| 12 | - if( !empty( $attachment_data ) && !empty($attachment_data->ID) ) { |
|
| 6 | + $media_id_data = get_post_meta($pid, '_wps_product_media', true); |
|
| 7 | + if (!empty($media_id_data)) { |
|
| 8 | + $media_id = explode(',', $media_id_data); |
|
| 9 | + foreach ($media_id as $id) { |
|
| 10 | + if (((wp_attachment_is_image($id) && $type == 'gallery') || (!empty($id) && !wp_attachment_is_image($id) && $type == 'attachments'))) { |
|
| 11 | + $attachment_data = get_post($id); |
|
| 12 | + if (!empty($attachment_data) && !empty($attachment_data->ID)) { |
|
| 13 | 13 | $attachments[] = $attachment_data; |
| 14 | 14 | } |
| 15 | 15 | } |
@@ -26,13 +26,13 @@ discard block |
||
| 26 | 26 | * |
| 27 | 27 | * @return string The attachement gallery output |
| 28 | 28 | */ |
| 29 | - public static function display_attachment_gallery( $attachement_type, $content ) { |
|
| 29 | + public static function display_attachment_gallery($attachement_type, $content) { |
|
| 30 | 30 | $galery_output = ''; |
| 31 | 31 | |
| 32 | 32 | /* |
| 33 | 33 | * Get the template part for given galery type |
| 34 | 34 | */ |
| 35 | - switch ( $attachement_type ) { |
|
| 35 | + switch ($attachement_type) { |
|
| 36 | 36 | case 'picture': |
| 37 | 37 | $template_part = 'product_attachment_picture_galery'; |
| 38 | 38 | break; |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | * Build template |
| 53 | 53 | */ |
| 54 | 54 | $tpl_way_to_take = wpshop_display::check_way_for_template($template_part); |
| 55 | - if ( $tpl_way_to_take[0] && !empty($tpl_way_to_take[1]) ) { |
|
| 55 | + if ($tpl_way_to_take[0] && !empty($tpl_way_to_take[1])) { |
|
| 56 | 56 | /* Include the old way template part */ |
| 57 | 57 | ob_start(); |
| 58 | 58 | require(wpshop_display::get_template_file($tpl_way_to_take[1])); |
@@ -72,81 +72,81 @@ discard block |
||
| 72 | 72 | * @param integer $pid |
| 73 | 73 | * @return Ambigous <string, string> |
| 74 | 74 | */ |
| 75 | - public static function get_product_complete_sheet_galery( $pid ) { |
|
| 75 | + public static function get_product_complete_sheet_galery($pid) { |
|
| 76 | 76 | $output = ''; |
| 77 | - if( !empty($pid) ) { |
|
| 77 | + if (!empty($pid)) { |
|
| 78 | 78 | $tpl_component = $sub_tpl_component = array(); |
| 79 | 79 | $attachments = array(); |
| 80 | 80 | $tpl_component['THUMBNAILS'] = ''; |
| 81 | 81 | $tpl_component['SLIDER_CONTENT'] = ''; |
| 82 | 82 | |
| 83 | 83 | /** Check and get the product thumbnail */ |
| 84 | - $principal_thumbnail_id = get_post_meta( $pid, '_thumbnail_id', true); |
|
| 85 | - if( !empty($principal_thumbnail_id) ) { |
|
| 86 | - $attachments[0] = get_post( $principal_thumbnail_id ); |
|
| 84 | + $principal_thumbnail_id = get_post_meta($pid, '_thumbnail_id', true); |
|
| 85 | + if (!empty($principal_thumbnail_id)) { |
|
| 86 | + $attachments[0] = get_post($principal_thumbnail_id); |
|
| 87 | 87 | } |
| 88 | 88 | else { |
| 89 | 89 | $sub_tpl_component['THUMBNAIL_GALLERY_THUMBNAIL'] = ''; |
| 90 | - $sub_tpl_component['IMAGE_SLIDER_FULL'] = '<img src="' .WPSHOP_DEFAULT_PRODUCT_PICTURE. '" alt="" />'; |
|
| 91 | - $sub_tpl_component['THUMBNAIL_GALLERY_FULL'] = '<img src="' .WPSHOP_DEFAULT_PRODUCT_PICTURE. '" alt="" />'; |
|
| 90 | + $sub_tpl_component['IMAGE_SLIDER_FULL'] = '<img src="' . WPSHOP_DEFAULT_PRODUCT_PICTURE . '" alt="" />'; |
|
| 91 | + $sub_tpl_component['THUMBNAIL_GALLERY_FULL'] = '<img src="' . WPSHOP_DEFAULT_PRODUCT_PICTURE . '" alt="" />'; |
|
| 92 | 92 | $sub_tpl_component['THUMBNAIL_GALLERY_THUMBNAIL_ID'] = ''; |
| 93 | 93 | |
| 94 | - $tpl_component[ 'SLIDER_CONTENT' ] .= wpshop_display::display_template_element( 'wps_product_complete_sheet_gallery_slider_element', $sub_tpl_component ); |
|
| 95 | - $tpl_component[ 'THUMBNAILS' ] = ''; |
|
| 94 | + $tpl_component['SLIDER_CONTENT'] .= wpshop_display::display_template_element('wps_product_complete_sheet_gallery_slider_element', $sub_tpl_component); |
|
| 95 | + $tpl_component['THUMBNAILS'] = ''; |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** Get product associated pictures */ |
| 99 | 99 | $allowed_mime_type = get_allowed_mime_types(); |
| 100 | 100 | |
| 101 | - $attachments = array_merge( $attachments, (array)self::get_attachments( $pid ) ); |
|
| 101 | + $attachments = array_merge($attachments, (array)self::get_attachments($pid)); |
|
| 102 | 102 | |
| 103 | 103 | /** In case there are picture read and display them into product sheet */ |
| 104 | - if ( !empty($attachments) ) { |
|
| 105 | - foreach( $attachments as $attachment) { |
|
| 106 | - if( !empty($attachment) && !empty($attachment->post_mime_type) && in_array( $attachment->post_mime_type, $allowed_mime_type ) ) { |
|
| 104 | + if (!empty($attachments)) { |
|
| 105 | + foreach ($attachments as $attachment) { |
|
| 106 | + if (!empty($attachment) && !empty($attachment->post_mime_type) && in_array($attachment->post_mime_type, $allowed_mime_type)) { |
|
| 107 | 107 | //IMAGE SLIDER |
| 108 | - $image_attributes = wp_get_attachment_metadata( $attachment->ID ); |
|
| 108 | + $image_attributes = wp_get_attachment_metadata($attachment->ID); |
|
| 109 | 109 | $sub_tpl_component['THUMBNAIL_GALLERY_THUMBNAIL'] = ''; |
| 110 | 110 | $sub_tpl_component['THUMBNAIL_GALLERY_THUMBNAIL_ID'] = $attachment->ID; |
| 111 | - if ( !empty($image_attributes) && !empty($image_attributes['sizes']) && is_array($image_attributes['sizes']) ) { |
|
| 112 | - foreach ( $image_attributes['sizes'] as $size_name => $size_def) { |
|
| 113 | - $p = wp_get_attachment_image( $attachment->ID, $size_name); |
|
| 114 | - $src = wp_get_attachment_image_src( $attachment->ID, $size_name ); |
|
| 111 | + if (!empty($image_attributes) && !empty($image_attributes['sizes']) && is_array($image_attributes['sizes'])) { |
|
| 112 | + foreach ($image_attributes['sizes'] as $size_name => $size_def) { |
|
| 113 | + $p = wp_get_attachment_image($attachment->ID, $size_name); |
|
| 114 | + $src = wp_get_attachment_image_src($attachment->ID, $size_name); |
|
| 115 | 115 | $sub_tpl_component['THUMBNAIL_GALLERY_' . strtoupper($size_name)] = ''; |
| 116 | 116 | $sub_tpl_component['IMAGE_SLIDER_' . strtoupper($size_name)] = ''; |
| 117 | - if( !empty($p) ) { |
|
| 118 | - $sub_tpl_component['SRC_IMAGE_SLIDER_' . strtoupper($size_name)] = ( !empty($src) ) ? $src[0] : ''; |
|
| 119 | - $sub_tpl_component['IMAGE_SLIDER_' . strtoupper($size_name)] = ( !empty( $p ) ) ? $p : '<img src="' .WPSHOP_DEFAULT_PRODUCT_PICTURE. '" alt="" />'; |
|
| 120 | - $sub_tpl_component['THUMBNAIL_GALLERY_' . strtoupper($size_name)] = ( !empty( $p ) ) ? $p : '<img src="' .WPSHOP_DEFAULT_PRODUCT_PICTURE. '" alt="" />'; |
|
| 117 | + if (!empty($p)) { |
|
| 118 | + $sub_tpl_component['SRC_IMAGE_SLIDER_' . strtoupper($size_name)] = (!empty($src)) ? $src[0] : ''; |
|
| 119 | + $sub_tpl_component['IMAGE_SLIDER_' . strtoupper($size_name)] = (!empty($p)) ? $p : '<img src="' . WPSHOP_DEFAULT_PRODUCT_PICTURE . '" alt="" />'; |
|
| 120 | + $sub_tpl_component['THUMBNAIL_GALLERY_' . strtoupper($size_name)] = (!empty($p)) ? $p : '<img src="' . WPSHOP_DEFAULT_PRODUCT_PICTURE . '" alt="" />'; |
|
| 121 | 121 | } |
| 122 | 122 | } |
| 123 | - $p = wp_get_attachment_image( $attachment->ID, 'full'); |
|
| 124 | - $src = wp_get_attachment_image_src( $attachment->ID, 'full' ); |
|
| 125 | - if( !empty($p) ) { |
|
| 126 | - $sub_tpl_component['SRC_IMAGE_SLIDER_FULL'] = ( !empty($src) ) ? $src[0] : ''; |
|
| 127 | - $sub_tpl_component['IMAGE_SLIDER_FULL'] = ( !empty($p) ) ? $p : ''; |
|
| 128 | - $sub_tpl_component['THUMBNAIL_GALLERY_FULL'] = ( !empty($p) ) ? $p : ''; |
|
| 123 | + $p = wp_get_attachment_image($attachment->ID, 'full'); |
|
| 124 | + $src = wp_get_attachment_image_src($attachment->ID, 'full'); |
|
| 125 | + if (!empty($p)) { |
|
| 126 | + $sub_tpl_component['SRC_IMAGE_SLIDER_FULL'] = (!empty($src)) ? $src[0] : ''; |
|
| 127 | + $sub_tpl_component['IMAGE_SLIDER_FULL'] = (!empty($p)) ? $p : ''; |
|
| 128 | + $sub_tpl_component['THUMBNAIL_GALLERY_FULL'] = (!empty($p)) ? $p : ''; |
|
| 129 | 129 | } |
| 130 | 130 | } |
| 131 | 131 | else { |
| 132 | - $p = wp_get_attachment_image( $attachment->ID, 'full' ); |
|
| 133 | - $src = wp_get_attachment_image_src( $attachment->ID, 'full' ); |
|
| 134 | - $sub_tpl_component['SRC_IMAGE_SLIDER_FULL'] = ( !empty($src) ) ? $src[0] : ''; |
|
| 135 | - $sub_tpl_component['IMAGE_SLIDER_FULL'] = ( !empty( $p ) ) ? $p : '<img src="' .WPSHOP_DEFAULT_PRODUCT_PICTURE. '" alt="" />'; |
|
| 136 | - $sub_tpl_component['THUMBNAIL_GALLERY_FULL'] = ( !empty( $p ) ) ? $p : '<img src="' .WPSHOP_DEFAULT_PRODUCT_PICTURE. '" alt="" />'; |
|
| 132 | + $p = wp_get_attachment_image($attachment->ID, 'full'); |
|
| 133 | + $src = wp_get_attachment_image_src($attachment->ID, 'full'); |
|
| 134 | + $sub_tpl_component['SRC_IMAGE_SLIDER_FULL'] = (!empty($src)) ? $src[0] : ''; |
|
| 135 | + $sub_tpl_component['IMAGE_SLIDER_FULL'] = (!empty($p)) ? $p : '<img src="' . WPSHOP_DEFAULT_PRODUCT_PICTURE . '" alt="" />'; |
|
| 136 | + $sub_tpl_component['THUMBNAIL_GALLERY_FULL'] = (!empty($p)) ? $p : '<img src="' . WPSHOP_DEFAULT_PRODUCT_PICTURE . '" alt="" />'; |
|
| 137 | 137 | } |
| 138 | - if ( !empty( $sub_tpl_component['IMAGE_SLIDER_FULL'] ) ) { |
|
| 139 | - $tpl_component[ 'SLIDER_CONTENT' ] .= wpshop_display::display_template_element( 'wps_product_complete_sheet_gallery_slider_element', $sub_tpl_component ); |
|
| 140 | - if ( ( 1 < count( $attachments ) ) || ( ( 1 == count( $attachments ) ) && empty( $principal_thumbnail_id ) ) ) { |
|
| 141 | - $tpl_component[ 'THUMBNAILS' ] .= wpshop_display::display_template_element( 'wps_product_complete_sheet_gallery_thumbnail_element', $sub_tpl_component ); |
|
| 138 | + if (!empty($sub_tpl_component['IMAGE_SLIDER_FULL'])) { |
|
| 139 | + $tpl_component['SLIDER_CONTENT'] .= wpshop_display::display_template_element('wps_product_complete_sheet_gallery_slider_element', $sub_tpl_component); |
|
| 140 | + if ((1 < count($attachments)) || ((1 == count($attachments)) && empty($principal_thumbnail_id))) { |
|
| 141 | + $tpl_component['THUMBNAILS'] .= wpshop_display::display_template_element('wps_product_complete_sheet_gallery_thumbnail_element', $sub_tpl_component); |
|
| 142 | 142 | } |
| 143 | 143 | } |
| 144 | - unset( $sub_tpl_component ); |
|
| 144 | + unset($sub_tpl_component); |
|
| 145 | 145 | } |
| 146 | 146 | else { |
| 147 | 147 | $sub_tpl_component['SRC_IMAGE_SLIDER_FULL'] = ''; |
| 148 | - $sub_tpl_component['IMAGE_SLIDER_FULL'] = '<img src="' .WPSHOP_DEFAULT_PRODUCT_PICTURE. '" alt="" />'; |
|
| 149 | - $sub_tpl_component['THUMBNAIL_GALLERY_FULL'] = '<img src="' .WPSHOP_DEFAULT_PRODUCT_PICTURE. '" alt="" />'; |
|
| 148 | + $sub_tpl_component['IMAGE_SLIDER_FULL'] = '<img src="' . WPSHOP_DEFAULT_PRODUCT_PICTURE . '" alt="" />'; |
|
| 149 | + $sub_tpl_component['THUMBNAIL_GALLERY_FULL'] = '<img src="' . WPSHOP_DEFAULT_PRODUCT_PICTURE . '" alt="" />'; |
|
| 150 | 150 | } |
| 151 | 151 | } |
| 152 | 152 | } |
@@ -157,35 +157,35 @@ discard block |
||
| 157 | 157 | return $output; |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | - public static function get_product_complete_sheet_attachments( $product_id ) { |
|
| 160 | + public static function get_product_complete_sheet_attachments($product_id) { |
|
| 161 | 161 | $output = ''; |
| 162 | 162 | |
| 163 | 163 | /** Get attachement file for the current product */ |
| 164 | 164 | $product_picture_galery_content = $product_document_galery_content = ''; |
| 165 | 165 | $picture_number = $document_number = $index_li = 0; |
| 166 | 166 | |
| 167 | - $attachments = self::get_attachments( $product_id, 'attachments' ); |
|
| 167 | + $attachments = self::get_attachments($product_id, 'attachments'); |
|
| 168 | 168 | |
| 169 | - if ( is_array($attachments) && (count($attachments) > 0) ) { |
|
| 169 | + if (is_array($attachments) && (count($attachments) > 0)) { |
|
| 170 | 170 | $picture_increment = $document_increment = 1; |
| 171 | 171 | foreach ($attachments as $attachment) { |
| 172 | 172 | $tpl_component = array(); |
| 173 | - $attachment_url = wp_get_attachment_url( $attachment->ID ); |
|
| 173 | + $attachment_url = wp_get_attachment_url($attachment->ID); |
|
| 174 | 174 | $attachment_extension = explode('.', $attachment_url); |
| 175 | 175 | $attachment_extension = $attachment_extension[1]; |
| 176 | 176 | $tpl_component['ATTACHMENT_ITEM_GUID'] = $attachment_url; |
| 177 | 177 | $tpl_component['ATTACHMENT_ITEM_TITLE'] = $attachment->post_title; |
| 178 | 178 | $tpl_component['ATTACHMENT_ITEM_EXTENSION'] = $attachment_extension; |
| 179 | - if(is_int(strpos($attachment->post_mime_type, 'application/')) || is_int(strpos($attachment->post_mime_type, 'text/'))) { |
|
| 179 | + if (is_int(strpos($attachment->post_mime_type, 'application/')) || is_int(strpos($attachment->post_mime_type, 'text/'))) { |
|
| 180 | 180 | $tpl_component['ATTACHMENT_ITEM_TYPE'] = 'document'; |
| 181 | - $tpl_component['ATTACHMENT_ITEM_SPECIFIC_CLASS'] = (!($document_increment%WPSHOP_DISPLAY_GALLERY_ELEMENT_NUMBER_PER_LINE)) ? 'wpshop_gallery_document_last' : ''; |
|
| 181 | + $tpl_component['ATTACHMENT_ITEM_SPECIFIC_CLASS'] = (!($document_increment % WPSHOP_DISPLAY_GALLERY_ELEMENT_NUMBER_PER_LINE)) ? 'wpshop_gallery_document_last' : ''; |
|
| 182 | 182 | /** Template parameters */ |
| 183 | 183 | $template_part = 'product_attachment_item_document'; |
| 184 | 184 | $tpl_component['PRODUCT_ID'] = $product_id; |
| 185 | 185 | |
| 186 | 186 | /** Build template */ |
| 187 | 187 | $tpl_way_to_take = wpshop_display::check_way_for_template($template_part); |
| 188 | - if ( $tpl_way_to_take[0] && !empty($tpl_way_to_take[1]) ) { |
|
| 188 | + if ($tpl_way_to_take[0] && !empty($tpl_way_to_take[1])) { |
|
| 189 | 189 | /* Include the old way template part */ |
| 190 | 190 | |
| 191 | 191 | ob_start(); |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | ob_start(); |
| 207 | - require( wpshop_tools::get_template_part( WPS_MEDIA_MANAGER_DIR, WPS_MEDIA_MANAGER_TEMPLATE_DIR, 'frontend', 'associated', 'document' ) ); |
|
| 207 | + require(wpshop_tools::get_template_part(WPS_MEDIA_MANAGER_DIR, WPS_MEDIA_MANAGER_TEMPLATE_DIR, 'frontend', 'associated', 'document')); |
|
| 208 | 208 | $output = ob_get_contents(); |
| 209 | 209 | ob_end_clean(); |
| 210 | 210 | } |
@@ -1,4 +1,6 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
| 2 | + exit; |
|
| 3 | +} |
|
| 2 | 4 | class wps_media_manager_frontend_ctr { |
| 3 | 5 | |
| 4 | 6 | public static function get_attachments( $pid, $type = 'gallery' ) { |
@@ -58,8 +60,7 @@ discard block |
||
| 58 | 60 | require(wpshop_display::get_template_file($tpl_way_to_take[1])); |
| 59 | 61 | $galery_output = ob_get_contents(); |
| 60 | 62 | ob_end_clean(); |
| 61 | - } |
|
| 62 | - else { |
|
| 63 | + } else { |
|
| 63 | 64 | $galery_output = wpshop_display::display_template_element($template_part, $tpl_component); |
| 64 | 65 | } |
| 65 | 66 | unset($tpl_component); |
@@ -84,8 +85,7 @@ discard block |
||
| 84 | 85 | $principal_thumbnail_id = get_post_meta( $pid, '_thumbnail_id', true); |
| 85 | 86 | if( !empty($principal_thumbnail_id) ) { |
| 86 | 87 | $attachments[0] = get_post( $principal_thumbnail_id ); |
| 87 | - } |
|
| 88 | - else { |
|
| 88 | + } else { |
|
| 89 | 89 | $sub_tpl_component['THUMBNAIL_GALLERY_THUMBNAIL'] = ''; |
| 90 | 90 | $sub_tpl_component['IMAGE_SLIDER_FULL'] = '<img src="' .WPSHOP_DEFAULT_PRODUCT_PICTURE. '" alt="" />'; |
| 91 | 91 | $sub_tpl_component['THUMBNAIL_GALLERY_FULL'] = '<img src="' .WPSHOP_DEFAULT_PRODUCT_PICTURE. '" alt="" />'; |
@@ -127,8 +127,7 @@ discard block |
||
| 127 | 127 | $sub_tpl_component['IMAGE_SLIDER_FULL'] = ( !empty($p) ) ? $p : ''; |
| 128 | 128 | $sub_tpl_component['THUMBNAIL_GALLERY_FULL'] = ( !empty($p) ) ? $p : ''; |
| 129 | 129 | } |
| 130 | - } |
|
| 131 | - else { |
|
| 130 | + } else { |
|
| 132 | 131 | $p = wp_get_attachment_image( $attachment->ID, 'full' ); |
| 133 | 132 | $src = wp_get_attachment_image_src( $attachment->ID, 'full' ); |
| 134 | 133 | $sub_tpl_component['SRC_IMAGE_SLIDER_FULL'] = ( !empty($src) ) ? $src[0] : ''; |
@@ -142,8 +141,7 @@ discard block |
||
| 142 | 141 | } |
| 143 | 142 | } |
| 144 | 143 | unset( $sub_tpl_component ); |
| 145 | - } |
|
| 146 | - else { |
|
| 144 | + } else { |
|
| 147 | 145 | $sub_tpl_component['SRC_IMAGE_SLIDER_FULL'] = ''; |
| 148 | 146 | $sub_tpl_component['IMAGE_SLIDER_FULL'] = '<img src="' .WPSHOP_DEFAULT_PRODUCT_PICTURE. '" alt="" />'; |
| 149 | 147 | $sub_tpl_component['THUMBNAIL_GALLERY_FULL'] = '<img src="' .WPSHOP_DEFAULT_PRODUCT_PICTURE. '" alt="" />'; |
@@ -192,8 +190,7 @@ discard block |
||
| 192 | 190 | require(wpshop_display::get_template_file($tpl_way_to_take[1])); |
| 193 | 191 | $product_document_galery_content .= ob_get_contents(); |
| 194 | 192 | ob_end_clean(); |
| 195 | - } |
|
| 196 | - else { |
|
| 193 | + } else { |
|
| 197 | 194 | $product_document_galery_content .= wpshop_display::display_template_element($template_part, $tpl_component); |
| 198 | 195 | } |
| 199 | 196 | |