Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Test if gzopen64 function exists for some versions of PHP compiled wi…
Browse files Browse the repository at this point in the history
…th large files support. Fix #690
  • Loading branch information
cdujeu committed Nov 10, 2014
1 parent 529ab49 commit fe2b9b1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion core/src/core/classes/class.ConfService.php
Expand Up @@ -869,7 +869,7 @@ public function deleteRepositoryInst($repoId)
public static function zipEnabled()
{
if(ConfService::getCoreConf("DISABLE_ZIP_BROWSING") === true) return false;
return (function_exists("gzopen")?true:false);
return ((function_exists("gzopen") || function_exists("gzopen64"))?true:false);
}
/**
* Get the list of all "conf" messages
Expand Down
16 changes: 13 additions & 3 deletions core/src/core/classes/pclzip.lib.php
Expand Up @@ -216,7 +216,7 @@ function PclZip($p_zipname)
{

// ----- Tests the zlib
if (!function_exists('gzopen'))
if (!function_exists('gzopen') && !function_exists('gzopen64'))
{
die('Abort '.basename(__FILE__).' : Missing zlib extensions');
}
Expand Down Expand Up @@ -2811,7 +2811,12 @@ function privAddFileUsingTempFile($p_filedescr, &$p_header, &$p_options)

// ----- Creates a compressed temporary file
$v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz';
if (($v_file_compressed = @gzopen($v_gzip_temp_name, "wb")) == 0) {
if(function_exists('gzopen64')){
$v_file_compressed = @gzopen64($v_gzip_temp_name, "wb");
}else{
$v_file_compressed = @gzopen($v_gzip_temp_name, "wb");
}
if ($v_file_compressed == 0) {
fclose($v_file);
PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode');
return PclZip::errorCode();
Expand Down Expand Up @@ -4005,7 +4010,12 @@ function privExtractFileUsingTempFile(&$p_entry, &$p_options)
}

// ----- Open the temporary gz file
if (($v_src_file = @gzopen($v_gzip_temp_name, 'rb')) == 0) {
if(function_exists('gzopen64')){
$v_src_file = @gzopen64($v_gzip_temp_name, 'rb');
}else{
$v_src_file = @gzopen($v_gzip_temp_name, 'rb');
}
if ($v_src_file == 0) {
@fclose($v_dest_file);
$p_entry['status'] = "read_error";
PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
Expand Down
4 changes: 2 additions & 2 deletions core/src/core/tests/test.Zlib.php
Expand Up @@ -28,10 +28,10 @@
*/
class Zlib extends AbstractTest
{
public function Zlib() { parent::AbstractTest("Zlib extension (ZIP)", "Extension enabled : ".(function_exists('gzopen')?"1":"0")); }
public function Zlib() { parent::AbstractTest("Zlib extension (ZIP)", "Extension enabled : ".((function_exists('gzopen')||function_exists('gzopen64'))?"1":"0")); }
public function doTest()
{
$this->testedParams["Zlib Enabled"] = (function_exists('gzopen')?"Yes":"No");
$this->testedParams["Zlib Enabled"] = ((function_exists('gzopen')||function_exists('gzopen64'))?"Yes":"No");
$os = PHP_OS;
/*if (stristr($os, "win")!==false && $this->testedParams["Zlib Enabled"]) {
$this->failedLevel = "warning";
Expand Down

0 comments on commit fe2b9b1

Please sign in to comment.