diff --git a/wp-admin/includes/class-pclzip.php b/wp-admin/includes/class-pclzip.php index 7e14695368..5e6a619bc2 100644 --- a/wp-admin/includes/class-pclzip.php +++ b/wp-admin/includes/class-pclzip.php @@ -29,7 +29,7 @@ if (!defined('PCLZIP_READ_BLOCK_SIZE')) { define( 'PCLZIP_READ_BLOCK_SIZE', 2048 ); } - + // ----- File list separator // In version 1.x of PclZip, the separator for file list is a space // (which is not a very smart choice, specifically for windows paths !). @@ -68,7 +68,7 @@ // ----- Optional threshold ratio for use of temporary files // Pclzip sense the size of the file to add/extract and decide to - // use or not temporary file. The algorythm is looking for + // use or not temporary file. The algorythm is looking for // memory_limit of PHP and apply a ratio. // threshold = memory_limit * ratio. // Recommended values are under 0.5. Default 0.47. @@ -152,7 +152,7 @@ define( 'PCLZIP_OPT_ADD_TEMP_FILE_ON', 77021 ); // alias define( 'PCLZIP_OPT_TEMP_FILE_OFF', 77022 ); define( 'PCLZIP_OPT_ADD_TEMP_FILE_OFF', 77022 ); // alias - + // ----- File description attributes define( 'PCLZIP_ATT_FILE_NAME', 79001 ); define( 'PCLZIP_ATT_FILE_NEW_SHORT_NAME', 79002 ); @@ -198,7 +198,7 @@ // ----- Internal error handling var $error_code = 1; var $error_string = ''; - + // ----- Current status of the magic_quotes_runtime // This value store the php configuration for magic_quotes // The class can then disable the magic_quotes and reset it after @@ -332,7 +332,7 @@ } } } - + // ----- Look for default option values $this->privOptionDefaultThreshold($v_options); @@ -341,16 +341,16 @@ $v_att_list = array(); $v_filedescr_list = array(); $p_result_list = array(); - + // ----- Look if the $p_filelist is really an array if (is_array($p_filelist)) { - + // ----- Look if the first element is also an array // This will mean that this is a file description entry if (isset($p_filelist[0]) && is_array($p_filelist[0])) { $v_att_list = $p_filelist; } - + // ----- The list is a list of string names else { $v_string_list = $p_filelist; @@ -368,7 +368,7 @@ PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_filelist"); return 0; } - + // ----- Reformat the string list if (sizeof($v_string_list) != 0) { foreach ($v_string_list as $v_string) { @@ -379,7 +379,7 @@ } } } - + // ----- For each file in the list check the attributes $v_supported_attributes = array ( PCLZIP_ATT_FILE_NAME => 'mandatory' @@ -528,16 +528,16 @@ $v_att_list = array(); $v_filedescr_list = array(); $p_result_list = array(); - + // ----- Look if the $p_filelist is really an array if (is_array($p_filelist)) { - + // ----- Look if the first element is also an array // This will mean that this is a file description entry if (isset($p_filelist[0]) && is_array($p_filelist[0])) { $v_att_list = $p_filelist; } - + // ----- The list is a list of string names else { $v_string_list = $p_filelist; @@ -555,14 +555,14 @@ PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type '".gettype($p_filelist)."' for p_filelist"); return 0; } - + // ----- Reformat the string list if (sizeof($v_string_list) != 0) { foreach ($v_string_list as $v_string) { $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string; } } - + // ----- For each file in the list check the attributes $v_supported_attributes = array ( PCLZIP_ATT_FILE_NAME => 'mandatory' @@ -996,7 +996,7 @@ // Options : // PCLZIP_OPT_BY_INDEX : // PCLZIP_OPT_BY_NAME : - // PCLZIP_OPT_BY_EREG : + // PCLZIP_OPT_BY_EREG : // PCLZIP_OPT_BY_PREG : // Return Values : // 0 on failure, @@ -1064,7 +1064,7 @@ // -------------------------------------------------------------------------------- function deleteByIndex($p_index) { - + $p_list = $this->delete(PCLZIP_OPT_BY_INDEX, $p_index); // ----- Return @@ -1114,7 +1114,7 @@ if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0) { $this->privSwapBackMagicQuotes(); - + // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode'); @@ -1426,7 +1426,7 @@ function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_requested_options=false) { $v_result=1; - + // ----- Read the options $i=0; while ($i<$p_size) { @@ -1466,13 +1466,13 @@ PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); return PclZip::errorCode(); } - + // ----- Check for incompatible options if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) { PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'"); return PclZip::errorCode(); } - + // ----- Check the value $v_value = $p_options_list[$i+1]; if ((!is_integer($v_value)) || ($v_value<0)) { @@ -1491,7 +1491,7 @@ PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'"); return PclZip::errorCode(); } - + $v_result_list[$p_options_list[$i]] = true; break; @@ -1506,7 +1506,7 @@ PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_THRESHOLD'"); return PclZip::errorCode(); } - + $v_result_list[$p_options_list[$i]] = true; break; @@ -1655,7 +1655,7 @@ // ----- Return return PclZip::errorCode(); } - + // ----- Reduce the index list // each index item in the list must be a couple with a start and // an end value : [0,3], [5-5], [8-10], ... @@ -1666,10 +1666,10 @@ // ----- Explode the item $v_item_list = explode("-", $v_work_list[$j]); $v_size_item_list = sizeof($v_item_list); - + // ----- TBC : Here we might check that each item is a // real integer ... - + // ----- Look for single value if ($v_size_item_list == 1) { // ----- Set the option value @@ -1703,7 +1703,7 @@ } $v_sort_value = $v_result_list[$p_options_list[$i]][$j]['start']; } - + // ----- Sort the items if ($v_sort_flag) { // TBC : To Be Completed @@ -1806,10 +1806,10 @@ } } } - + // ----- Look for default values if (!isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) { - + } // ----- Return @@ -1826,17 +1826,17 @@ function privOptionDefaultThreshold(&$p_options) { $v_result=1; - + if (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]) || isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) { return $v_result; } - + // ----- Get 'memory_limit' configuration value $v_memory_limit = ini_get('memory_limit'); $v_memory_limit = trim($v_memory_limit); $last = strtolower(substr($v_memory_limit, -1)); - + if($last == 'g') //$v_memory_limit = $v_memory_limit*1024*1024*1024; $v_memory_limit = $v_memory_limit*1073741824; @@ -1845,15 +1845,15 @@ $v_memory_limit = $v_memory_limit*1048576; if($last == 'k') $v_memory_limit = $v_memory_limit*1024; - + $p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] = floor($v_memory_limit*PCLZIP_TEMPORARY_FILE_RATIO); - + // ----- Sanity check : No threshold if value lower than 1M if ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] < 1048576) { unset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]); } - + // ----- Return return $v_result; } @@ -1870,10 +1870,10 @@ function privFileDescrParseAtt(&$p_file_list, &$p_filedescr, $v_options, $v_requested_options=false) { $v_result=1; - + // ----- For each file in the list check the attributes foreach ($p_file_list as $v_key => $v_value) { - + // ----- Check if the option is supported if (!isset($v_requested_options[$v_key])) { // ----- Error log @@ -1892,7 +1892,7 @@ } $p_filedescr['filename'] = PclZipUtilPathReduction($v_value); - + if ($p_filedescr['filename'] == '') { PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty filename for attribute '".PclZipUtilOptionText($v_key)."'"); return PclZip::errorCode(); @@ -1973,10 +1973,10 @@ } } } - + // end foreach } - + // ----- Return return $v_result; } @@ -1989,7 +1989,7 @@ // or a string to be added as file. For any other type of files (link, other) // just ignore the item. // Then prepare the information that will be stored for that file. - // When its a folder, expand the folder with all the files that are in that + // When its a folder, expand the folder with all the files that are in that // folder (recursively). // Parameters : // Return Values : @@ -1999,20 +1999,20 @@ function privFileDescrExpand(&$p_filedescr_list, &$p_options) { $v_result=1; - + // ----- Create a result list $v_result_list = array(); - + // ----- Look each entry for ($i=0; $iprivCalculateStoredFilename($v_descr, $p_options); - + // ----- Add the descriptor in result list $v_result_list[sizeof($v_result_list)] = $v_descr; - + // ----- Look for folder if ($v_descr['type'] == 'folder') { // ----- List of items in folder @@ -2063,10 +2063,10 @@ if (($v_item_handler == '.') || ($v_item_handler == '..')) { continue; } - + // ----- Compose the full filename $v_dirlist_descr[$v_dirlist_nb]['filename'] = $v_descr['filename'].'/'.$v_item_handler; - + // ----- Look for different stored filename // Because the name of the folder was changed, the name of the // files/sub-folders also change @@ -2079,34 +2079,34 @@ $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_item_handler; } } - + $v_dirlist_nb++; } - + @closedir($v_folder_handler); } else { // TBC : unable to open folder in read mode } - + // ----- Expand each element of the list if ($v_dirlist_nb != 0) { // ----- Expand if (($v_result = $this->privFileDescrExpand($v_dirlist_descr, $p_options)) != 1) { return $v_result; } - + // ----- Concat the resulting list $v_result_list = array_merge($v_result_list, $v_dirlist_descr); } else { } - + // ----- Free local array unset($v_dirlist_descr); } } - + // ----- Get the result list $p_filedescr_list = $v_result_list; @@ -2125,7 +2125,7 @@ { $v_result=1; $v_list_detail = array(); - + // ----- Magic quotes trick $this->privDisableMagicQuotes(); @@ -2455,7 +2455,7 @@ // Function : privAddFileList() // Description : // Parameters : - // $p_filedescr_list : An array containing the file description + // $p_filedescr_list : An array containing the file description // or directory names to add in the zip // $p_result_list : list of added files with their properties (specially the status field) // Return Values : @@ -2473,7 +2473,7 @@ // ----- Format the filename $p_filedescr_list[$j]['filename'] = PclZipUtilTranslateWinPath($p_filedescr_list[$j]['filename'], false); - + // ----- Skip empty file names // TBC : Can this be possible ? not checked in DescrParseAtt ? @@ -2525,7 +2525,7 @@ function privAddFile($p_filedescr, &$p_header, &$p_options) { $v_result=1; - + // ----- Working variable $p_filename = $p_filedescr['filename']; @@ -2537,8 +2537,8 @@ // ----- Return return PclZip::errorCode(); } - - // ----- Look for a stored different filename + + // ----- Look for a stored different filename /* TBC : Removed if (isset($p_filedescr['stored_filename'])) { $v_stored_filename = $p_filedescr['stored_filename']; @@ -2573,20 +2573,20 @@ $p_header['external'] = 0x00000000; $p_header['size'] = filesize($p_filename); } - + // ----- Look for regular folder else if ($p_filedescr['type']=='folder') { $p_header['external'] = 0x00000010; $p_header['mtime'] = filemtime($p_filename); $p_header['size'] = filesize($p_filename); } - + // ----- Look for virtual file else if ($p_filedescr['type'] == 'virtual_file') { $p_header['external'] = 0x00000000; $p_header['size'] = strlen($p_filedescr['content']); } - + // ----- Look for filetime if (isset($p_filedescr['mtime'])) { @@ -2637,7 +2637,7 @@ if ($p_header['stored_filename'] == "") { $p_header['status'] = "filtered"; } - + // ----- Check the path length if (strlen($p_header['stored_filename']) > 0xFF) { $p_header['status'] = 'filename_too_long'; @@ -2649,7 +2649,7 @@ // ----- Look for a file if ($p_filedescr['type'] == 'file') { // ----- Look for using temporary file to zip - if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) + if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON]) || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]) && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_header['size'])) ) ) { @@ -2658,7 +2658,7 @@ return $v_result; } } - + // ----- Use "in memory" zip algo else { @@ -2676,14 +2676,14 @@ // ----- Calculate the CRC $p_header['crc'] = @crc32($v_content); - + // ----- Look for no compression if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) { // ----- Set header parameters $p_header['compressed_size'] = $p_header['size']; $p_header['compression'] = 0; } - + // ----- Look for normal compression else { // ----- Compress the content @@ -2693,7 +2693,7 @@ $p_header['compressed_size'] = strlen($v_content); $p_header['compression'] = 8; } - + // ----- Call the header generation if (($v_result = $this->privWriteFileHeader($p_header)) != 1) { @fclose($v_file); @@ -2709,19 +2709,19 @@ // ----- Look for a virtual file (a file from string) else if ($p_filedescr['type'] == 'virtual_file') { - + $v_content = $p_filedescr['content']; // ----- Calculate the CRC $p_header['crc'] = @crc32($v_content); - + // ----- Look for no compression if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) { // ----- Set header parameters $p_header['compressed_size'] = $p_header['size']; $p_header['compression'] = 0; } - + // ----- Look for normal compression else { // ----- Compress the content @@ -2731,7 +2731,7 @@ $p_header['compressed_size'] = strlen($v_content); $p_header['compression'] = 8; } - + // ----- Call the header generation if (($v_result = $this->privWriteFileHeader($p_header)) != 1) { @fclose($v_file); @@ -2796,7 +2796,7 @@ function privAddFileUsingTempFile($p_filedescr, &$p_header, &$p_options) { $v_result=PCLZIP_ERR_NO_ERROR; - + // ----- Working variable $p_filename = $p_filedescr['filename']; @@ -2891,7 +2891,7 @@ // ----- Unlink the temporary file @unlink($v_gzip_temp_name); - + // ----- Return return $v_result; } @@ -2908,7 +2908,7 @@ function privCalculateStoredFilename(&$p_filedescr, &$p_options) { $v_result=1; - + // ----- Working variables $p_filename = $p_filedescr['filename']; if (isset($p_options[PCLZIP_OPT_ADD_PATH])) { @@ -2936,7 +2936,7 @@ // ----- Remove drive letter if any $v_stored_filename = PclZipUtilTranslateWinPath($p_filedescr['new_full_name']); } - + // ----- Look for path and/or short name change else { @@ -2966,7 +2966,7 @@ if ( (substr($p_filename, 0, 2) == "./") || (substr($p_remove_dir, 0, 2) == "./")) { - + if ( (substr($p_filename, 0, 2) == "./") && (substr($p_remove_dir, 0, 2) != "./")) { $p_remove_dir = "./".$p_remove_dir; @@ -2989,10 +2989,10 @@ } } } - + // ----- Remove drive letter if any $v_stored_filename = PclZipUtilTranslateWinPath($v_stored_filename); - + // ----- Look for path to add if ($p_add_dir != "") { if (substr($p_add_dir, -1) == "/") @@ -3005,7 +3005,7 @@ // ----- Filename (reduce the path of stored name) $v_stored_filename = PclZipUtilPathReduction($v_stored_filename); $p_filedescr['stored_filename'] = $v_stored_filename; - + // ----- Return return $v_result; } @@ -3156,7 +3156,7 @@ { // ----- Magic quotes trick $this->privSwapBackMagicQuotes(); - + // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode'); @@ -3387,7 +3387,7 @@ // ----- Look for extract by ereg rule // ereg() is deprecated with PHP 5.3 - /* + /* else if ( (isset($p_options[PCLZIP_OPT_BY_EREG])) && ($p_options[PCLZIP_OPT_BY_EREG] != "")) { @@ -3409,7 +3409,7 @@ // ----- Look for extract by index rule else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX])) && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) { - + // ----- Look if the index is in the list for ($j=$j_start; ($jprivSwapBackMagicQuotes(); - + PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_COMPRESSION, "Filename '".$v_header['stored_filename']."' is " ."compressed by an unsupported compression " @@ -3451,7 +3451,7 @@ return PclZip::errorCode(); } } - + // ----- Check encrypted files if (($v_extract) && (($v_header['flag'] & 1) == 1)) { $v_header['status'] = 'unsupported_encryption'; @@ -3483,7 +3483,7 @@ $v_extract = false; } - + // ----- Look for real extraction if ($v_extract) { @@ -3532,7 +3532,7 @@ // ----- Next extracted file $v_nb_extracted++; - + // ----- Look for user callback abort if ($v_result1 == 2) { break; @@ -3668,12 +3668,12 @@ if ($p_path != '') { $p_entry['filename'] = $p_path."/".$p_entry['filename']; } - + // ----- Check a base_dir_restriction if (isset($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION])) { $v_inclusion = PclZipUtilPathInclusion($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION], - $p_entry['filename']); + $p_entry['filename']); if ($v_inclusion == 0) { PclZip::privErrorLog(PCLZIP_ERR_DIRECTORY_RESTRICTION, @@ -3700,7 +3700,7 @@ $p_entry['status'] = "skipped"; $v_result = 1; } - + // ----- Look for abort result if ($v_result == 2) { // ----- This status is internal and will be changed in 'skipped' @@ -3727,7 +3727,7 @@ // ----- Change the file status $p_entry['status'] = "already_a_directory"; - + // ----- Look for PCLZIP_OPT_STOP_ON_ERROR // For historical reason first PclZip implementation does not stop // when this kind of error occurs. @@ -3800,10 +3800,10 @@ $v_dir_to_check = dirname($p_entry['filename']); if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external']&0x00000010)==0x00000010))) != 1) { - + // ----- Change the file status $p_entry['status'] = "path_creation_fail"; - + // ----- Return //return $v_result; $v_result = 1; @@ -3842,7 +3842,7 @@ $v_binary_data = pack('a'.$v_read_size, $v_buffer); @fwrite($v_dest_file, $v_binary_data, $v_read_size); */ - @fwrite($v_dest_file, $v_buffer, $v_read_size); + @fwrite($v_dest_file, $v_buffer, $v_read_size); $v_size -= $v_read_size; } @@ -3851,7 +3851,7 @@ // ----- Change the file mtime touch($p_entry['filename'], $p_entry['mtime']); - + } else { @@ -3864,7 +3864,7 @@ // ----- Look for using temporary file to unzip - if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) + if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON]) || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]) && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_entry['size'])) ) ) { @@ -3873,42 +3873,42 @@ return $v_result; } } - + // ----- Look for extract in memory else { - + // ----- Read the compressed file in a buffer (one shot) $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']); - + // ----- Decompress the file $v_file_content = @gzinflate($v_buffer); unset($v_buffer); if ($v_file_content === FALSE) { - + // ----- Change the file status // TBC $p_entry['status'] = "error"; - + return $v_result; } - + // ----- Opening destination file if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) { - + // ----- Change the file status $p_entry['status'] = "write_error"; - + return $v_result; } - + // ----- Write the uncompressed data @fwrite($v_dest_file, $v_file_content, $p_entry['size']); unset($v_file_content); - + // ----- Closing the destination file @fclose($v_dest_file); - + } // ----- Change the file mtime @@ -3929,7 +3929,7 @@ if ($p_entry['status'] == "aborted") { $p_entry['status'] = "skipped"; } - + // ----- Look for post-extract callback elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) { @@ -3962,7 +3962,7 @@ function privExtractFileUsingTempFile(&$p_entry, &$p_options) { $v_result=1; - + // ----- Creates a temporary file $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz'; if (($v_dest_file = @fopen($v_gzip_temp_name, "wb")) == 0) { @@ -4023,7 +4023,7 @@ // ----- Delete the temporary file @unlink($v_gzip_temp_name); - + // ----- Return return $v_result; } @@ -4101,7 +4101,7 @@ // ----- Read the compressed file in a buffer (one shot) $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']); - + // ----- Decompress the file $v_file_content = gzinflate($v_buffer); unset($v_buffer); @@ -4180,7 +4180,7 @@ $p_entry['status'] = "skipped"; $v_result = 1; } - + // ----- Look for abort result if ($v_result == 2) { // ----- This status is internal and will be changed in 'skipped' @@ -4202,41 +4202,41 @@ // ----- Look for not compressed file // if ($p_entry['compressed_size'] == $p_entry['size']) if ($p_entry['compression'] == 0) { - + // ----- Reading the file $p_string = @fread($this->zip_fd, $p_entry['compressed_size']); } else { - + // ----- Reading the file $v_data = @fread($this->zip_fd, $p_entry['compressed_size']); - + // ----- Decompress the file if (($p_string = @gzinflate($v_data)) === FALSE) { // TBC } } - + // ----- Trace } else { // TBC : error : can not extract a folder in a string } - + } // ----- Change abort status if ($p_entry['status'] == "aborted") { $p_entry['status'] = "skipped"; } - + // ----- Look for post-extract callback elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) { // ----- Generate a local information $v_local_header = array(); $this->privConvertHeader2FileInfo($p_entry, $v_local_header); - + // ----- Swap the content to header $v_local_header['content'] = $p_string; $p_string = ''; @@ -4496,7 +4496,7 @@ } if ($p_local_header['filename_len'] != $p_central_header['filename_len']) { } - + // ----- Look for flag bit 3 if (($p_local_header['flag'] & 8) == 8) { $p_local_header['size'] = $p_central_header['size']; @@ -4582,9 +4582,9 @@ // ----- Add the byte //$v_bytes = ($v_bytes << 8) | Ord($v_byte); - // Note we mask the old value down such that once shifted we can never end up with more than a 32bit number - // Otherwise on systems where we have 64bit integers the check below for the magic number will fail. - $v_bytes = ( ($v_bytes & 0xFFFFFF) << 8) | Ord($v_byte); + // Note we mask the old value down such that once shifted we can never end up with more than a 32bit number + // Otherwise on systems where we have 64bit integers the check below for the magic number will fail. + $v_bytes = ( ($v_bytes & 0xFFFFFF) << 8) | Ord($v_byte); // ----- Compare the bytes if ($v_bytes == 0x504b0506) @@ -4862,7 +4862,7 @@ // ----- Return return $v_result; } - + // ----- Check that local file header is same as central file header if ($this->privCheckFileHeaders($v_local_header, $v_header_list[$i]) != 1) { @@ -4946,11 +4946,11 @@ // TBC : I should test the result ... //@rename($v_zip_temp_name, $this->zipname); PclZipUtilRename($v_zip_temp_name, $this->zipname); - + // ----- Destroy the temporary archive unset($v_temp_zip); } - + // ----- Remove every files : reset the file else if ($v_central_dir['entries'] != 0) { $this->privCloseFd(); @@ -5437,7 +5437,7 @@ } } } - + // ----- Look for skip if ($v_skip > 0) { while ($v_skip > 0) { @@ -5470,7 +5470,7 @@ function PclZipUtilPathInclusion($p_dir, $p_path) { $v_result = 1; - + // ----- Look for path beginning by ./ if ( ($p_dir == '.') || ((strlen($p_dir) >=2) && (substr($p_dir, 0, 2) == './'))) { @@ -5638,7 +5638,7 @@ // -------------------------------------------------------------------------------- function PclZipUtilOptionText($p_option) { - + $v_list = get_defined_constants(); for (reset($v_list); $v_key = key($v_list); next($v_list)) { $v_prefix = substr($v_key, 0, 10); @@ -5649,7 +5649,7 @@ return $v_key; } } - + $v_result = 'Unknown'; return $v_result; diff --git a/wp-admin/includes/plugin.php b/wp-admin/includes/plugin.php index 7e99a07127..e88dc48fe5 100644 --- a/wp-admin/includes/plugin.php +++ b/wp-admin/includes/plugin.php @@ -991,7 +991,7 @@ function user_can_access_admin_page() { * @since 2.7.0 * * @param string $option_group A settings group name. Should correspond to a whitelisted option key name. - * Default whitelisted option key names include "general," "discussion," and "reading," among others. + * Default whitelisted option key names include "general," "discussion," and "reading," among others. * @param string $option_name The name of an option to sanitize and save. * @param unknown_type $sanitize_callback A callback function that sanitizes the option's value. * @return unknown diff --git a/wp-admin/press-this.php b/wp-admin/press-this.php index bc10b491d9..dbdd2d53ba 100644 --- a/wp-admin/press-this.php +++ b/wp-admin/press-this.php @@ -436,7 +436,7 @@ var ajaxurl = '', pagenow = 'press-thi jQuery('#title').unbind(); jQuery('#publish, #save').click(function() { jQuery('#saving').css('display', 'inline'); }); - + $('#tagsdiv-post_tag, #categorydiv').children('h3').click(function(){ $(this).siblings('.inside').toggle(); }); diff --git a/wp-includes/class-oembed.php b/wp-includes/class-oembed.php index 101973f052..2c058a3b94 100644 --- a/wp-includes/class-oembed.php +++ b/wp-includes/class-oembed.php @@ -174,7 +174,7 @@ class WP_oEmbed { // Example content: http://vimeo.com/api/oembed.xml?url=http%3A%2F%2Fvimeo.com%2F240975 elseif ( function_exists('simplexml_load_string') ) { $errors = libxml_use_internal_errors( 'true' ); - + $data = simplexml_load_string( $result ); libxml_use_internal_errors( $errors ); diff --git a/wp-includes/comment.php b/wp-includes/comment.php index 5e6f8f1e00..082bd7c125 100644 --- a/wp-includes/comment.php +++ b/wp-includes/comment.php @@ -896,8 +896,8 @@ function wp_untrash_comment($comment_id) { $comment['comment_approved'] = $status; - delete_comment_meta($comment_id, '_wp_trash_meta_time'); - delete_comment_meta($comment_id, '_wp_trash_meta_status'); + delete_comment_meta($comment_id, '_wp_trash_meta_time'); + delete_comment_meta($comment_id, '_wp_trash_meta_status'); wp_update_comment($comment); diff --git a/wp-includes/deprecated.php b/wp-includes/deprecated.php index 4bcd3fceec..fbfbeafed9 100644 --- a/wp-includes/deprecated.php +++ b/wp-includes/deprecated.php @@ -1715,7 +1715,7 @@ function the_author_ID() { * parameters. * * @deprecated 2.9.0 - * + * * @param string $more_link_text Optional. Text to display when more content is available but not displayed. * @param int|bool $stripteaser Optional. Default is 0. * @param string $more_file Optional. diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 08463ca189..6099ceab53 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -3172,13 +3172,13 @@ function wp_suspend_cache_invalidation($suspend = true) { } function get_site_option( $key, $default = false, $use_cache = true ) { - // Allow plugins to short-circuit site options. - $pre = apply_filters( 'pre_site_option_' . $key, false ); - if ( false !== $pre ) - return $pre; - + // Allow plugins to short-circuit site options. + $pre = apply_filters( 'pre_site_option_' . $key, false ); + if ( false !== $pre ) + return $pre; + $value = get_option($key, $default); - + return apply_filters( 'site_option_' . $key, $value ); } diff --git a/wp-includes/media.php b/wp-includes/media.php index 09405830d8..96e736cac9 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -560,7 +560,7 @@ function wp_get_attachment_image($attachment_id, $size = 'thumbnail', $icon = fa * Adds a 'wp-post-image' class to post image thumbnails * Uses the begin_fetch_post_image_html and end_fetch_post_image_html action hooks to * dynamically add/remove itself so as to only filter post image thumbnails - * + * * @author Mark Jaquith * @since 2.9.0 * @param array $attr Attributes including src, class, alt, title @@ -573,7 +573,7 @@ function _wp_post_image_class_filter( $attr ) { /** * Adds _wp_post_image_class_filter to the wp_get_attachment_image_attributes filter - * + * * @author Mark Jaquith * @since 2.9.0 */ @@ -583,7 +583,7 @@ function _wp_post_image_class_filter_add( $attr ) { /** * Removes _wp_post_image_class_filter from the wp_get_attachment_image_attributes filter - * + * * @author Mark Jaquith * @since 2.9.0 */ diff --git a/wp-includes/meta.php b/wp-includes/meta.php index 376b5f2351..80504fe38b 100644 --- a/wp-includes/meta.php +++ b/wp-includes/meta.php @@ -81,9 +81,9 @@ function update_metadata($meta_type, $object_id, $meta_key, $meta_value, $prev_v } function delete_metadata($meta_type, $object_id, $meta_key, $meta_value = '', $delete_all = false) { - if ( !$meta_type || !$meta_key || (!$delete_all && ! (int)$object_id) ) + if ( !$meta_type || !$meta_key || (!$delete_all && ! (int)$object_id) ) return false; - + if ( ! $table = _get_meta_table($meta_type) ) return false; diff --git a/wp-includes/post.php b/wp-includes/post.php index 51709f1b7a..2dd4f56781 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -473,7 +473,7 @@ function get_post_types( $args = array(), $output = 'names' ) { * Optional $args contents: * * exclude_from_search - Whether to exclude posts with this post type from search results. Defaults to true. - * + * * @package WordPress * @subpackage Post * @since 2.9.0 @@ -2246,7 +2246,7 @@ function &get_page_children($page_id, $pages) { * * It uses auxiliary structure to hold parent-children relationships and * runs in O(N) complexity - * + * * @since 2.0.0 * * @param array $posts Posts array. @@ -2254,34 +2254,34 @@ function &get_page_children($page_id, $pages) { * @return array A list arranged by hierarchy. Children immediately follow their parents. */ function &get_page_hierarchy( &$pages, $page_id = 0 ) { - + if ( empty( $pages ) ) return null; - + $children = array(); foreach ( (array) $pages as $p ) { - + $parent_id = intval( $p->post_parent ); $children[ $parent_id ][] = $p; } - + $result = array(); _page_traverse_name( $page_id, $children, $result ); - + return $result; } /** * function to traverse and return all the nested children post names of a root page. * $children contains parent-chilren relations - * + * */ -function _page_traverse_name( $page_id, &$children, &$result ){ - +function _page_traverse_name( $page_id, &$children, &$result ){ + if ( isset( $children[ $page_id ] ) ){ - + foreach( (array)$children[ $page_id ] as $child ) { - + $result[ $child->ID ] = $child->post_name; _page_traverse_name( $child->ID, $children, $result ); } diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php index f1f14de2c3..e1995e4f2e 100644 --- a/wp-includes/script-loader.php +++ b/wp-includes/script-loader.php @@ -385,7 +385,7 @@ function wp_default_scripts( &$scripts ) { $scripts->add( 'set-post-thumbnail-handler', "/wp-admin/js/set-post-thumbnail-handler$suffix.js", array( 'jquery' ), '20091015' ); $scripts->add_data( 'set-post-thumbnail-handler', 'group', 1 ); - + } } diff --git a/wp-includes/theme.php b/wp-includes/theme.php index b594ec1403..aacfcf286a 100644 --- a/wp-includes/theme.php +++ b/wp-includes/theme.php @@ -129,7 +129,7 @@ function get_template_directory() { $template = get_template(); $theme_root = get_theme_root( $template ); $template_dir = "$theme_root/$template"; - + return apply_filters( 'template_directory', $template_dir, $template, $theme_root ); } @@ -145,7 +145,7 @@ function get_template_directory_uri() { $template = get_template(); $theme_root_uri = get_theme_root_uri( $template ); $template_dir_uri = "$theme_root_uri/$template"; - + return apply_filters( 'template_directory_uri', $template_dir_uri, $template, $theme_root_uri ); } @@ -266,9 +266,9 @@ function get_themes() { if ( !$theme_files = search_theme_directories() ) return false; - + asort( $theme_files ); - + foreach ( (array) $theme_files as $theme_file ) { $theme_root = $theme_file['theme_root']; $theme_file = $theme_file['theme_file']; @@ -307,7 +307,7 @@ function get_themes() { else continue; } - + $template = trim( $template ); if ( !file_exists("$theme_root/$template/index.php") ) { @@ -315,9 +315,9 @@ function get_themes() { if ( file_exists("$theme_root/$parent_dir/$template/index.php") ) { $template = "$theme_root/$parent_dir/$template"; } else { - /** - * The parent theme doesn't exist in the current theme's folder or sub folder - * so lets use the theme root for the parent template. + /** + * The parent theme doesn't exist in the current theme's folder or sub folder + * so lets use the theme root for the parent template. */ $parent_theme_root = $theme_files[$template]['theme_root']; if ( file_exists( "$parent_theme_root/$template/index.php" ) ) { @@ -326,12 +326,12 @@ function get_themes() { $wp_broken_themes[$name] = array('Name' => $name, 'Title' => $title, 'Description' => __('Template is missing.')); continue; } - + } } else { $template = trim( $theme_root . '/' . $template ); } - + $stylesheet_files = array(); $template_files = array(); @@ -419,7 +419,7 @@ function get_themes() { } $wp_themes = $themes; - + return $themes; } @@ -501,16 +501,16 @@ function get_current_theme() { */ function register_theme_directory( $directory ) { global $wp_theme_directories; - + /* The theme directory should be relative to the content directory */ $registered_directory = WP_CONTENT_DIR . '/' . $directory; - + /* If this folder does not exist, return and do not register */ if ( !file_exists( $registered_directory ) ) return false; - + $wp_theme_directories[] = $registered_directory; - + return true; } @@ -523,7 +523,7 @@ function register_theme_directory( $directory ) { */ function search_theme_directories() { global $wp_theme_directories, $wp_broken_themes; - + if ( empty( $wp_theme_directories ) ) return false; @@ -533,9 +533,9 @@ function search_theme_directories() { /* Loop the registered theme directories and extract all themes */ foreach ( (array) $wp_theme_directories as $theme_root ) { $theme_loc = $theme_root; - + /* We don't want to replace all forward slashes, see Trac #4541 */ - if ( '/' != WP_CONTENT_DIR ) + if ( '/' != WP_CONTENT_DIR ) $theme_loc = str_replace(WP_CONTENT_DIR, '', $theme_root); /* Files in the root of the current theme directory and one subdir down */ @@ -551,7 +551,7 @@ function search_theme_directories() { $stylish_dir = @ opendir($theme_root . '/' . $theme_dir); $found_stylesheet = false; - + while ( ($theme_file = readdir($stylish_dir)) !== false ) { if ( $theme_file == 'style.css' ) { $theme_files[$theme_dir] = array( 'theme_file' => $theme_dir . '/' . $theme_file, 'theme_root' => $theme_root ); @@ -560,20 +560,20 @@ function search_theme_directories() { } } @closedir($stylish_dir); - + if ( !$found_stylesheet ) { // look for themes in that dir $subdir = "$theme_root/$theme_dir"; $subdir_name = $theme_dir; $theme_subdir = @ opendir( $subdir ); - + while ( ($theme_dir = readdir($theme_subdir)) !== false ) { if ( is_dir( $subdir . '/' . $theme_dir) && is_readable($subdir . '/' . $theme_dir) ) { if ( $theme_dir{0} == '.' || $theme_dir == '..' || $theme_dir == 'CVS' ) continue; - + $stylish_dir = @ opendir($subdir . '/' . $theme_dir); $found_stylesheet = false; - + while ( ($theme_file = readdir($stylish_dir)) !== false ) { if ( $theme_file == 'style.css' ) { $theme_files[$theme_dir] = array( 'theme_file' => $subdir_name . '/' . $theme_dir . '/' . $theme_file, 'theme_root' => $theme_root ); @@ -585,7 +585,7 @@ function search_theme_directories() { } } @closedir($theme_subdir); - + $wp_broken_themes[$theme_dir] = array('Name' => $theme_dir, 'Title' => $theme_dir, 'Description' => __('Stylesheet is missing.')); } } @@ -593,7 +593,7 @@ function search_theme_directories() { if ( is_dir( $theme_dir ) ) @closedir( $theme_dir ); } - + return $theme_files; } @@ -610,7 +610,7 @@ function search_theme_directories() { */ function get_theme_root( $stylesheet_or_template = false ) { $theme_roots = get_theme_roots(); - + if ( $theme_roots[$stylesheet_or_template] ) $theme_root = WP_CONTENT_DIR . '/' . $theme_roots[$stylesheet_or_template]; else @@ -631,7 +631,7 @@ function get_theme_root( $stylesheet_or_template = false ) { */ function get_theme_root_uri( $stylesheet_or_template = false ) { $theme_roots = get_theme_roots(); - + if ( $theme_roots[$stylesheet_or_template] ) $theme_root_uri = content_url( $theme_roots[$stylesheet_or_template] ); else @@ -736,7 +736,7 @@ function get_category_template() { * Works by first retrieving the current tag name, for example 'tag-wordpress.php' and then * trying tag ID, for example 'tag-1.php' and will finally fallback to tag.php * template, if those files don't exist. - * + * * @since 2.3.0 * @uses apply_filters() Calls 'tag_template' on file path of tag template. * @@ -753,7 +753,7 @@ function get_tag_template() { if ( $tag_id ) $templates[] = "tag-$tag_id.php"; $templates[] = "tag.php"; - + $template = locate_template($templates); return apply_filters('tag_template', $template); }