From 4ed32728d9337a4f382aa8a275ff2933ef3ca3df Mon Sep 17 00:00:00 2001 From: Nicola Lambathakis Date: Wed, 11 Jan 2017 12:55:13 +0100 Subject: [PATCH] fix Deprecated: Methods with the same name Deprecated: Methods with the same name PHP7 --- assets/snippets/evobackup/pclzip.lib.php | 309 ++++++++++--------- install/assets/snippets/RunEvoAutoBackup.tpl | 2 +- 2 files changed, 156 insertions(+), 155 deletions(-) diff --git a/assets/snippets/evobackup/pclzip.lib.php b/assets/snippets/evobackup/pclzip.lib.php index e7facc1..293419a 100644 --- a/assets/snippets/evobackup/pclzip.lib.php +++ b/assets/snippets/evobackup/pclzip.lib.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 @@ class PclZip // ----- 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 @@ -212,14 +212,18 @@ class PclZip // Note that no real action is taken, if the archive does not exist it is not // created. Use create() for that. // -------------------------------------------------------------------------------- - function PclZip($p_zipname) + function __construct($p_zipname) { // ----- Tests the zlib - if (!function_exists('gzopen')) + if (!extension_loaded('zlib')) { die('Abort '.basename(__FILE__).' : Missing zlib extensions'); } + if (!function_exists('gzopen') && !function_exists('gzopen64')) + { + die('Abort '.basename(__FILE__).' : Could not find gzopen'); + } // ----- Set the attributes $this->zipname = $p_zipname; @@ -332,7 +336,7 @@ function create($p_filelist) } } } - + // ----- Look for default option values $this->privOptionDefaultThreshold($v_options); @@ -341,16 +345,16 @@ function create($p_filelist) $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 +372,7 @@ function create($p_filelist) 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 +383,7 @@ function create($p_filelist) } } } - + // ----- For each file in the list check the attributes $v_supported_attributes = array ( PCLZIP_ATT_FILE_NAME => 'mandatory' @@ -528,16 +532,16 @@ function add($p_filelist) $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 +559,14 @@ function add($p_filelist) 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 +1000,7 @@ function extractByIndex($p_index) // 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 +1068,7 @@ function delete() // -------------------------------------------------------------------------------- function deleteByIndex($p_index) { - + $p_list = $this->delete(PCLZIP_OPT_BY_INDEX, $p_index); // ----- Return @@ -1114,7 +1118,7 @@ function properties() 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'); @@ -1122,7 +1126,7 @@ function properties() return 0; } - // ----- Read the central directory informations + // ----- Read the central directory information $v_central_dir = array(); if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) { @@ -1426,7 +1430,7 @@ function privCheckFormat($p_level=0) 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 +1470,13 @@ function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_request 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 +1495,7 @@ function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_request 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 +1510,7 @@ function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_request 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 +1659,7 @@ function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_request // ----- 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 +1670,10 @@ function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_request // ----- 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 +1707,7 @@ function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_request } $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 +1810,10 @@ function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_request } } } - + // ----- Look for default values if (!isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) { - + } // ----- Return @@ -1826,17 +1830,17 @@ function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_request 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 +1849,15 @@ function privOptionDefaultThreshold(&$p_options) $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 +1874,10 @@ function privOptionDefaultThreshold(&$p_options) 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 +1896,7 @@ function privFileDescrParseAtt(&$p_file_list, &$p_filedescr, $v_options, $v_requ } $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 +1977,10 @@ function privFileDescrParseAtt(&$p_file_list, &$p_filedescr, $v_options, $v_requ } } } - + // end foreach } - + // ----- Return return $v_result; } @@ -1989,7 +1993,7 @@ function privFileDescrParseAtt(&$p_file_list, &$p_filedescr, $v_options, $v_requ // 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 +2003,20 @@ function privFileDescrParseAtt(&$p_file_list, &$p_filedescr, $v_options, $v_requ 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 +2067,10 @@ function privFileDescrExpand(&$p_filedescr_list, &$p_options) 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 +2083,34 @@ function privFileDescrExpand(&$p_filedescr_list, &$p_options) $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 +2129,7 @@ function privCreate($p_filedescr_list, &$p_result_list, &$p_options) { $v_result=1; $v_list_detail = array(); - + // ----- Magic quotes trick $this->privDisableMagicQuotes(); @@ -2184,7 +2188,7 @@ function privAdd($p_filedescr_list, &$p_result_list, &$p_options) return $v_result; } - // ----- Read the central directory informations + // ----- Read the central directory information $v_central_dir = array(); if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) { @@ -2455,7 +2459,7 @@ function privAddList($p_filedescr_list, &$p_result_list, &$p_options) // 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 +2477,7 @@ function privAddFileList($p_filedescr_list, &$p_result_list, &$p_options) // ----- 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 +2529,7 @@ function privAddFileList($p_filedescr_list, &$p_result_list, &$p_options) function privAddFile($p_filedescr, &$p_header, &$p_options) { $v_result=1; - + // ----- Working variable $p_filename = $p_filedescr['filename']; @@ -2537,8 +2541,8 @@ function privAddFile($p_filedescr, &$p_header, &$p_options) // ----- 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 +2577,20 @@ function privAddFile($p_filedescr, &$p_header, &$p_options) $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'])) { @@ -2627,7 +2631,7 @@ function privAddFile($p_filedescr, &$p_header, &$p_options) $v_result = 1; } - // ----- Update the informations + // ----- Update the information // Only some fields can be modified if ($p_header['stored_filename'] != $v_local_header['stored_filename']) { $p_header['stored_filename'] = PclZipUtilPathReduction($v_local_header['stored_filename']); @@ -2638,7 +2642,7 @@ function privAddFile($p_filedescr, &$p_header, &$p_options) 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'; @@ -2650,7 +2654,7 @@ function privAddFile($p_filedescr, &$p_header, &$p_options) // ----- 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'])) ) ) { @@ -2659,7 +2663,7 @@ function privAddFile($p_filedescr, &$p_header, &$p_options) return $v_result; } } - + // ----- Use "in memory" zip algo else { @@ -2677,14 +2681,14 @@ function privAddFile($p_filedescr, &$p_header, &$p_options) // ----- 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 @@ -2694,7 +2698,7 @@ function privAddFile($p_filedescr, &$p_header, &$p_options) $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); @@ -2710,19 +2714,19 @@ function privAddFile($p_filedescr, &$p_header, &$p_options) // ----- 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 @@ -2732,7 +2736,7 @@ function privAddFile($p_filedescr, &$p_header, &$p_options) $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); @@ -2780,7 +2784,7 @@ function privAddFile($p_filedescr, &$p_header, &$p_options) $v_result = 1; } - // ----- Update the informations + // ----- Update the information // Nothing can be modified } @@ -2798,7 +2802,7 @@ function privAddFile($p_filedescr, &$p_header, &$p_options) function privAddFileUsingTempFile($p_filedescr, &$p_header, &$p_options) { $v_result=PCLZIP_ERR_NO_ERROR; - + // ----- Working variable $p_filename = $p_filedescr['filename']; @@ -2893,7 +2897,7 @@ function privAddFileUsingTempFile($p_filedescr, &$p_header, &$p_options) // ----- Unlink the temporary file @unlink($v_gzip_temp_name); - + // ----- Return return $v_result; } @@ -2910,7 +2914,7 @@ function privAddFileUsingTempFile($p_filedescr, &$p_header, &$p_options) function privCalculateStoredFilename(&$p_filedescr, &$p_options) { $v_result=1; - + // ----- Working variables $p_filename = $p_filedescr['filename']; if (isset($p_options[PCLZIP_OPT_ADD_PATH])) { @@ -2938,7 +2942,7 @@ function privCalculateStoredFilename(&$p_filedescr, &$p_options) // ----- Remove drive letter if any $v_stored_filename = PclZipUtilTranslateWinPath($p_filedescr['new_full_name']); } - + // ----- Look for path and/or short name change else { @@ -2968,7 +2972,7 @@ function privCalculateStoredFilename(&$p_filedescr, &$p_options) 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; @@ -2991,10 +2995,10 @@ function privCalculateStoredFilename(&$p_filedescr, &$p_options) } } } - + // ----- 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) == "/") @@ -3007,7 +3011,7 @@ function privCalculateStoredFilename(&$p_filedescr, &$p_options) // ----- 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; } @@ -3158,7 +3162,7 @@ function privList(&$p_list) { // ----- Magic quotes trick $this->privSwapBackMagicQuotes(); - + // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode'); @@ -3166,7 +3170,7 @@ function privList(&$p_list) return PclZip::errorCode(); } - // ----- Read the central directory informations + // ----- Read the central directory information $v_central_dir = array(); if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) { @@ -3217,7 +3221,7 @@ function privList(&$p_list) // -------------------------------------------------------------------------------- // Function : privConvertHeader2FileInfo() // Description : - // This function takes the file informations from the central directory + // This function takes the file information from the central directory // entries and extract the interesting parameters that will be given back. // The resulting file infos are set in the array $p_info // $p_info['filename'] : Filename with full path. Given by user (add), @@ -3310,7 +3314,7 @@ function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all return $v_result; } - // ----- Read the central directory informations + // ----- Read the central directory information $v_central_dir = array(); if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) { @@ -3389,7 +3393,7 @@ function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all // ----- 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] != "")) { @@ -3411,7 +3415,7 @@ function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all // ----- 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 " @@ -3453,7 +3457,7 @@ function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all return PclZip::errorCode(); } } - + // ----- Check encrypted files if (($v_extract) && (($v_header['flag'] & 1) == 1)) { $v_header['status'] = 'unsupported_encryption'; @@ -3485,7 +3489,7 @@ function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all $v_extract = false; } - + // ----- Look for real extraction if ($v_extract) { @@ -3534,7 +3538,7 @@ function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all // ----- Next extracted file $v_nb_extracted++; - + // ----- Look for user callback abort if ($v_result1 == 2) { break; @@ -3670,12 +3674,12 @@ function privExtractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, 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, @@ -3703,7 +3707,7 @@ function privExtractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, $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' @@ -3711,7 +3715,7 @@ function privExtractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, $v_result = PCLZIP_ERR_USER_ABORTED; } - // ----- Update the informations + // ----- Update the information // Only some fields can be modified $p_entry['filename'] = $v_local_header['filename']; } @@ -3730,7 +3734,7 @@ function privExtractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, // ----- 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. @@ -3803,10 +3807,10 @@ function privExtractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, $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; @@ -3845,7 +3849,7 @@ function privExtractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, $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; } @@ -3854,7 +3858,7 @@ function privExtractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, // ----- Change the file mtime touch($p_entry['filename'], $p_entry['mtime']); - + } else { @@ -3867,7 +3871,7 @@ function privExtractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, // ----- 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'])) ) ) { @@ -3876,42 +3880,42 @@ function privExtractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, 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 @@ -3932,7 +3936,7 @@ function privExtractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, if ($p_entry['status'] == "aborted") { $p_entry['status'] = "skipped"; } - + // ----- Look for post-extract callback elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) { @@ -3966,7 +3970,7 @@ function privExtractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, 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) { @@ -4027,7 +4031,7 @@ function privExtractFileUsingTempFile(&$p_entry, &$p_options) // ----- Delete the temporary file @unlink($v_gzip_temp_name); - + // ----- Return return $v_result; } @@ -4079,7 +4083,7 @@ function privExtractFileInOutput(&$p_entry, &$p_options) $v_result = PCLZIP_ERR_USER_ABORTED; } - // ----- Update the informations + // ----- Update the information // Only some fields can be modified $p_entry['filename'] = $v_local_header['filename']; } @@ -4105,7 +4109,7 @@ function privExtractFileInOutput(&$p_entry, &$p_options) // ----- 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); @@ -4186,7 +4190,7 @@ function privExtractFileAsString(&$p_entry, &$p_string, &$p_options) $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' @@ -4194,7 +4198,7 @@ function privExtractFileAsString(&$p_entry, &$p_string, &$p_options) $v_result = PCLZIP_ERR_USER_ABORTED; } - // ----- Update the informations + // ----- Update the information // Only some fields can be modified $p_entry['filename'] = $v_local_header['filename']; } @@ -4208,41 +4212,41 @@ function privExtractFileAsString(&$p_entry, &$p_string, &$p_options) // ----- 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 = ''; @@ -4503,7 +4507,7 @@ function privCheckFileHeaders(&$p_local_header, &$p_central_header) } 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']; @@ -4589,9 +4593,9 @@ function privReadEndCentralDir(&$p_central_dir) // ----- 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) @@ -4691,7 +4695,7 @@ function privDeleteByRule(&$p_result_list, &$p_options) return $v_result; } - // ----- Read the central directory informations + // ----- Read the central directory information $v_central_dir = array(); if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) { @@ -4869,7 +4873,7 @@ function privDeleteByRule(&$p_result_list, &$p_options) // ----- 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) { @@ -4953,11 +4957,11 @@ function privDeleteByRule(&$p_result_list, &$p_options) // 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(); @@ -5077,7 +5081,7 @@ function privMerge(&$p_archive_to_add) return $v_result; } - // ----- Read the central directory informations + // ----- Read the central directory information $v_central_dir = array(); if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) { @@ -5097,7 +5101,7 @@ function privMerge(&$p_archive_to_add) return $v_result; } - // ----- Read the central directory informations + // ----- Read the central directory information $v_central_dir_to_add = array(); if (($v_result = $p_archive_to_add->privReadEndCentralDir($v_central_dir_to_add)) != 1) { @@ -5444,7 +5448,7 @@ function PclZipUtilPathReduction($p_dir) } } } - + // ----- Look for skip if ($v_skip > 0) { while ($v_skip > 0) { @@ -5477,7 +5481,7 @@ function PclZipUtilPathReduction($p_dir) 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) == './'))) { @@ -5645,7 +5649,7 @@ function PclZipUtilRename($p_src, $p_dest) // -------------------------------------------------------------------------------- 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); @@ -5656,7 +5660,7 @@ function PclZipUtilOptionText($p_option) return $v_key; } } - + $v_result = 'Unknown'; return $v_result; @@ -5689,6 +5693,3 @@ function PclZipUtilTranslateWinPath($p_path, $p_remove_disk_letter=true) return $p_path; } // -------------------------------------------------------------------------------- - - -?> diff --git a/install/assets/snippets/RunEvoAutoBackup.tpl b/install/assets/snippets/RunEvoAutoBackup.tpl index ac7957d..7884b7f 100644 --- a/install/assets/snippets/RunEvoAutoBackup.tpl +++ b/install/assets/snippets/RunEvoAutoBackup.tpl @@ -141,7 +141,7 @@ EOD; var $_dbtables; var $_isDroptables; - function Mysqldumper($host, $dbuser, $dbpassword, $dbname) + function __construct($host, $dbuser, $dbpassword, $dbname) { $this->setHost($host); $this->setDBuser($dbuser);