System update (for Wunderfeyd)

This commit is contained in:
markseu 2016-08-07 12:51:23 +02:00
parent 15e04da191
commit 45c476ca50
6 changed files with 37 additions and 29 deletions

View file

@ -263,7 +263,7 @@ class YellowCommandline
$statusCode = 200;
if(is_dir($path) && $this->checkStaticDirectory($path))
{
if(!$this->yellow->toolbox->deleteDirectory($path, true))
if(!$this->yellow->toolbox->deleteDirectory($path))
{
$statusCode = 500;
echo "ERROR cleaning files: Can't delete directory '$path'!\n";

View file

@ -2742,26 +2742,6 @@ class YellowToolbox
return $entries;
}
// Delete directory
function deleteDirectory($path, $recursive = false)
{
if($recursive)
{
$iterator = new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::SKIP_DOTS);
$files = new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::CHILD_FIRST);
foreach($files as $file)
{
if($file->isDir())
{
@rmdir($file->getRealPath());
} else {
@unlink($file->getRealPath());
}
}
}
return @rmdir($path);
}
// Return file extension
function getFileExtension($fileName)
{
@ -2852,11 +2832,39 @@ class YellowToolbox
{
$ok = @unlink($fileName);
} else {
if(!is_dir($pathTrash)) @mkdir($pathTrash, 0777, true);
$fileNameDest = $pathTrash;
$fileNameDest .= pathinfo($fileName, PATHINFO_FILENAME);
$fileNameDest .= "-".str_replace(array(" ", ":"), "-", date("Y-m-d H:i:s", filemtime($fileName)));
$fileNameDest .= ".".pathinfo($fileName, PATHINFO_EXTENSION);
$ok = $this->renameFile($fileName, $fileNameDest, true);
$ok = @rename($fileName, $fileNameDest);
}
return $ok;
}
// Delete directory
function deleteDirectory($path, $pathTrash = "")
{
if(empty($pathTrash))
{
$iterator = new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::SKIP_DOTS);
$files = new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::CHILD_FIRST);
foreach($files as $file)
{
if($file->isDir())
{
@rmdir($file->getRealPath());
} else {
@unlink($file->getRealPath());
}
}
$ok = @rmdir($path);
} else {
if(!is_dir($pathTrash)) @mkdir($pathTrash, 0777, true);
$pathDest = $pathTrash;
$pathDest .= basename($path);
$pathDest .= "-".str_replace(array(" ", ":"), "-", date("Y-m-d H:i:s", filemtime($path)));
$ok = @rename($path, $pathDest);
}
return $ok;
}

View file

@ -5,7 +5,7 @@
// Update plugin
class YellowUpdate
{
const VERSION = "0.6.5";
const VERSION = "0.6.6";
var $yellow; //access to API
// Handle initialisation
@ -246,7 +246,7 @@ class YellowUpdate
$regex = "/^.*\\".$this->yellow->config->get("downloadExtension")."$/";
foreach($this->yellow->toolbox->getDirectoryEntries($path, $regex, true, false) as $entry)
{
if(preg_match("/$feature/i", basename($entry)))
if(stristr(basename($entry), $feature))
{
if($this->updateSoftwareArchive($entry)!=200) $ok = false;
}
@ -437,7 +437,7 @@ class YellowUpdate
{
if(strnatcasecmp($dataCurrent[$key], $version)<0) $data[$key] = $dataLatest[$key];
} else {
if(preg_match("/$feature/i", $key) && $version) $data[$key] = $dataLatest[$key];
if(stristr($key, $feature) && $version) $data[$key] = $dataLatest[$key];
}
}
return array($statusCode, $data);

View file

@ -1,4 +1,4 @@
/* Yellow web interface 0.6.9 */
/* Yellow web interface 0.6.10 */
.yellow-bar { position:relative; overflow:hidden; height:2em; margin-bottom:10px; }
.yellow-bar-left { display:block; float:left; }

View file

@ -4,7 +4,7 @@
// Yellow API
var yellow =
{
version: "0.6.9",
version: "0.6.10",
action: function(action) { yellow.webinterface.action(action, "none"); },
onLoad: function() { yellow.webinterface.loadInterface(); },
onClick: function(e) { yellow.webinterface.hidePanesOnClick(yellow.toolbox.getEventElement(e)); },

View file

@ -5,7 +5,7 @@
// Web interface plugin
class YellowWebinterface
{
const VERSION = "0.6.9";
const VERSION = "0.6.10";
var $yellow; //access to API
var $active; //web interface is active? (boolean)
var $userEmail; //web interface user
@ -381,7 +381,7 @@ class YellowWebinterface
function processRequestSettings($serverScheme, $serverName, $base, $location, $fileName)
{
$this->action = "settings";
$this->status = $this->getUserAccount($this->userEmail, "", $this->action);
$this->status = "ok";
if($this->status=="ok")
{
$name = trim(preg_replace("/[^\pL\d\-\. ]/u", "-", $_REQUEST["name"]));