diff --git a/src/wp-admin/includes/class-pclzip.php b/src/wp-admin/includes/class-pclzip.php
index ae0af7a8f1..32fb6b3a36 100644
|
a
|
b
|
class PclZip |
| 199 | 199 | var $error_code = 1; |
| 200 | 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; |
| 206 | | |
| 207 | 202 | // -------------------------------------------------------------------------------- |
| 208 | 203 | // Function : PclZip() |
| 209 | 204 | // Description : |
| … |
… |
function __construct($p_zipname) |
| 224 | 219 | // ----- Set the attributes |
| 225 | 220 | $this->zipname = $p_zipname; |
| 226 | 221 | $this->zip_fd = 0; |
| 227 | | $this->magic_quotes_status = -1; |
| 228 | 222 | |
| 229 | 223 | // ----- Return |
| 230 | 224 | return; |
| … |
… |
function delete() |
| 1041 | 1035 | } |
| 1042 | 1036 | } |
| 1043 | 1037 | |
| 1044 | | // ----- Magic quotes trick |
| 1045 | | $this->privDisableMagicQuotes(); |
| 1046 | 1038 | |
| 1047 | 1039 | // ----- Call the delete fct |
| 1048 | 1040 | $v_list = array(); |
| 1049 | 1041 | if (($v_result = $this->privDeleteByRule($v_list, $v_options)) != 1) { |
| 1050 | | $this->privSwapBackMagicQuotes(); |
| 1051 | 1042 | unset($v_list); |
| 1052 | 1043 | return(0); |
| 1053 | 1044 | } |
| 1054 | 1045 | |
| 1055 | | // ----- Magic quotes trick |
| 1056 | | $this->privSwapBackMagicQuotes(); |
| 1057 | | |
| 1058 | 1046 | // ----- Return |
| 1059 | 1047 | return $v_list; |
| 1060 | 1048 | } |
| … |
… |
function properties() |
| 1096 | 1084 | // ----- Reset the error handler |
| 1097 | 1085 | $this->privErrorReset(); |
| 1098 | 1086 | |
| 1099 | | // ----- Magic quotes trick |
| 1100 | | $this->privDisableMagicQuotes(); |
| 1101 | 1087 | |
| 1102 | 1088 | // ----- Check archive |
| 1103 | 1089 | if (!$this->privCheckFormat()) { |
| 1104 | | $this->privSwapBackMagicQuotes(); |
| 1105 | 1090 | return(0); |
| 1106 | 1091 | } |
| 1107 | 1092 | |
| … |
… |
function properties() |
| 1117 | 1102 | // ----- Open the zip file |
| 1118 | 1103 | if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0) |
| 1119 | 1104 | { |
| 1120 | | $this->privSwapBackMagicQuotes(); |
| 1121 | 1105 | |
| 1122 | 1106 | // ----- Error log |
| 1123 | 1107 | PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode'); |
| … |
… |
function properties() |
| 1130 | 1114 | $v_central_dir = array(); |
| 1131 | 1115 | if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) |
| 1132 | 1116 | { |
| 1133 | | $this->privSwapBackMagicQuotes(); |
| 1134 | 1117 | return 0; |
| 1135 | 1118 | } |
| 1136 | 1119 | |
| … |
… |
function properties() |
| 1143 | 1126 | $v_prop['status'] = 'ok'; |
| 1144 | 1127 | } |
| 1145 | 1128 | |
| 1146 | | // ----- Magic quotes trick |
| 1147 | | $this->privSwapBackMagicQuotes(); |
| 1148 | 1129 | |
| 1149 | 1130 | // ----- Return |
| 1150 | 1131 | return $v_prop; |
| … |
… |
function privCreate($p_filedescr_list, &$p_result_list, &$p_options) |
| 2131 | 2112 | $v_result=1; |
| 2132 | 2113 | $v_list_detail = array(); |
| 2133 | 2114 | |
| 2134 | | // ----- Magic quotes trick |
| 2135 | | $this->privDisableMagicQuotes(); |
| 2136 | 2115 | |
| 2137 | 2116 | // ----- Open the file in write mode |
| 2138 | 2117 | if (($v_result = $this->privOpenFd('wb')) != 1) |
| … |
… |
function privCreate($p_filedescr_list, &$p_result_list, &$p_options) |
| 2147 | 2126 | // ----- Close |
| 2148 | 2127 | $this->privCloseFd(); |
| 2149 | 2128 | |
| 2150 | | // ----- Magic quotes trick |
| 2151 | | $this->privSwapBackMagicQuotes(); |
| 2152 | | |
| 2153 | 2129 | // ----- Return |
| 2154 | 2130 | return $v_result; |
| 2155 | 2131 | } |
| … |
… |
function privAdd($p_filedescr_list, &$p_result_list, &$p_options) |
| 2176 | 2152 | // ----- Return |
| 2177 | 2153 | return $v_result; |
| 2178 | 2154 | } |
| 2179 | | // ----- Magic quotes trick |
| 2180 | | $this->privDisableMagicQuotes(); |
| 2181 | 2155 | |
| 2182 | 2156 | // ----- Open the zip file |
| 2183 | 2157 | if (($v_result=$this->privOpenFd('rb')) != 1) |
| 2184 | 2158 | { |
| 2185 | | // ----- Magic quotes trick |
| 2186 | | $this->privSwapBackMagicQuotes(); |
| 2187 | | |
| 2188 | 2159 | // ----- Return |
| 2189 | 2160 | return $v_result; |
| 2190 | 2161 | } |
| … |
… |
function privAdd($p_filedescr_list, &$p_result_list, &$p_options) |
| 2194 | 2165 | if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) |
| 2195 | 2166 | { |
| 2196 | 2167 | $this->privCloseFd(); |
| 2197 | | $this->privSwapBackMagicQuotes(); |
| 2198 | 2168 | return $v_result; |
| 2199 | 2169 | } |
| 2200 | 2170 | |
| … |
… |
function privAdd($p_filedescr_list, &$p_result_list, &$p_options) |
| 2208 | 2178 | if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0) |
| 2209 | 2179 | { |
| 2210 | 2180 | $this->privCloseFd(); |
| 2211 | | $this->privSwapBackMagicQuotes(); |
| 2212 | 2181 | |
| 2213 | 2182 | PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode'); |
| 2214 | 2183 | |
| … |
… |
function privAdd($p_filedescr_list, &$p_result_list, &$p_options) |
| 2241 | 2210 | fclose($v_zip_temp_fd); |
| 2242 | 2211 | $this->privCloseFd(); |
| 2243 | 2212 | @unlink($v_zip_temp_name); |
| 2244 | | $this->privSwapBackMagicQuotes(); |
| 2245 | 2213 | |
| 2246 | 2214 | // ----- Return |
| 2247 | 2215 | return $v_result; |
| … |
… |
function privAdd($p_filedescr_list, &$p_result_list, &$p_options) |
| 2269 | 2237 | fclose($v_zip_temp_fd); |
| 2270 | 2238 | $this->privCloseFd(); |
| 2271 | 2239 | @unlink($v_zip_temp_name); |
| 2272 | | $this->privSwapBackMagicQuotes(); |
| 2273 | 2240 | |
| 2274 | 2241 | // ----- Return |
| 2275 | 2242 | return $v_result; |
| … |
… |
function privAdd($p_filedescr_list, &$p_result_list, &$p_options) |
| 2301 | 2268 | { |
| 2302 | 2269 | // ----- Reset the file list |
| 2303 | 2270 | unset($v_header_list); |
| 2304 | | $this->privSwapBackMagicQuotes(); |
| 2305 | 2271 | |
| 2306 | 2272 | // ----- Return |
| 2307 | 2273 | return $v_result; |
| … |
… |
function privAdd($p_filedescr_list, &$p_result_list, &$p_options) |
| 2318 | 2284 | // ----- Close the temporary file |
| 2319 | 2285 | @fclose($v_zip_temp_fd); |
| 2320 | 2286 | |
| 2321 | | // ----- Magic quotes trick |
| 2322 | | $this->privSwapBackMagicQuotes(); |
| 2323 | | |
| 2324 | 2287 | // ----- Delete the zip file |
| 2325 | 2288 | // TBC : I should test the result ... |
| 2326 | 2289 | @unlink($this->zipname); |
| … |
… |
function privList(&$p_list) |
| 3153 | 3116 | { |
| 3154 | 3117 | $v_result=1; |
| 3155 | 3118 | |
| 3156 | | // ----- Magic quotes trick |
| 3157 | | $this->privDisableMagicQuotes(); |
| 3158 | 3119 | |
| 3159 | 3120 | // ----- Open the zip file |
| 3160 | 3121 | if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0) |
| 3161 | 3122 | { |
| 3162 | | // ----- Magic quotes trick |
| 3163 | | $this->privSwapBackMagicQuotes(); |
| 3164 | | |
| 3165 | 3123 | // ----- Error log |
| 3166 | 3124 | PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode'); |
| 3167 | 3125 | |
| … |
… |
function privList(&$p_list) |
| 3173 | 3131 | $v_central_dir = array(); |
| 3174 | 3132 | if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) |
| 3175 | 3133 | { |
| 3176 | | $this->privSwapBackMagicQuotes(); |
| 3177 | 3134 | return $v_result; |
| 3178 | 3135 | } |
| 3179 | 3136 | |
| … |
… |
function privList(&$p_list) |
| 3181 | 3138 | @rewind($this->zip_fd); |
| 3182 | 3139 | if (@fseek($this->zip_fd, $v_central_dir['offset'])) |
| 3183 | 3140 | { |
| 3184 | | $this->privSwapBackMagicQuotes(); |
| 3185 | | |
| 3186 | 3141 | // ----- Error log |
| 3187 | 3142 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); |
| 3188 | 3143 | |
| … |
… |
function privList(&$p_list) |
| 3196 | 3151 | // ----- Read the file header |
| 3197 | 3152 | if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1) |
| 3198 | 3153 | { |
| 3199 | | $this->privSwapBackMagicQuotes(); |
| 3200 | 3154 | return $v_result; |
| 3201 | 3155 | } |
| 3202 | 3156 | $v_header['index'] = $i; |
| … |
… |
function privList(&$p_list) |
| 3209 | 3163 | // ----- Close the zip file |
| 3210 | 3164 | $this->privCloseFd(); |
| 3211 | 3165 | |
| 3212 | | // ----- Magic quotes trick |
| 3213 | | $this->privSwapBackMagicQuotes(); |
| 3214 | | |
| 3215 | 3166 | // ----- Return |
| 3216 | 3167 | return $v_result; |
| 3217 | 3168 | } |
| … |
… |
function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all |
| 3279 | 3230 | { |
| 3280 | 3231 | $v_result=1; |
| 3281 | 3232 | |
| 3282 | | // ----- Magic quotes trick |
| 3283 | | $this->privDisableMagicQuotes(); |
| 3284 | | |
| 3285 | 3233 | // ----- Check the path |
| 3286 | 3234 | if ( ($p_path == "") |
| 3287 | 3235 | || ( (substr($p_path, 0, 1) != "/") |
| … |
… |
function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all |
| 3309 | 3257 | // ----- Open the zip file |
| 3310 | 3258 | if (($v_result = $this->privOpenFd('rb')) != 1) |
| 3311 | 3259 | { |
| 3312 | | $this->privSwapBackMagicQuotes(); |
| 3313 | 3260 | return $v_result; |
| 3314 | 3261 | } |
| 3315 | 3262 | |
| … |
… |
function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all |
| 3319 | 3266 | { |
| 3320 | 3267 | // ----- Close the zip file |
| 3321 | 3268 | $this->privCloseFd(); |
| 3322 | | $this->privSwapBackMagicQuotes(); |
| 3323 | 3269 | |
| 3324 | 3270 | return $v_result; |
| 3325 | 3271 | } |
| … |
… |
function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all |
| 3338 | 3284 | { |
| 3339 | 3285 | // ----- Close the zip file |
| 3340 | 3286 | $this->privCloseFd(); |
| 3341 | | $this->privSwapBackMagicQuotes(); |
| 3342 | 3287 | |
| 3343 | 3288 | // ----- Error log |
| 3344 | 3289 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); |
| … |
… |
function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all |
| 3353 | 3298 | { |
| 3354 | 3299 | // ----- Close the zip file |
| 3355 | 3300 | $this->privCloseFd(); |
| 3356 | | $this->privSwapBackMagicQuotes(); |
| 3357 | 3301 | |
| 3358 | 3302 | return $v_result; |
| 3359 | 3303 | } |
| … |
… |
function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all |
| 3446 | 3390 | if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
| 3447 | 3391 | && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { |
| 3448 | 3392 | |
| 3449 | | $this->privSwapBackMagicQuotes(); |
| 3450 | | |
| 3451 | 3393 | PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_COMPRESSION, |
| 3452 | 3394 | "Filename '".$v_header['stored_filename']."' is " |
| 3453 | 3395 | ."compressed by an unsupported compression " |
| … |
… |
function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all |
| 3465 | 3407 | if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
| 3466 | 3408 | && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { |
| 3467 | 3409 | |
| 3468 | | $this->privSwapBackMagicQuotes(); |
| 3469 | | |
| 3470 | 3410 | PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION, |
| 3471 | 3411 | "Unsupported encryption for " |
| 3472 | 3412 | ." filename '".$v_header['stored_filename'] |
| … |
… |
function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all |
| 3482 | 3422 | $p_file_list[$v_nb_extracted++]); |
| 3483 | 3423 | if ($v_result != 1) { |
| 3484 | 3424 | $this->privCloseFd(); |
| 3485 | | $this->privSwapBackMagicQuotes(); |
| 3486 | 3425 | return $v_result; |
| 3487 | 3426 | } |
| 3488 | 3427 | |
| … |
… |
function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all |
| 3500 | 3439 | // ----- Close the zip file |
| 3501 | 3440 | $this->privCloseFd(); |
| 3502 | 3441 | |
| 3503 | | $this->privSwapBackMagicQuotes(); |
| 3504 | | |
| 3505 | 3442 | // ----- Error log |
| 3506 | 3443 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); |
| 3507 | 3444 | |
| … |
… |
function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all |
| 3518 | 3455 | $v_result1 = $this->privExtractFileAsString($v_header, $v_string, $p_options); |
| 3519 | 3456 | if ($v_result1 < 1) { |
| 3520 | 3457 | $this->privCloseFd(); |
| 3521 | | $this->privSwapBackMagicQuotes(); |
| 3522 | 3458 | return $v_result1; |
| 3523 | 3459 | } |
| 3524 | 3460 | |
| … |
… |
function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all |
| 3527 | 3463 | { |
| 3528 | 3464 | // ----- Close the zip file |
| 3529 | 3465 | $this->privCloseFd(); |
| 3530 | | $this->privSwapBackMagicQuotes(); |
| 3531 | 3466 | |
| 3532 | 3467 | return $v_result; |
| 3533 | 3468 | } |
| … |
… |
function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all |
| 3550 | 3485 | $v_result1 = $this->privExtractFileInOutput($v_header, $p_options); |
| 3551 | 3486 | if ($v_result1 < 1) { |
| 3552 | 3487 | $this->privCloseFd(); |
| 3553 | | $this->privSwapBackMagicQuotes(); |
| 3554 | 3488 | return $v_result1; |
| 3555 | 3489 | } |
| 3556 | 3490 | |
| 3557 | 3491 | // ----- Get the only interesting attributes |
| 3558 | 3492 | if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) { |
| 3559 | 3493 | $this->privCloseFd(); |
| 3560 | | $this->privSwapBackMagicQuotes(); |
| 3561 | 3494 | return $v_result; |
| 3562 | 3495 | } |
| 3563 | 3496 | |
| … |
… |
function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all |
| 3575 | 3508 | $p_options); |
| 3576 | 3509 | if ($v_result1 < 1) { |
| 3577 | 3510 | $this->privCloseFd(); |
| 3578 | | $this->privSwapBackMagicQuotes(); |
| 3579 | 3511 | return $v_result1; |
| 3580 | 3512 | } |
| 3581 | 3513 | |
| … |
… |
function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all |
| 3584 | 3516 | { |
| 3585 | 3517 | // ----- Close the zip file |
| 3586 | 3518 | $this->privCloseFd(); |
| 3587 | | $this->privSwapBackMagicQuotes(); |
| 3588 | 3519 | |
| 3589 | 3520 | return $v_result; |
| 3590 | 3521 | } |
| … |
… |
function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all |
| 3599 | 3530 | |
| 3600 | 3531 | // ----- Close the zip file |
| 3601 | 3532 | $this->privCloseFd(); |
| 3602 | | $this->privSwapBackMagicQuotes(); |
| 3603 | 3533 | |
| 3604 | 3534 | // ----- Return |
| 3605 | 3535 | return $v_result; |
| … |
… |
function privErrorReset() |
| 5314 | 5244 | $this->error_string = ''; |
| 5315 | 5245 | } |
| 5316 | 5246 | } |
| 5317 | | // -------------------------------------------------------------------------------- |
| 5318 | | |
| 5319 | | // -------------------------------------------------------------------------------- |
| 5320 | | // Function : privDisableMagicQuotes() |
| 5321 | | // Description : |
| 5322 | | // Parameters : |
| 5323 | | // Return Values : |
| 5324 | | // -------------------------------------------------------------------------------- |
| 5325 | | function privDisableMagicQuotes() |
| 5326 | | { |
| 5327 | | $v_result=1; |
| 5328 | | |
| 5329 | | // ----- Look if function exists |
| 5330 | | if ( (!function_exists("get_magic_quotes_runtime")) |
| 5331 | | || (!function_exists("set_magic_quotes_runtime"))) { |
| 5332 | | return $v_result; |
| 5333 | | } |
| 5334 | | |
| 5335 | | // ----- Look if already done |
| 5336 | | if ($this->magic_quotes_status != -1) { |
| 5337 | | return $v_result; |
| 5338 | | } |
| 5339 | | |
| 5340 | | // ----- Get and memorize the magic_quote value |
| 5341 | | $this->magic_quotes_status = @get_magic_quotes_runtime(); |
| 5342 | | |
| 5343 | | // ----- Disable magic_quotes |
| 5344 | | if ($this->magic_quotes_status == 1) { |
| 5345 | | @set_magic_quotes_runtime(0); |
| 5346 | | } |
| 5347 | | |
| 5348 | | // ----- Return |
| 5349 | | return $v_result; |
| 5350 | | } |
| 5351 | | // -------------------------------------------------------------------------------- |
| 5352 | 5247 | |
| 5353 | | // -------------------------------------------------------------------------------- |
| 5354 | | // Function : privSwapBackMagicQuotes() |
| 5355 | | // Description : |
| 5356 | | // Parameters : |
| 5357 | | // Return Values : |
| 5358 | | // -------------------------------------------------------------------------------- |
| 5359 | | function privSwapBackMagicQuotes() |
| 5360 | | { |
| 5361 | | $v_result=1; |
| 5362 | | |
| 5363 | | // ----- Look if function exists |
| 5364 | | if ( (!function_exists("get_magic_quotes_runtime")) |
| 5365 | | || (!function_exists("set_magic_quotes_runtime"))) { |
| 5366 | | return $v_result; |
| 5367 | | } |
| 5368 | | |
| 5369 | | // ----- Look if something to do |
| 5370 | | if ($this->magic_quotes_status != -1) { |
| 5371 | | return $v_result; |
| 5372 | | } |
| 5373 | | |
| 5374 | | // ----- Swap back magic_quotes |
| 5375 | | if ($this->magic_quotes_status == 1) { |
| 5376 | | @set_magic_quotes_runtime($this->magic_quotes_status); |
| 5377 | | } |
| 5378 | | |
| 5379 | | // ----- Return |
| 5380 | | return $v_result; |
| 5381 | | } |
| 5382 | 5248 | // -------------------------------------------------------------------------------- |
| 5383 | 5249 | |
| 5384 | 5250 | } |