mirror of
https://github.com/e107inc/e107.git
synced 2025-08-08 15:46:44 +02:00
added use of ZipArchive unzip method for testing. (debug mode only) Issue #1907
This commit is contained in:
@@ -1322,11 +1322,50 @@ class e_file
|
|||||||
$mes = e107::getMessage();
|
$mes = e107::getMessage();
|
||||||
|
|
||||||
chmod(e_TEMP.$localfile, 0755);
|
chmod(e_TEMP.$localfile, 0755);
|
||||||
|
|
||||||
|
$dir = false;
|
||||||
|
|
||||||
|
if(class_exists('ZipArchive') && e_DEBUG === true) // PHP7 compat. method.
|
||||||
|
{
|
||||||
|
$zip = new ZipArchive;
|
||||||
|
|
||||||
|
if($zip->open(e_TEMP.$localfile) === true)
|
||||||
|
{
|
||||||
|
for($i = 0; $i < $zip->numFiles; $i++ )
|
||||||
|
{
|
||||||
|
$filename = $zip->getNameIndex($i);
|
||||||
|
$fileinfo = pathinfo($filename);
|
||||||
|
|
||||||
|
if($fileinfo['dirname'] === '.')
|
||||||
|
{
|
||||||
|
$dir = $fileinfo['basename'];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// $stat = $zip->statIndex( $i );
|
||||||
|
// print_a( $stat['name'] );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$zip->extractTo(e_TEMP);
|
||||||
|
chmod(e_TEMP.$dir, 0755);
|
||||||
|
|
||||||
|
$zip->close();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
else // Legacy Method.
|
||||||
|
{
|
||||||
require_once(e_HANDLER."pclzip.lib.php");
|
require_once(e_HANDLER."pclzip.lib.php");
|
||||||
|
|
||||||
$archive = new PclZip(e_TEMP.$localfile);
|
$archive = new PclZip(e_TEMP.$localfile);
|
||||||
$unarc = ($fileList = $archive -> extract(PCLZIP_OPT_PATH, e_TEMP, PCLZIP_OPT_SET_CHMOD, 0755)); // Store in TEMP first.
|
$unarc = ($fileList = $archive -> extract(PCLZIP_OPT_PATH, e_TEMP, PCLZIP_OPT_SET_CHMOD, 0755)); // Store in TEMP first.
|
||||||
$dir = $this->getRootFolder($unarc);
|
$dir = $this->getRootFolder($unarc);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$destpath = ($type == 'theme') ? e_THEME : e_PLUGIN;
|
$destpath = ($type == 'theme') ? e_THEME : e_PLUGIN;
|
||||||
$typeDiz = ucfirst($type);
|
$typeDiz = ucfirst($type);
|
||||||
|
|
||||||
@@ -1345,7 +1384,7 @@ class e_file
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($dir == '')
|
if(empty($dir))
|
||||||
{
|
{
|
||||||
$mes->addError("Couldn't detect the root folder in the zip."); // flush();
|
$mes->addError("Couldn't detect the root folder in the zip."); // flush();
|
||||||
@unlink(e_TEMP.$localfile);
|
@unlink(e_TEMP.$localfile);
|
||||||
@@ -1354,7 +1393,8 @@ class e_file
|
|||||||
|
|
||||||
if(is_dir(e_TEMP.$dir))
|
if(is_dir(e_TEMP.$dir))
|
||||||
{
|
{
|
||||||
if(!rename(e_TEMP.$dir,$destpath.$dir))
|
$res = rename(e_TEMP.$dir,$destpath.$dir);
|
||||||
|
if($res === false)
|
||||||
{
|
{
|
||||||
$mes->addError("Couldn't Move ".e_TEMP.$dir." to ".$destpath.$dir." Folder"); // flush(); usleep(50000);
|
$mes->addError("Couldn't Move ".e_TEMP.$dir." to ".$destpath.$dir." Folder"); // flush(); usleep(50000);
|
||||||
@unlink(e_TEMP.$localfile);
|
@unlink(e_TEMP.$localfile);
|
||||||
|
Reference in New Issue
Block a user