mirror of
https://github.com/e107inc/e107.git
synced 2025-08-15 11:04:18 +02:00
Plugin install tweaks and layout fixes.
This commit is contained in:
@@ -942,8 +942,10 @@ class e_file
|
||||
if($d['folder'] == 1 && $target == $test) //
|
||||
{
|
||||
// $text .= "\\n test = ".$test;
|
||||
$text .= "\\n test=".$test;
|
||||
$text .= "\\n target=".$target;
|
||||
$text = "getRootDirectory: ".$d['stored_filename'];
|
||||
$text .= "<br />test=".$test;
|
||||
$text .= "<br />target=".$target;
|
||||
|
||||
if(E107_DEBUG_LEVEL > 0)
|
||||
{
|
||||
e107::getMessage()->addDebug($text);
|
||||
@@ -993,5 +995,110 @@ class e_file
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Recursive Directory removal .
|
||||
*/
|
||||
public function removeDir($dir)
|
||||
{
|
||||
if (is_dir($dir))
|
||||
{
|
||||
$objects = scandir($dir);
|
||||
foreach ($objects as $object)
|
||||
{
|
||||
if ($object != "." && $object != "..")
|
||||
{
|
||||
if (filetype($dir."/".$object) == "dir")
|
||||
{
|
||||
$this->removeDir($dir."/".$object);
|
||||
}
|
||||
else
|
||||
{
|
||||
@unlink($dir."/".$object);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
reset($objects);
|
||||
@rmdir($dir);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* File-class wrapper for upload handler. (Preferred for v2.x)
|
||||
* Process files uploaded in a form post. ie. $_FILES.
|
||||
*/
|
||||
public function getUploaded($uploaddir, $fileinfo = false, $options = null)
|
||||
{
|
||||
require_once(e_HANDLER."upload_handler.php");
|
||||
return process_uploaded_files($uploaddir, $fileinfo, $options);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Unzip Plugin or Theme zip file and move to plugin or theme folder.
|
||||
* @param string $localfile - filename located in e_TEMP
|
||||
* @param string $type - addon type, either 'plugin' or 'theme', (possibly 'language' in future).
|
||||
*/
|
||||
public function unzipArchive($localfile, $type)
|
||||
{
|
||||
$mes = e107::getMessage();
|
||||
|
||||
chmod(e_TEMP.$localfile, 0755);
|
||||
require_once(e_HANDLER."pclzip.lib.php");
|
||||
|
||||
$archive = new PclZip(e_TEMP.$localfile);
|
||||
$unarc = ($fileList = $archive -> extract(PCLZIP_OPT_PATH, e_TEMP, PCLZIP_OPT_SET_CHMOD, 0755)); // Store in TEMP first.
|
||||
$dir = $this->getRootFolder($unarc);
|
||||
$destpath = ($type == 'theme') ? e_THEME : e_PLUGIN;
|
||||
$typeDiz = ucfirst($type);
|
||||
|
||||
@copy(e_TEMP.$localfile, e_BACKUP.$dir.".zip"); // Make a Backup in the system folder.
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
$this->removeDir(e_TEMP.$dir);
|
||||
return false;
|
||||
}
|
||||
|
||||
if($dir == '')
|
||||
{
|
||||
$mes->addError("Couldn't detect the root folder in the zip."); // flush();
|
||||
@unlink(e_TEMP.$localfile);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(is_dir(e_TEMP.$dir))
|
||||
{
|
||||
if(!rename(e_TEMP.$dir,$destpath.$dir))
|
||||
{
|
||||
$mes->addError("Couldn't Move ".e_TEMP.$dir." to ".$destpath.$dir." Folder"); // flush(); usleep(50000);
|
||||
@unlink(e_TEMP.$localfile);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// $dir = basename($unarc[0]['filename']);
|
||||
// $plugPath = preg_replace("/[^a-z0-9-\._]/", "-", strtolower($dir));
|
||||
//$status = "Done"; // ADMIN_TRUE_ICON;
|
||||
@unlink(e_TEMP.$localfile);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user