|
@@ -1,11 +1,11 @@
|
|
|
<?php
|
|
|
-// Copyright (c) 2013-2016 Datenstrom, http://datenstrom.se
|
|
|
+// Copyright (c) 2013-2017 Datenstrom, http://datenstrom.se
|
|
|
// This file may be used and distributed under the terms of the public license.
|
|
|
|
|
|
// Update plugin
|
|
|
class YellowUpdate
|
|
|
{
|
|
|
- const VERSION = "0.6.10";
|
|
|
+ const VERSION = "0.6.11";
|
|
|
var $yellow; //access to API
|
|
|
|
|
|
// Handle initialisation
|
|
@@ -16,17 +16,24 @@ class YellowUpdate
|
|
|
$this->yellow->config->setDefault("updateThemesUrl", "https://github.com/datenstrom/yellow-themes");
|
|
|
$this->yellow->config->setDefault("updateVersionFile", "version.ini");
|
|
|
$this->yellow->config->setDefault("updateInformationFile", "update.ini");
|
|
|
+ $this->yellow->config->setDefault("updateNotification", "none");
|
|
|
+ }
|
|
|
+
|
|
|
+ // Handle update
|
|
|
+ function onUpdate($name)
|
|
|
+ {
|
|
|
+ if(empty($name)) $this->processUpdateNotification();
|
|
|
}
|
|
|
|
|
|
// Handle request
|
|
|
function onRequest($serverScheme, $serverName, $base, $location, $fileName)
|
|
|
{
|
|
|
$statusCode = 0;
|
|
|
- if($this->isInstallation())
|
|
|
+ if($this->isInstallationMode())
|
|
|
{
|
|
|
- $statusCode = $this->processRequestInstallation($serverScheme, $serverName, $base, $location, $fileName);
|
|
|
+ $statusCode = $this->processRequestInstallationMode($serverScheme, $serverName, $base, $location, $fileName);
|
|
|
} else {
|
|
|
- $statusCode = $this->processRequestPending($serverScheme, $serverName, $base, $location, $fileName);
|
|
|
+ $statusCode = $this->processRequestInstallationPending($serverScheme, $serverName, $base, $location, $fileName);
|
|
|
}
|
|
|
return $statusCode;
|
|
|
}
|
|
@@ -37,8 +44,9 @@ class YellowUpdate
|
|
|
list($command) = $args;
|
|
|
switch($command)
|
|
|
{
|
|
|
+ case "clean": $statusCode = $this->cleanCommand($args); break;
|
|
|
case "update": $statusCode = $this->updateCommand($args); break;
|
|
|
- default: $statusCode = $this->updateCommandPending($args); break;
|
|
|
+ default: $statusCode = $this->processCommandInstallationPending($args); break;
|
|
|
}
|
|
|
return $statusCode;
|
|
|
}
|
|
@@ -49,11 +57,29 @@ class YellowUpdate
|
|
|
return "update [FEATURE]";
|
|
|
}
|
|
|
|
|
|
+ // Clean downloads
|
|
|
+ function cleanCommand($args)
|
|
|
+ {
|
|
|
+ $statusCode = 0;
|
|
|
+ list($command, $path) = $args;
|
|
|
+ if($path=="all")
|
|
|
+ {
|
|
|
+ $path = $this->yellow->config->get("pluginDir");
|
|
|
+ $regex = "/^.*\\".$this->yellow->config->get("downloadExtension")."$/";
|
|
|
+ foreach($this->yellow->toolbox->getDirectoryEntries($path, $regex, false, false) as $entry)
|
|
|
+ {
|
|
|
+ if(!$this->yellow->toolbox->deleteFile($entry)) $statusCode = 500;
|
|
|
+ }
|
|
|
+ if($statusCode==500) echo "ERROR cleaning downloads: Can't delete files in directory '$path'!\n";
|
|
|
+ }
|
|
|
+ return $statusCode;
|
|
|
+ }
|
|
|
+
|
|
|
// Update website
|
|
|
function updateCommand($args)
|
|
|
{
|
|
|
- list($command, $feature) = $args;
|
|
|
- list($statusCode, $data) = $this->getSoftwareUpdate($feature);
|
|
|
+ list($command, $feature, $option) = $args;
|
|
|
+ list($statusCode, $data) = $this->getSoftwareUpdates($feature);
|
|
|
if(!empty($data))
|
|
|
{
|
|
|
foreach($data as $key=>$value)
|
|
@@ -61,8 +87,8 @@ class YellowUpdate
|
|
|
list($version) = explode(',', $value);
|
|
|
echo "$key $version\n";
|
|
|
}
|
|
|
- if($statusCode==200) $statusCode = $this->download($data);
|
|
|
- if($statusCode==200) $statusCode = $this->update();
|
|
|
+ if($statusCode==200) $statusCode = $this->downloadSoftware($data);
|
|
|
+ if($statusCode==200) $statusCode = $this->updateSoftware($option);
|
|
|
if($statusCode!=200) echo "ERROR updating files: ".$this->yellow->page->get("pageError")."\n";
|
|
|
echo "Yellow $command: Website ".($statusCode!=200 ? "not " : "")."updated\n";
|
|
|
} else {
|
|
@@ -72,24 +98,8 @@ class YellowUpdate
|
|
|
return $statusCode;
|
|
|
}
|
|
|
|
|
|
- // Update pending software
|
|
|
- function updateCommandPending($args)
|
|
|
- {
|
|
|
- $statusCode = 0;
|
|
|
- if($this->isSoftwarePending())
|
|
|
- {
|
|
|
- $statusCode = $this->update();
|
|
|
- if($statusCode!=0)
|
|
|
- {
|
|
|
- if($statusCode!=200) echo "ERROR updating files: ".$this->yellow->page->get("pageError")."\n";
|
|
|
- echo "Yellow has ".($statusCode!=200 ? "not " : "")."been updated: Please run command again\n";
|
|
|
- }
|
|
|
- }
|
|
|
- return $statusCode;
|
|
|
- }
|
|
|
-
|
|
|
- // Download available software
|
|
|
- function download($data)
|
|
|
+ // Download software
|
|
|
+ function downloadSoftware($data)
|
|
|
{
|
|
|
$statusCode = 0;
|
|
|
$path = $this->yellow->config->get("pluginDir");
|
|
@@ -121,85 +131,82 @@ class YellowUpdate
|
|
|
return $statusCode;
|
|
|
}
|
|
|
|
|
|
- // Update downloaded software
|
|
|
- function update()
|
|
|
+ // Update software
|
|
|
+ function updateSoftware($option = "")
|
|
|
{
|
|
|
$statusCode = 0;
|
|
|
- foreach($this->yellow->plugins->plugins as $key=>$value)
|
|
|
+ $path = $this->yellow->config->get("pluginDir");
|
|
|
+ foreach($this->yellow->toolbox->getDirectoryEntries($path, "/^.*\.zip$/", true, false) as $entry)
|
|
|
{
|
|
|
- if(method_exists($value["obj"], "onUpdate"))
|
|
|
- {
|
|
|
- $statusCode = $value["obj"]->onUpdate($this->yellow->getRequestHandler());
|
|
|
- if($statusCode!=0) break;
|
|
|
- }
|
|
|
+ $statusCode = max($statusCode, $this->updateSoftwareArchive($entry, $option));
|
|
|
}
|
|
|
- if($statusCode==0)
|
|
|
+ $path = $this->yellow->config->get("themeDir");
|
|
|
+ foreach($this->yellow->toolbox->getDirectoryEntries($path, "/^.*\.zip$/", true, false) as $entry)
|
|
|
{
|
|
|
- $path = $this->yellow->config->get("pluginDir");
|
|
|
- foreach($this->yellow->toolbox->getDirectoryEntries($path, "/^.*\.zip$/", true, false) as $entry)
|
|
|
- {
|
|
|
- if(defined("DEBUG") && DEBUG>=2) echo "YellowUpdate::update file:$entry<br/>\n";
|
|
|
- $statusCode = max($statusCode, $this->updateSoftwareArchive($entry));
|
|
|
- }
|
|
|
- $path = $this->yellow->config->get("themeDir");
|
|
|
- foreach($this->yellow->toolbox->getDirectoryEntries($path, "/^.*\.zip$/", true, false) as $entry)
|
|
|
- {
|
|
|
- if(defined("DEBUG") && DEBUG>=2) echo "YellowUpdate::update file:$entry<br/>\n";
|
|
|
- $statusCode = max($statusCode, $this->updateSoftwareArchive($entry));
|
|
|
- }
|
|
|
+ $statusCode = max($statusCode, $this->updateSoftwareArchive($entry, $option));
|
|
|
}
|
|
|
return $statusCode;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// Update software from archive
|
|
|
- function updateSoftwareArchive($path)
|
|
|
+ function updateSoftwareArchive($path, $option = "")
|
|
|
{
|
|
|
$statusCode = 0;
|
|
|
$zip = new ZipArchive();
|
|
|
if($zip->open($path)===true)
|
|
|
{
|
|
|
- $fileNameInformation = $this->yellow->config->get("updateInformationFile");
|
|
|
- for($i=0; $i<$zip->numFiles; ++$i)
|
|
|
+ if(defined("DEBUG") && DEBUG>=2) echo "YellowUpdate::updateSoftwareArchive file:$path<br/>\n";
|
|
|
+ if(strtoloweru($option)=="force") $force = true;
|
|
|
+ if(preg_match("#^(.*\/).*?$#", $zip->getNameIndex(0), $matches)) $pathBase = $matches[1];
|
|
|
+ $fileData = $zip->getFromName($pathBase.$this->yellow->config->get("updateInformationFile"));
|
|
|
+ foreach($this->yellow->toolbox->getTextLines($fileData) as $line)
|
|
|
{
|
|
|
- $fileName = $zip->getNameIndex($i);
|
|
|
- if(empty($pathBase))
|
|
|
- {
|
|
|
- preg_match("#^(.*\/).*?$#", $fileName, $matches);
|
|
|
- $pathBase = $matches[1];
|
|
|
- }
|
|
|
- if($fileName==$pathBase.$fileNameInformation)
|
|
|
+ preg_match("/^\s*(.*?)\s*:\s*(.*?)\s*$/", $line, $matches);
|
|
|
+ if(!empty($matches[1]) && !empty($matches[2]))
|
|
|
{
|
|
|
- $fileData = $zip->getFromIndex($i);
|
|
|
- break;
|
|
|
+ if(is_file($matches[1])) { $lastPublished = filemtime($matches[1]); break; }
|
|
|
}
|
|
|
}
|
|
|
foreach($this->yellow->toolbox->getTextLines($fileData) as $line)
|
|
|
{
|
|
|
- if(preg_match("/^\#/", $line)) continue;
|
|
|
preg_match("/^\s*(.*?)\s*:\s*(.*?)\s*$/", $line, $matches);
|
|
|
if(lcfirst($matches[1])=="plugin" || lcfirst($matches[1])=="theme") $software = $matches[2];
|
|
|
+ if(lcfirst($matches[1])=="published") $modified = strtotime($matches[2]);
|
|
|
if(!empty($software) && !empty($matches[1]) && !empty($matches[2]))
|
|
|
{
|
|
|
- list($fileName, $flags) = explode(',', $matches[2], 2);
|
|
|
- $fileData = $zip->getFromName($pathBase.$fileName);
|
|
|
- $metaData = $zip->statName($pathBase.$fileName);
|
|
|
- $modified = $metaData ? $metaData["mtime"] : 0;
|
|
|
- $statusCode = $this->updateSoftwareFile($matches[1], $fileData, $modified, $flags, $software);
|
|
|
+ list($entry, $flags) = explode(',', $matches[2], 2);
|
|
|
+ $fileName = $matches[1];
|
|
|
+ $fileData = $zip->getFromName($pathBase.$entry);
|
|
|
+ $lastModified = $this->yellow->toolbox->getFileModified($fileName);
|
|
|
+ $statusCode = $this->updateSoftwareFile($fileName, $fileData, $modified, $lastModified, $lastPublished, $flags, $force, $software);
|
|
|
if($statusCode!=200) break;
|
|
|
}
|
|
|
}
|
|
|
$zip->close();
|
|
|
- if($statusCode==200 && !$this->yellow->toolbox->deleteFile($path))
|
|
|
+ if($statusCode==200)
|
|
|
{
|
|
|
- $statusCode = 500;
|
|
|
- $this->yellow->page->error($statusCode, "Can't delete file '$path'!");
|
|
|
+ $updateNotification = $this->yellow->config->get("updateNotification");
|
|
|
+ if($updateNotification=="none") $updateNotification = "";
|
|
|
+ if(!empty($updateNotification)) $updateNotification .= ",";
|
|
|
+ $updateNotification .= $software;
|
|
|
+ $fileNameConfig = $this->yellow->config->get("configDir").$this->yellow->config->get("configFile");
|
|
|
+ if(!$this->yellow->config->update($fileNameConfig, array("updateNotification" => $updateNotification)))
|
|
|
+ {
|
|
|
+ $statusCode = 500;
|
|
|
+ $this->yellow->page->error(500, "Can't write file '$fileNameConfig'!");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ if(!$this->yellow->toolbox->deleteFile($path))
|
|
|
+ {
|
|
|
+ $statusCode = 500;
|
|
|
+ $this->yellow->page->error($statusCode, "Can't delete file '$path'!");
|
|
|
+ }
|
|
|
return $statusCode;
|
|
|
}
|
|
|
|
|
|
// Update software file
|
|
|
- function updateSoftwareFile($fileName, $fileData, $modified, $flags, $software)
|
|
|
+ function updateSoftwareFile($fileName, $fileData, $modified, $lastModified, $lastPublished, $flags, $force, $software)
|
|
|
{
|
|
|
$statusCode = 200;
|
|
|
$fileName = $this->yellow->toolbox->normaliseTokens($fileName);
|
|
@@ -209,7 +216,8 @@ class YellowUpdate
|
|
|
if(preg_match("/create/i", $flags) && !is_file($fileName) && !empty($fileData)) $create = true;
|
|
|
if(preg_match("/update/i", $flags) && is_file($fileName) && !empty($fileData)) $update = true;
|
|
|
if(preg_match("/delete/i", $flags) && is_file($fileName)) $delete = true;
|
|
|
- if(preg_match("/optional/i", $flags) && $this->isSoftware($software)) $create = $update = $delete = false;
|
|
|
+ if(preg_match("/careful/i", $flags) && is_file($fileName) && $lastModified!=$lastPublished && !$force) $update = false;
|
|
|
+ if(preg_match("/optional/i", $flags) && $this->isSoftwareExisting($software)) $create = $update = $delete = false;
|
|
|
if($create)
|
|
|
{
|
|
|
if(!$this->yellow->toolbox->createFile($fileName, $fileData, true) ||
|
|
@@ -237,41 +245,77 @@ class YellowUpdate
|
|
|
$this->yellow->page->error($statusCode, "Can't delete file '$fileName'!");
|
|
|
}
|
|
|
}
|
|
|
- if(defined("DEBUG") && DEBUG>=3) echo "YellowUpdate::updateSoftwareFile file:$fileName flags:$flags<br/>\n";
|
|
|
+ if(defined("DEBUG") && DEBUG>=2)
|
|
|
+ {
|
|
|
+ $debug = "action:".($create ? "create" : "").($update ? "update" : "").($delete ? "delete" : "");
|
|
|
+ if(!$create && !$update && !$delete) $debug = "action:none";
|
|
|
+ echo "YellowUpdate::updateSoftwareFile file:$fileName $debug<br/>\n";
|
|
|
+ }
|
|
|
}
|
|
|
return $statusCode;
|
|
|
}
|
|
|
|
|
|
- // Update installation files
|
|
|
- function updateInstallation($feature)
|
|
|
+ // Update software features
|
|
|
+ function updateSoftwareFeatures($feature)
|
|
|
{
|
|
|
- $ok = true;
|
|
|
+ $statusCode = 200;
|
|
|
$path = $this->yellow->config->get("pluginDir");
|
|
|
- $regex = "/^.*\\".$this->yellow->config->get("downloadExtension")."$/";
|
|
|
+ $regex = "/^.*\\".$this->yellow->config->get("installationExtension")."$/";
|
|
|
foreach($this->yellow->toolbox->getDirectoryEntries($path, $regex, true, false) as $entry)
|
|
|
{
|
|
|
if(stristr(basename($entry), $feature))
|
|
|
{
|
|
|
- if($this->updateSoftwareArchive($entry)!=200) $ok = false;
|
|
|
+ $statusCode = max($statusCode, $this->updateSoftwareArchive($entry));
|
|
|
}
|
|
|
}
|
|
|
- if($ok)
|
|
|
+ if($statusCode==200)
|
|
|
{
|
|
|
foreach($this->yellow->toolbox->getDirectoryEntries($path, $regex, true, false) as $entry)
|
|
|
{
|
|
|
$this->yellow->toolbox->deleteFile($entry);
|
|
|
}
|
|
|
}
|
|
|
- return $ok;
|
|
|
+ return $statusCode;
|
|
|
+ }
|
|
|
+
|
|
|
+ // Process update notification for recently installed software
|
|
|
+ function processUpdateNotification()
|
|
|
+ {
|
|
|
+ if($this->yellow->config->get("updateNotification")!="none")
|
|
|
+ {
|
|
|
+ $tokens = explode(',', $this->yellow->config->get("updateNotification"));
|
|
|
+ foreach($this->yellow->plugins->plugins as $key=>$value)
|
|
|
+ {
|
|
|
+ if(in_array($value["plugin"], $tokens) && method_exists($value["obj"], "onUpdate")) $value["obj"]->onUpdate($key);
|
|
|
+ }
|
|
|
+ $fileNameConfig = $this->yellow->config->get("configDir").$this->yellow->config->get("configFile");
|
|
|
+ $this->yellow->config->update($fileNameConfig, array("updateNotification" => "none"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // Process command to install pending software
|
|
|
+ function processCommandInstallationPending($args)
|
|
|
+ {
|
|
|
+ $statusCode = 0;
|
|
|
+ if($this->isSoftwarePending())
|
|
|
+ {
|
|
|
+ $statusCode = $this->updateSoftware();
|
|
|
+ if($statusCode!=0)
|
|
|
+ {
|
|
|
+ if($statusCode!=200) echo "ERROR updating files: ".$this->yellow->page->get("pageError")."\n";
|
|
|
+ echo "Yellow has ".($statusCode!=200 ? "not " : "")."been updated: Please run command again\n";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return $statusCode;
|
|
|
}
|
|
|
|
|
|
// Process request to install pending software
|
|
|
- function processRequestPending($serverScheme, $serverName, $base, $location, $fileName)
|
|
|
+ function processRequestInstallationPending($serverScheme, $serverName, $base, $location, $fileName)
|
|
|
{
|
|
|
$statusCode = 0;
|
|
|
- if($this->isContentFile($fileName) && $this->isSoftwarePending())
|
|
|
+ if($this->yellow->lookup->isContentFile($fileName) && $this->isSoftwarePending())
|
|
|
{
|
|
|
- $statusCode = $this->update();
|
|
|
+ $statusCode = $this->updateSoftware();
|
|
|
if($statusCode==200)
|
|
|
{
|
|
|
$statusCode = 303;
|
|
@@ -283,15 +327,15 @@ class YellowUpdate
|
|
|
}
|
|
|
|
|
|
// Process request to install website
|
|
|
- function processRequestInstallation($serverScheme, $serverName, $base, $location, $fileName)
|
|
|
+ function processRequestInstallationMode($serverScheme, $serverName, $base, $location, $fileName)
|
|
|
{
|
|
|
$statusCode = 0;
|
|
|
- if($this->isContentFile($fileName) && $this->isInstallation())
|
|
|
+ if($this->yellow->lookup->isContentFile($fileName) && $this->isInstallationMode())
|
|
|
{
|
|
|
$this->yellow->pages->pages["root/"] = array();
|
|
|
$this->yellow->page = new YellowPage($this->yellow);
|
|
|
$this->yellow->page->setRequestInformation($serverScheme, $serverName, $base, $location, $fileName);
|
|
|
- $this->yellow->page->parseData($this->getRawDataInstallation($this->yellow->getRequestLanguage()), false, 404);
|
|
|
+ $this->yellow->page->parseData($this->getRawDataInstallation(), false, 404);
|
|
|
$this->yellow->page->parserSafeMode = false;
|
|
|
$this->yellow->page->parseContent();
|
|
|
$name = trim(preg_replace("/[^\pL\d\-\. ]/u", "-", $_REQUEST["name"]));
|
|
@@ -324,7 +368,7 @@ class YellowUpdate
|
|
|
{
|
|
|
if(!empty($feature))
|
|
|
{
|
|
|
- $status = $this->updateInstallation($feature) ? "ok" : "error";
|
|
|
+ $status = $this->updateSoftwareFeatures($feature)==200 ? "ok" : "error";
|
|
|
if($status=="error") $this->yellow->page->error(500, "Can't install feature '$feature'!");
|
|
|
}
|
|
|
}
|
|
@@ -348,8 +392,9 @@ class YellowUpdate
|
|
|
}
|
|
|
|
|
|
// Return raw data for installation page
|
|
|
- function getRawDataInstallation($language)
|
|
|
+ function getRawDataInstallation()
|
|
|
{
|
|
|
+ $language = $this->yellow->toolbox->detectBrowserLanguage($this->yellow->text->getLanguages(), $this->yellow->config->get("language"));
|
|
|
$fileName = strreplaceu("(.*)", "installation", $this->yellow->config->get("configDir").$this->yellow->config->get("webinterfaceNewFile"));
|
|
|
$rawData = $this->yellow->toolbox->readFile($fileName);
|
|
|
if(empty($rawData))
|
|
@@ -370,10 +415,10 @@ class YellowUpdate
|
|
|
}
|
|
|
$rawData .= "</p>\n";
|
|
|
}
|
|
|
- if(count($this->getFeatures())>1)
|
|
|
+ if(count($this->getSoftwareFeatures())>1)
|
|
|
{
|
|
|
$rawData .= "<p>".$this->yellow->text->get("webinterfaceInstallationFeature")."<p>";
|
|
|
- foreach($this->getFeatures() as $feature)
|
|
|
+ foreach($this->getSoftwareFeatures() as $feature)
|
|
|
{
|
|
|
$checked = $feature=="website" ? " checked=\"checked\"" : "";
|
|
|
$rawData .= "<label for=\"$feature\"><input type=\"radio\" name=\"feature\" id=\"$feature\" value=\"$feature\"$checked> ".ucfirst($feature)."</label><br />";
|
|
@@ -394,7 +439,7 @@ class YellowUpdate
|
|
|
return $rawData;
|
|
|
}
|
|
|
|
|
|
- // Return configuration data for installation
|
|
|
+ // Return configuration data
|
|
|
function getConfigData()
|
|
|
{
|
|
|
$data = array();
|
|
@@ -411,12 +456,12 @@ class YellowUpdate
|
|
|
return $data;
|
|
|
}
|
|
|
|
|
|
- // Return installation features
|
|
|
- function getFeatures()
|
|
|
+ // Return software features
|
|
|
+ function getSoftwareFeatures()
|
|
|
{
|
|
|
$data = array("website");
|
|
|
$path = $this->yellow->config->get("pluginDir");
|
|
|
- $regex = "/^.*\\".$this->yellow->config->get("downloadExtension")."$/";
|
|
|
+ $regex = "/^.*\\".$this->yellow->config->get("installationExtension")."$/";
|
|
|
foreach($this->yellow->toolbox->getDirectoryEntries($path, $regex, true, false, false) as $entry)
|
|
|
{
|
|
|
if(preg_match("/^(.*?)-(.*?)\./", $entry, $matches))
|
|
@@ -427,8 +472,8 @@ class YellowUpdate
|
|
|
return $data;
|
|
|
}
|
|
|
|
|
|
- // Return software update
|
|
|
- function getSoftwareUpdate($feature)
|
|
|
+ // Return software updates
|
|
|
+ function getSoftwareUpdates($feature)
|
|
|
{
|
|
|
$data = array();
|
|
|
list($statusCode, $dataCurrent) = $this->getSoftwareVersion();
|
|
@@ -471,8 +516,7 @@ class YellowUpdate
|
|
|
}
|
|
|
} else {
|
|
|
$statusCode = 200;
|
|
|
- foreach($this->yellow->plugins->getData() as $key=>$value) $data[$key] = $value;
|
|
|
- foreach($this->yellow->themes->getData() as $key=>$value) $data[$key] = $value;
|
|
|
+ $data = array_merge($this->yellow->plugins->getData(), $this->yellow->themes->getData());
|
|
|
}
|
|
|
return array($statusCode, $data);
|
|
|
}
|
|
@@ -500,9 +544,10 @@ class YellowUpdate
|
|
|
{
|
|
|
$fileData = $rawData;
|
|
|
} else if($statusCode==0) {
|
|
|
- $statusCode = 444;
|
|
|
- $this->yellow->page->error($statusCode, "No response from server!");
|
|
|
+ $statusCode = 500;
|
|
|
+ $this->yellow->page->error($statusCode, "Can't connect to server!");
|
|
|
} else {
|
|
|
+ $statusCode = 500;
|
|
|
$this->yellow->page->error($statusCode, "Can't download file '$url'!");
|
|
|
}
|
|
|
if(defined("DEBUG") && DEBUG>=3) echo "YellowUpdate::getSoftwareFile status:$statusCode url:$url<br/>\n";
|
|
@@ -513,14 +558,7 @@ class YellowUpdate
|
|
|
return array($statusCode, $fileData);
|
|
|
}
|
|
|
|
|
|
- // Check if software exists
|
|
|
- function isSoftware($software)
|
|
|
- {
|
|
|
- $data = $this->yellow->plugins->getData();
|
|
|
- return !is_null($data[$software]);
|
|
|
- }
|
|
|
-
|
|
|
- // Check if pending software exists
|
|
|
+ // Check if software installation is pending
|
|
|
function isSoftwarePending()
|
|
|
{
|
|
|
$path = $this->yellow->config->get("pluginDir");
|
|
@@ -529,18 +567,18 @@ class YellowUpdate
|
|
|
$foundThemes = count($this->yellow->toolbox->getDirectoryEntries($path, "/^.*\.zip$/", true, false))>0;
|
|
|
return $foundPlugins || $foundThemes;
|
|
|
}
|
|
|
-
|
|
|
- // Check if installation requested
|
|
|
- function isInstallation()
|
|
|
+
|
|
|
+ // Check if software exists
|
|
|
+ function isSoftwareExisting($software)
|
|
|
{
|
|
|
- return $this->yellow->config->get("installationMode") && PHP_SAPI!="cli";
|
|
|
+ $data = array_merge($this->yellow->plugins->getData(), $this->yellow->themes->getData());
|
|
|
+ return !is_null($data[$software]);
|
|
|
}
|
|
|
|
|
|
- // Check if content file
|
|
|
- function isContentFile($fileName)
|
|
|
+ // Check if installation mode
|
|
|
+ function isInstallationMode()
|
|
|
{
|
|
|
- $contentDirLength = strlenu($this->yellow->config->get("contentDir"));
|
|
|
- return substru($fileName, 0, $contentDirLength)==$this->yellow->config->get("contentDir");
|
|
|
+ return $this->yellow->config->get("installationMode") && PHP_SAPI!="cli";
|
|
|
}
|
|
|
}
|
|
|
|