Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
3360a933be
@ -62,8 +62,11 @@ class zipfile
|
||||
* "echo $zipfile;" command
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @return nothing
|
||||
*/
|
||||
function setDoWrite() {
|
||||
function setDoWrite()
|
||||
{
|
||||
$this -> doWrite = true;
|
||||
} // end of the 'setDoWrite()' method
|
||||
|
||||
@ -71,13 +74,14 @@ class zipfile
|
||||
* Converts an Unix timestamp to a four byte DOS date and time format (date
|
||||
* in high two bytes, time in low two bytes allowing magnitude comparison).
|
||||
*
|
||||
* @param integer the current Unix timestamp
|
||||
* @param integer $unixtime the current Unix timestamp
|
||||
*
|
||||
* @return integer the current date in a four byte DOS format
|
||||
* @return integer the current date in a four byte DOS format
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
function unix2DosTime($unixtime = 0) {
|
||||
function unix2DosTime($unixtime = 0)
|
||||
{
|
||||
$timearray = ($unixtime == 0) ? getdate() : getdate($unixtime);
|
||||
|
||||
if ($timearray['year'] < 1980) {
|
||||
@ -97,17 +101,19 @@ class zipfile
|
||||
/**
|
||||
* Adds "file" to archive
|
||||
*
|
||||
* @param string file contents
|
||||
* @param string name of the file in the archive (may contains the path)
|
||||
* @param integer the current timestamp
|
||||
* @param string $data file contents
|
||||
* @param string $name name of the file in the archive (may contains the path)
|
||||
* @param integer $time the current timestamp
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @return nothing
|
||||
*/
|
||||
function addFile($data, $name, $time = 0)
|
||||
{
|
||||
$name = str_replace('\\', '/', $name);
|
||||
|
||||
$dtime = substr( "00000000" . dechex($this->unix2DosTime($time)), -8);
|
||||
$dtime = substr("00000000" . dechex($this->unix2DosTime($time)), -8);
|
||||
$hexdtime = '\x' . $dtime[6] . $dtime[7]
|
||||
. '\x' . $dtime[4] . $dtime[5]
|
||||
. '\x' . $dtime[2] . $dtime[3]
|
||||
|
||||
@ -7,13 +7,14 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Gets zip file contents
|
||||
*
|
||||
* @param string $specific_entry regular expression to match a file
|
||||
* @return array ($error_message, $file_data); $error_message
|
||||
* is empty if no error
|
||||
*/
|
||||
|
||||
* Gets zip file contents
|
||||
*
|
||||
* @param string $file zip file
|
||||
* @param string $specific_entry regular expression to match a file
|
||||
*
|
||||
* @return array ($error_message, $file_data); $error_message
|
||||
* is empty if no error
|
||||
*/
|
||||
function PMA_getZipContents($file, $specific_entry = null)
|
||||
{
|
||||
$error_message = '';
|
||||
@ -77,6 +78,8 @@ function PMA_getZipContents($file, $specific_entry = null)
|
||||
*
|
||||
* @param string $file_regexp regular expression for the file name to match
|
||||
* @param string $file zip archive
|
||||
*
|
||||
* @return string the file name of the first file that matches the given regexp
|
||||
*/
|
||||
function PMA_findFileFromZipArchive ($file_regexp, $file)
|
||||
{
|
||||
@ -100,7 +103,9 @@ function PMA_findFileFromZipArchive ($file_regexp, $file)
|
||||
/**
|
||||
* Returns the number of files in the zip archive.
|
||||
*
|
||||
* @param string $file
|
||||
* @param string $file zip archive
|
||||
*
|
||||
* @return int the number of files in the zip archive
|
||||
*/
|
||||
function PMA_getNoOfFilesInZip($file)
|
||||
{
|
||||
@ -121,11 +126,14 @@ function PMA_getNoOfFilesInZip($file)
|
||||
/**
|
||||
* Extracts a set of files from the given zip archive to a given destinations.
|
||||
*
|
||||
* @param string $zip_path
|
||||
* @param string $destination
|
||||
* @param array $entries
|
||||
* @param string $zip_path path to the zip archive
|
||||
* @param string $destination destination to extract files
|
||||
* @param array $entries files in archive that should be extracted
|
||||
*
|
||||
* @return bool true on sucess, false otherwise
|
||||
*/
|
||||
function PMA_zipExtract($zip_path, $destination, $entries) {
|
||||
function PMA_zipExtract($zip_path, $destination, $entries)
|
||||
{
|
||||
$zip = new ZipArchive;
|
||||
if ($zip->open($zip_path) === true) {
|
||||
$zip->extractTo($destination, $entries);
|
||||
@ -138,30 +146,31 @@ function PMA_zipExtract($zip_path, $destination, $entries) {
|
||||
/**
|
||||
* Gets zip error message
|
||||
*
|
||||
* @param integer error code
|
||||
* @return string error message
|
||||
* @param integer $code error code
|
||||
*
|
||||
* @return string error message
|
||||
*/
|
||||
function PMA_getZipError($code)
|
||||
{
|
||||
// I don't think this needs translation
|
||||
switch ($code) {
|
||||
case ZIPARCHIVE::ER_MULTIDISK:
|
||||
$message = 'Multi-disk zip archives not supported';
|
||||
break;
|
||||
case ZIPARCHIVE::ER_READ:
|
||||
$message = 'Read error';
|
||||
break;
|
||||
case ZIPARCHIVE::ER_CRC:
|
||||
$message = 'CRC error';
|
||||
break;
|
||||
case ZIPARCHIVE::ER_NOZIP:
|
||||
$message = 'Not a zip archive';
|
||||
break;
|
||||
case ZIPARCHIVE::ER_INCONS:
|
||||
$message = 'Zip archive inconsistent';
|
||||
break;
|
||||
default:
|
||||
$message = $code;
|
||||
case ZIPARCHIVE::ER_MULTIDISK:
|
||||
$message = 'Multi-disk zip archives not supported';
|
||||
break;
|
||||
case ZIPARCHIVE::ER_READ:
|
||||
$message = 'Read error';
|
||||
break;
|
||||
case ZIPARCHIVE::ER_CRC:
|
||||
$message = 'CRC error';
|
||||
break;
|
||||
case ZIPARCHIVE::ER_NOZIP:
|
||||
$message = 'Not a zip archive';
|
||||
break;
|
||||
case ZIPARCHIVE::ER_INCONS:
|
||||
$message = 'Zip archive inconsistent';
|
||||
break;
|
||||
default:
|
||||
$message = $code;
|
||||
}
|
||||
return $message;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user