1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-08 23:56:58 +02:00

Plugin/Theme "new version" alerts on admin dashboard. Overwriting enabled during download - existing plugins/theme now moved out of the way and backed up.Theme-dir scanning improved and optimized for speed.

This commit is contained in:
Cameron
2017-01-04 18:08:58 -08:00
parent 703e514045
commit 6e68aaa9a4
9 changed files with 716 additions and 212 deletions

View File

@@ -1321,7 +1321,7 @@ class e_file
* @param string $type - addon type, either 'plugin' or 'theme', (possibly 'language' in future).
* @return string unzipped folder name on success or false.
*/
public function unzipArchive($localfile, $type)
public function unzipArchive($localfile, $type, $overwrite=false)
{
$mes = e107::getMessage();
@@ -1329,7 +1329,7 @@ class e_file
$dir = false;
if(class_exists('ZipArchive') && e_DEBUG === true) // PHP7 compat. method.
if(class_exists('ZipArchive')) // PHP7 compat. method.
{
$zip = new ZipArchive;
@@ -1377,15 +1377,30 @@ class e_file
if($dir && is_dir($destpath.$dir))
{
$mes->addError("(".ucfirst($type).") Already Downloaded - ".basename($destpath).'/'.$dir);
if(file_exists(e_TEMP.$localfile))
{
@unlink(e_TEMP.$localfile);
if($overwrite === true)
{
if(file_exists(e_TEMP.$localfile))
{
$time = date("YmdHi");
if(rename($destpath.$dir, e_BACKUP.$dir."_".$time))
{
$mes->addSuccess("Old folder moved to backup directory");
}
}
}
else
{
$mes->addError("(".ucfirst($type).") Already Downloaded - ".basename($destpath).'/'.$dir);
if(file_exists(e_TEMP.$localfile))
{
@unlink(e_TEMP.$localfile);
}
$this->removeDir(e_TEMP.$dir);
return false;
}
$this->removeDir(e_TEMP.$dir);
return false;
}
if(empty($dir))