Sfoglia il codice sorgente

System update (file format)

markseu 8 anni fa
parent
commit
9680bae476
2 ha cambiato i file con 38 aggiunte e 25 eliminazioni
  1. 1 1
      system/config/config.ini
  2. 37 24
      system/plugins/update.php

+ 1 - 1
system/config/config.ini

@@ -52,8 +52,8 @@ MultiLanguageMode: 0
 InstallationMode: 1
 InstallationMode: 1
 UpdatePluginsUrl: https://github.com/datenstrom/yellow-plugins
 UpdatePluginsUrl: https://github.com/datenstrom/yellow-plugins
 UpdateThemesUrl: https://github.com/datenstrom/yellow-themes
 UpdateThemesUrl: https://github.com/datenstrom/yellow-themes
-UpdateVersionFile: version.ini
 UpdateInformationFile: update.ini
 UpdateInformationFile: update.ini
+UpdateVersionFile: version.ini
 UpdateNotification: none
 UpdateNotification: none
 WebinterfaceLocation: /edit/
 WebinterfaceLocation: /edit/
 WebinterfaceNewFile: page-new-(.*).txt
 WebinterfaceNewFile: page-new-(.*).txt

+ 37 - 24
system/plugins/update.php

@@ -5,7 +5,7 @@
 // Update plugin
 // Update plugin
 class YellowUpdate
 class YellowUpdate
 {
 {
-	const VERSION = "0.6.11";
+	const VERSION = "0.6.12";
 	var $yellow;					//access to API
 	var $yellow;					//access to API
 	
 	
 	// Handle initialisation
 	// Handle initialisation
@@ -14,8 +14,8 @@ class YellowUpdate
 		$this->yellow = $yellow;
 		$this->yellow = $yellow;
 		$this->yellow->config->setDefault("updatePluginsUrl", "https://github.com/datenstrom/yellow-plugins");
 		$this->yellow->config->setDefault("updatePluginsUrl", "https://github.com/datenstrom/yellow-plugins");
 		$this->yellow->config->setDefault("updateThemesUrl", "https://github.com/datenstrom/yellow-themes");
 		$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("updateInformationFile", "update.ini");
+		$this->yellow->config->setDefault("updateVersionFile", "version.ini");
 		$this->yellow->config->setDefault("updateNotification", "none");
 		$this->yellow->config->setDefault("updateNotification", "none");
 	}
 	}
 	
 	
@@ -164,7 +164,10 @@ class YellowUpdate
 				preg_match("/^\s*(.*?)\s*:\s*(.*?)\s*$/", $line, $matches);
 				preg_match("/^\s*(.*?)\s*:\s*(.*?)\s*$/", $line, $matches);
 				if(!empty($matches[1]) && !empty($matches[2]))
 				if(!empty($matches[1]) && !empty($matches[2]))
 				{
 				{
-					if(is_file($matches[1])) { $lastPublished = filemtime($matches[1]); break; }
+					list($dummy, $entry) = explode('/', $matches[1], 2);
+					list($fileName, $flags) = explode(',', $matches[2], 2);
+					if($dummy[0]!='Y') $fileName = $matches[1]; //TODO: remove later, converts old file format
+					if(is_file($fileName)) { $lastPublished = filemtime($fileName); break; }
 				}
 				}
 			}
 			}
 			foreach($this->yellow->toolbox->getTextLines($fileData) as $line)
 			foreach($this->yellow->toolbox->getTextLines($fileData) as $line)
@@ -172,10 +175,15 @@ class YellowUpdate
 				preg_match("/^\s*(.*?)\s*:\s*(.*?)\s*$/", $line, $matches);
 				preg_match("/^\s*(.*?)\s*:\s*(.*?)\s*$/", $line, $matches);
 				if(lcfirst($matches[1])=="plugin" || lcfirst($matches[1])=="theme") $software = $matches[2];
 				if(lcfirst($matches[1])=="plugin" || lcfirst($matches[1])=="theme") $software = $matches[2];
 				if(lcfirst($matches[1])=="published") $modified = strtotime($matches[2]);
 				if(lcfirst($matches[1])=="published") $modified = strtotime($matches[2]);
-				if(!empty($software) && !empty($matches[1]) && !empty($matches[2]))
+				if(!empty($matches[1]) && !empty($matches[2]) && strposu($matches[1], '/'))
 				{
 				{
-					list($entry, $flags) = explode(',', $matches[2], 2);
-					$fileName = $matches[1];
+					list($dummy, $entry) = explode('/', $matches[1], 2);
+					list($fileName, $flags) = explode(',', $matches[2], 2);
+					if($dummy[0]!='Y') //TODO: remove later, converts old file format
+					{
+						list($entry, $flags) = explode(',', $matches[2], 2);
+						$fileName = $matches[1];
+					}
 					$fileData = $zip->getFromName($pathBase.$entry);
 					$fileData = $zip->getFromName($pathBase.$entry);
 					$lastModified = $this->yellow->toolbox->getFileModified($fileName);
 					$lastModified = $this->yellow->toolbox->getFileModified($fileName);
 					$statusCode = $this->updateSoftwareFile($fileName, $fileData, $modified, $lastModified, $lastPublished, $flags, $force, $software);
 					$statusCode = $this->updateSoftwareFile($fileName, $fileData, $modified, $lastModified, $lastPublished, $flags, $force, $software);
@@ -183,19 +191,7 @@ class YellowUpdate
 				}
 				}
 			}
 			}
 			$zip->close();
 			$zip->close();
-			if($statusCode==200)
-			{
-				$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($statusCode==200) $statusCode = $this->updateStartupNotification($software);
 		}
 		}
 		if(!$this->yellow->toolbox->deleteFile($path))
 		if(!$this->yellow->toolbox->deleteFile($path))
 		{
 		{
@@ -210,7 +206,7 @@ class YellowUpdate
 	{
 	{
 		$statusCode = 200;
 		$statusCode = 200;
 		$fileName = $this->yellow->toolbox->normaliseTokens($fileName);
 		$fileName = $this->yellow->toolbox->normaliseTokens($fileName);
-		if($this->yellow->lookup->isValidFile($fileName) && !empty($flags))
+		if($this->yellow->lookup->isValidFile($fileName) && !empty($software))
 		{
 		{
 			$create = $update = $delete = false;
 			$create = $update = $delete = false;
 			if(preg_match("/create/i", $flags) && !is_file($fileName) && !empty($fileData)) $create = true;
 			if(preg_match("/create/i", $flags) && !is_file($fileName) && !empty($fileData)) $create = true;
@@ -255,6 +251,23 @@ class YellowUpdate
 		return $statusCode;
 		return $statusCode;
 	}
 	}
 	
 	
+	// Update startup notification
+	function updateStartupNotification($software)
+	{
+		$statusCode = 200;
+		$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'!");
+		}
+		return $statusCode;
+	}
+	
 	// Update software features
 	// Update software features
 	function updateSoftwareFeatures($feature)
 	function updateSoftwareFeatures($feature)
 	{
 	{
@@ -499,8 +512,8 @@ class YellowUpdate
 		{
 		{
 			$urlPlugins = $this->yellow->config->get("updatePluginsUrl")."/raw/master/".$this->yellow->config->get("updateVersionFile");
 			$urlPlugins = $this->yellow->config->get("updatePluginsUrl")."/raw/master/".$this->yellow->config->get("updateVersionFile");
 			$urlThemes = $this->yellow->config->get("updateThemesUrl")."/raw/master/".$this->yellow->config->get("updateVersionFile");
 			$urlThemes = $this->yellow->config->get("updateThemesUrl")."/raw/master/".$this->yellow->config->get("updateVersionFile");
-			list($statusCodePlugins, $fileDataPlugins) = $this->getSoftwareFile($urlPlugins, $rawFormat);
-			list($statusCodeThemes, $fileDataThemes) = $this->getSoftwareFile($urlThemes, $rawFormat);
+			list($statusCodePlugins, $fileDataPlugins) = $this->getSoftwareFile($urlPlugins);
+			list($statusCodeThemes, $fileDataThemes) = $this->getSoftwareFile($urlThemes);
 			$statusCode = max($statusCodePlugins, $statusCodeThemes);
 			$statusCode = max($statusCodePlugins, $statusCodeThemes);
 			if($statusCode==200)
 			if($statusCode==200)
 			{
 			{
@@ -550,7 +563,7 @@ class YellowUpdate
 				$statusCode = 500;
 				$statusCode = 500;
 				$this->yellow->page->error($statusCode, "Can't download file '$url'!");
 				$this->yellow->page->error($statusCode, "Can't download file '$url'!");
 			}
 			}
-			if(defined("DEBUG") && DEBUG>=3) echo "YellowUpdate::getSoftwareFile status:$statusCode url:$url<br/>\n";
+			if(defined("DEBUG") && DEBUG>=2) echo "YellowUpdate::getSoftwareFile status:$statusCode url:$url<br/>\n";
 		} else {
 		} else {
 			$statusCode = 500;
 			$statusCode = 500;
 			$this->yellow->page->error($statusCode, "Plugin 'update' requires cURL library!");
 			$this->yellow->page->error($statusCode, "Plugin 'update' requires cURL library!");
@@ -558,7 +571,7 @@ class YellowUpdate
 		return array($statusCode, $fileData);
 		return array($statusCode, $fileData);
 	}
 	}
 	
 	
-	// Check if software installation is pending
+	// Check if software pending
 	function isSoftwarePending()
 	function isSoftwarePending()
 	{
 	{
 		$path = $this->yellow->config->get("pluginDir");
 		$path = $this->yellow->config->get("pluginDir");