From 18e9d4be0081643138bae1c78d7d4d505ad0627b Mon Sep 17 00:00:00 2001 From: markseu Date: Thu, 6 Aug 2020 20:03:57 +0200 Subject: [PATCH] Improved website update, no more warnings for modified files --- system/extensions/command.php | 12 ++-- system/extensions/core.php | 71 ++++++++++++----------- system/extensions/edit.js | 8 ++- system/extensions/edit.php | 40 +++++-------- system/extensions/update.php | 104 ++++++++++------------------------ 5 files changed, 91 insertions(+), 144 deletions(-) diff --git a/system/extensions/command.php b/system/extensions/command.php index 7b43db2..23d8572 100644 --- a/system/extensions/command.php +++ b/system/extensions/command.php @@ -2,7 +2,7 @@ // Command extension, https://github.com/datenstrom/yellow-extensions/tree/master/source/command class YellowCommand { - const VERSION = "0.8.19"; + const VERSION = "0.8.20"; const PRIORITY = "3"; public $yellow; // access to API public $files; // number of files @@ -442,8 +442,8 @@ class YellowCommand { public function broadcastCommand($command, $text) { $statusCode = 0; foreach ($this->yellow->extension->data as $key=>$value) { - if (method_exists($value["obj"], "onCommand") && $key!="command") { - $statusCode = max($statusCode, $value["obj"]->onCommand($command, $text)); + if (method_exists($value["object"], "onCommand") && $key!="command") { + $statusCode = max($statusCode, $value["object"]->onCommand($command, $text)); } } return $statusCode; @@ -508,8 +508,8 @@ class YellowCommand { public function getCommandHelp() { $data = array(); foreach ($this->yellow->extension->data as $key=>$value) { - if (method_exists($value["obj"], "onCommandHelp")) { - foreach (preg_split("/[\r\n]+/", $value["obj"]->onCommandHelp()) as $line) { + if (method_exists($value["object"], "onCommandHelp")) { + foreach (preg_split("/[\r\n]+/", $value["object"]->onCommandHelp()) as $line) { list($command, $dummy) = $this->yellow->toolbox->getTextList($line, " ", 2); if (!empty($command) && !isset($data[$command])) $data[$command] = $line; } @@ -627,7 +627,7 @@ class YellowCommand { $curlHandle = curl_init(); curl_setopt($curlHandle, CURLOPT_URL, $url); curl_setopt($curlHandle, CURLOPT_REFERER, $referer); - curl_setopt($curlHandle, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; DatenstromYellow/".YellowCore::VERSION."; LinkChecker)"); + curl_setopt($curlHandle, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; YellowCommand/".YellowCommand::VERSION."; LinkChecker)"); curl_setopt($curlHandle, CURLOPT_NOBODY, 1); curl_setopt($curlHandle, CURLOPT_CONNECTTIMEOUT, 30); curl_exec($curlHandle); diff --git a/system/extensions/core.php b/system/extensions/core.php index f6515d3..bf4009d 100644 --- a/system/extensions/core.php +++ b/system/extensions/core.php @@ -2,7 +2,8 @@ // Core extension, https://github.com/datenstrom/yellow-extensions/tree/master/source/core class YellowCore { - const VERSION = "0.8.14"; + const VERSION = "0.8.15"; + const RELEASE = "2020.6"; public $page; // current page public $content; // content files public $media; // media files @@ -115,9 +116,9 @@ class YellowCore { list($scheme, $address, $base, $location, $fileName) = $this->getRequestInformation(); $this->page->setRequestInformation($scheme, $address, $base, $location, $fileName); foreach ($this->extension->data as $key=>$value) { - if (method_exists($value["obj"], "onRequest")) { + if (method_exists($value["object"], "onRequest")) { $this->lookup->requestHandler = $key; - $statusCode = $value["obj"]->onRequest($scheme, $address, $base, $location, $fileName); + $statusCode = $value["object"]->onRequest($scheme, $address, $base, $location, $fileName); if ($statusCode!=0) break; } } @@ -276,9 +277,9 @@ class YellowCore { $this->toolbox->timerStart($time); list($command, $text) = $this->getCommandInformation($line); foreach ($this->extension->data as $key=>$value) { - if (method_exists($value["obj"], "onCommand")) { + if (method_exists($value["object"], "onCommand")) { $this->lookup->commandHandler = $key; - $statusCode = $value["obj"]->onCommand($command, $text); + $statusCode = $value["object"]->onCommand($command, $text); if ($statusCode!=0) break; } } @@ -298,10 +299,10 @@ class YellowCore { public function startup() { if ($this->isLoaded()) { foreach ($this->extension->data as $key=>$value) { - if (method_exists($value["obj"], "onStartup")) $value["obj"]->onStartup(); + if (method_exists($value["object"], "onStartup")) $value["object"]->onStartup(); } foreach ($this->extension->data as $key=>$value) { - if (method_exists($value["obj"], "onUpdate")) $value["obj"]->onUpdate("startup"); + if (method_exists($value["object"], "onUpdate")) $value["object"]->onUpdate("startup"); } } } @@ -310,7 +311,7 @@ class YellowCore { public function shutdown() { if ($this->isLoaded()) { foreach ($this->extension->data as $key=>$value) { - if (method_exists($value["obj"], "onShutdown")) $value["obj"]->onShutdown(); + if (method_exists($value["object"], "onShutdown")) $value["object"]->onShutdown(); } } } @@ -319,8 +320,8 @@ class YellowCore { public function log($action, $message) { $statusCode = 0; foreach ($this->extension->data as $key=>$value) { - if (method_exists($value["obj"], "onLog")) { - $statusCode = $value["obj"]->onLog($action, $message); + if (method_exists($value["object"], "onLog")) { + $statusCode = $value["object"]->onLog($action, $message); if ($statusCode!=0) break; } } @@ -488,7 +489,7 @@ class YellowPage { } if (!empty($pageError)) $this->set("pageError", $pageError); foreach ($this->yellow->extension->data as $key=>$value) { - if (method_exists($value["obj"], "onParseMeta")) $value["obj"]->onParseMeta($this); + if (method_exists($value["object"], "onParseMeta")) $value["object"]->onParseMeta($this); } } @@ -516,16 +517,16 @@ class YellowPage { if (!is_object($this->parser)) { if ($this->yellow->extension->isExisting($this->get("parser"))) { $value = $this->yellow->extension->data[$this->get("parser")]; - if (method_exists($value["obj"], "onParseContentRaw")) { - $this->parser = $value["obj"]; + if (method_exists($value["object"], "onParseContentRaw")) { + $this->parser = $value["object"]; $this->parserData = $this->getContent(true, $sizeMax); $this->parserData = preg_replace("/@pageRead/i", $this->get("pageRead"), $this->parserData); $this->parserData = preg_replace("/@pageEdit/i", $this->get("pageEdit"), $this->parserData); $this->parserData = $this->parser->onParseContentRaw($this, $this->parserData); $this->parserData = $this->yellow->toolbox->normaliseData($this->parserData, "html"); foreach ($this->yellow->extension->data as $key=>$value) { - if (method_exists($value["obj"], "onParseContentHtml")) { - $output = $value["obj"]->onParseContentHtml($this, $this->parserData); + if (method_exists($value["object"], "onParseContentHtml")) { + $output = $value["object"]->onParseContentHtml($this, $this->parserData); if (!is_null($output)) $this->parserData = $output; } } @@ -546,14 +547,21 @@ class YellowPage { public function parseContentShortcut($name, $text, $type) { $output = null; foreach ($this->yellow->extension->data as $key=>$value) { - if (method_exists($value["obj"], "onParseContentShortcut")) { - $output = $value["obj"]->onParseContentShortcut($this, $name, $text, $type); + if (method_exists($value["object"], "onParseContentShortcut")) { + $output = $value["object"]->onParseContentShortcut($this, $name, $text, $type); if (!is_null($output)) break; } } if (is_null($output)) { if ($name=="yellow" && $type=="inline") { - $output = "Datenstrom Yellow ".YellowCore::VERSION; + if ($text=="about") { + $output = "Datenstrom Yellow ".YellowCore::RELEASE."
\n"; + $dataCurrent = $this->yellow->extension->data; + uksort($dataCurrent, "strnatcasecmp"); + foreach ($dataCurrent as $key=>$value) { + $output .= ucfirst($key)." ".$value["version"]."
\n"; + } + } if ($text=="error") $output = $this->get("pageError"); if ($text=="log") { $fileName = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreLogFile"); @@ -605,8 +613,8 @@ class YellowPage { } if ($this->isExisting("pageClean")) $this->outputData = null; foreach ($this->yellow->extension->data as $key=>$value) { - if (method_exists($value["obj"], "onParsePageOutput")) { - $output = $value["obj"]->onParsePageOutput($this, $this->outputData); + if (method_exists($value["object"], "onParsePageOutput")) { + $output = $value["object"]->onParsePageOutput($this, $this->outputData); if (!is_null($output)) $this->outputData = $output; } } @@ -616,8 +624,8 @@ class YellowPage { public function parsePageLayout($name) { $this->outputData = null; foreach ($this->yellow->extension->data as $key=>$value) { - if (method_exists($value["obj"], "onParsePageLayout")) { - $value["obj"]->onParsePageLayout($this, $name); + if (method_exists($value["object"], "onParsePageLayout")) { + $value["object"]->onParsePageLayout($this, $name); } } if (is_null($this->outputData)) { @@ -809,8 +817,8 @@ class YellowPage { public function getExtra($name) { $output = ""; foreach ($this->yellow->extension->data as $key=>$value) { - if (method_exists($value["obj"], "onParsePageExtra")) { - $outputExtension = $value["obj"]->onParsePageExtra($this, $name); + if (method_exists($value["object"], "onParsePageExtra")) { + $outputExtension = $value["object"]->onParsePageExtra($this, $name); if (!is_null($outputExtension)) $output .= $outputExtension; } } @@ -2002,7 +2010,7 @@ class YellowExtension { }; uasort($this->data, $callback); foreach ($this->data as $key=>$value) { - if (method_exists($this->data[$key]["obj"], "onLoad")) $this->data[$key]["obj"]->onLoad($this->yellow); + if (method_exists($this->data[$key]["object"], "onLoad")) $this->data[$key]["object"]->onLoad($this->yellow); } $this->yellow->system->set("mediaLocation", "/media/"); // TODO: remove later, for backwards compatibility $this->yellow->system->set("downloadLocation", "/media/downloads/"); @@ -2043,7 +2051,7 @@ class YellowExtension { public function register($key, $class) { if (!$this->isExisting($key) && class_exists($class)) { $this->data[$key] = array(); - $this->data[$key]["obj"] = $class=="YellowCore" ? new stdClass : new $class; + $this->data[$key]["object"] = $class=="YellowCore" ? new stdClass : new $class; $this->data[$key]["class"] = $class; $this->data[$key]["version"] = defined("$class::VERSION") ? $class::VERSION : 0; $this->data[$key]["priority"] = defined("$class::PRIORITY") ? $class::PRIORITY : count($this->data) + 10; @@ -2052,16 +2060,7 @@ class YellowExtension { // Return extension public function get($key) { - return $this->data[$key]["obj"]; - } - - // Return extension - public function getExtensions() { - $extensions = array(); - foreach ($this->data as $key=>$value) { - array_push($extensions, $key); - } - return $extensions; + return $this->data[$key]["object"]; } // Return extensions modification date, Unix time or HTTP format diff --git a/system/extensions/edit.js b/system/extensions/edit.js index a752ceb..fafecaf 100644 --- a/system/extensions/edit.js +++ b/system/extensions/edit.js @@ -269,11 +269,11 @@ yellow.edit = { elementDiv.innerHTML = "
"+ ""+ - "

"+yellow.toolbox.encodeHtml(yellow.system.coreVersion)+"

"+ + "

"+yellow.toolbox.encodeHtml(yellow.system.coreProductRelease)+"

"+ "

"+this.getText("UpdateStatus", "", paneStatus)+"

"+ "
"+yellow.page.rawDataOutput+"
"+ ""+ "
"; break; @@ -395,7 +395,9 @@ yellow.edit = { setTimeout("yellow.action('submit', '', 'action:update/option:check/');", 500); } if (paneStatus=="updates") { - document.getElementById("yellow-pane-update-status").innerHTML = ""+this.getText("UpdateStatusUpdates")+""; + document.getElementById(paneId+"-submit").innerHTML = this.getText("UpdateButton"); + document.getElementById(paneId+"-submit").setAttribute("data-action", "submit"); + document.getElementById(paneId+"-submit").setAttribute("data-arguments", "action:update"); } break; case "yellow-pane-create": diff --git a/system/extensions/edit.php b/system/extensions/edit.php index f0c05e9..b00d9c5 100755 --- a/system/extensions/edit.php +++ b/system/extensions/edit.php @@ -670,18 +670,16 @@ class YellowEdit { if ($this->response->isUserAccess("update")) { $this->response->action = "update"; $this->response->status = "ok"; - $extension = trim($this->yellow->page->getRequest("extension")); - $option = trim($this->yellow->page->getRequest("option")); - if ($option=="check") { - list($statusCode, $updates, $rawData) = $this->response->getUpdateInformation(); - $this->response->status = $updates ? "updates" : "ok"; + if ($this->yellow->page->getRequest("option")=="check") { + list($statusCode, $rawData) = $this->response->getUpdateInformation(); + $this->response->status = empty($rawData) ? "ok" : "updates"; $this->response->rawDataOutput = $rawData; if ($statusCode!=200) { $this->response->status = "error"; $this->response->rawDataOutput = ""; } } else { - $this->response->status = $this->yellow->command("update $extension $option")==0 ? "done" : "error"; + $this->response->status = $this->yellow->command("update")==0 ? "done" : "error"; } if ($this->response->status=="done") { $location = $this->yellow->lookup->normaliseUrl($scheme, $address, $base, $location); @@ -943,8 +941,8 @@ class YellowEdit { public function getUserAccount($action, $email, $password) { $status = null; foreach ($this->yellow->extension->data as $key=>$value) { - if (method_exists($value["obj"], "onEditUserAccount")) { - $status = $value["obj"]->onEditUserAccount($action, $email, $password); + if (method_exists($value["object"], "onEditUserAccount")) { + $status = $value["object"]->onEditUserAccount($action, $email, $password); if (!is_null($status)) break; } } @@ -1189,7 +1187,7 @@ class YellowEditResponse { $data = array_merge($data, $this->yellow->system->getSettings("", "Location")); if ($this->isUser()) { $data["coreFileSizeMax"] = $this->yellow->toolbox->getNumberBytes(ini_get("upload_max_filesize")); - $data["coreVersion"] = "Datenstrom Yellow ".YellowCore::VERSION; + $data["coreProductRelease"] = "Datenstrom Yellow ".YellowCore::RELEASE; $data["coreExtensions"] = array(); foreach ($this->yellow->extension->data as $key=>$value) { $data["coreExtensions"][$key] = $value["class"]; @@ -1293,31 +1291,21 @@ class YellowEditResponse { // Return update information public function getUpdateInformation() { $statusCode = 200; - $updates = 0; $rawData = ""; if ($this->yellow->extension->isExisting("update")) { list($statusCodeCurrent, $dataCurrent) = $this->yellow->extension->get("update")->getExtensionsVersion(); list($statusCodeLatest, $dataLatest) = $this->yellow->extension->get("update")->getExtensionsVersion(true); - list($statusCodeModified, $dataModified) = $this->yellow->extension->get("update")->getExtensionsModified(); - $statusCode = max($statusCodeCurrent, $statusCodeLatest, $statusCodeModified); + $statusCode = max($statusCodeCurrent, $statusCodeLatest); foreach ($dataCurrent as $key=>$value) { if (isset($dataLatest[$key])) { if (strnatcasecmp($dataCurrent[$key], $dataLatest[$key])<0) { - $rawData .= htmlspecialchars(ucfirst($key)." $dataLatest[$key]")."
\n"; - ++$updates; - } - } - } - if ($updates==0) { - foreach ($dataCurrent as $key=>$value) { - if (isset($dataModified[$key]) && isset($dataLatest[$key])) { - $output = $this->yellow->language->getTextHtml("editUpdateModified", $this->language)." - yellow->toolbox->normaliseArguments("action:update/extension:$key/option:force")."\">".$this->yellow->language->getTextHtml("editUpdateForce", $this->language)."
\n"; - $rawData .= preg_replace("/@extension/i", htmlspecialchars(ucfirst($key)." $dataLatest[$key]"), $output); + $rawData .= htmlspecialchars(ucfirst($key)." $dataLatest[$key]")."
"; } } } + if (!empty($rawData)) $rawData = "

$rawData

\n"; } - return array($statusCode, $updates, $rawData); + return array($statusCode, $rawData); } // Return raw data for generated page @@ -1653,7 +1641,7 @@ class YellowEditResponse { public function editContentFile($page, $action, $email) { if (!$page->isError()) { foreach ($this->yellow->extension->data as $key=>$value) { - if (method_exists($value["obj"], "onEditContentFile")) $value["obj"]->onEditContentFile($page, $action, $email); + if (method_exists($value["object"], "onEditContentFile")) $value["object"]->onEditContentFile($page, $action, $email); } } } @@ -1662,7 +1650,7 @@ class YellowEditResponse { public function editMediaFile($file, $action, $email) { if (!$file->isError()) { foreach ($this->yellow->extension->data as $key=>$value) { - if (method_exists($value["obj"], "onEditMediaFile")) $value["obj"]->onEditMediaFile($file, $action, $email); + if (method_exists($value["object"], "onEditMediaFile")) $value["object"]->onEditMediaFile($file, $action, $email); } } } @@ -1671,7 +1659,7 @@ class YellowEditResponse { public function editSystemFile($file, $action, $email) { if (!$file->isError()) { foreach ($this->yellow->extension->data as $key=>$value) { - if (method_exists($value["obj"], "onEditSystemFile")) $value["obj"]->onEditSystemFile($file, $action, $email); + if (method_exists($value["object"], "onEditSystemFile")) $value["object"]->onEditSystemFile($file, $action, $email); } } } diff --git a/system/extensions/update.php b/system/extensions/update.php index 5a12ae2..44cf4fa 100644 --- a/system/extensions/update.php +++ b/system/extensions/update.php @@ -2,7 +2,7 @@ // Update extension, https://github.com/datenstrom/yellow-extensions/tree/master/source/update class YellowUpdate { - const VERSION = "0.8.27"; + const VERSION = "0.8.28"; const PRIORITY = "2"; public $yellow; // access to API public $updates; // number of updates @@ -202,7 +202,7 @@ class YellowUpdate { list($extension, $action) = $this->yellow->toolbox->getTextList($token, "/", 2); if ($this->yellow->extension->isExisting($extension) && ($action!="startup" && $action!="uninstall")) { $value = $this->yellow->extension->data[$extension]; - if (method_exists($value["obj"], "onUpdate")) $value["obj"]->onUpdate($action); + if (method_exists($value["object"], "onUpdate")) $value["object"]->onUpdate($action); } } $fileName = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("coreSystemFile"); @@ -291,7 +291,7 @@ class YellowUpdate { // Process command to show website version and updates public function processCommandAbout($command, $text) { - echo "Datenstrom Yellow ".YellowCore::VERSION."\n"; + echo "Datenstrom Yellow ".YellowCore::RELEASE."\n"; list($statusCode, $dataCurrent) = $this->getExtensionsVersion(); list($statusCode, $dataLatest) = $this->getExtensionsVersion(true); foreach ($dataCurrent as $key=>$value) { @@ -321,7 +321,7 @@ class YellowUpdate { // Process command to install extensions public function processCommandInstall($command, $text) { - list($extensions) = $this->getExtensionInformation($text); + $extensions = $this->getExtensions($text); if (!empty($extensions)) { $this->updates = 0; list($statusCode, $data) = $this->getInstallInformation($extensions); @@ -338,7 +338,7 @@ class YellowUpdate { // Process command to uninstall extensions public function processCommandUninstall($command, $text) { - list($extensions) = $this->getExtensionInformation($text); + $extensions = $this->getExtensions($text); if (!empty($extensions)) { $this->updates = 0; list($statusCode, $data) = $this->getUninstallInformation($extensions, "core, command, update"); @@ -351,15 +351,15 @@ class YellowUpdate { } return $statusCode; } - + // Process command to update website public function processCommandUpdate($command, $text) { - list($extensions, $force) = $this->getExtensionInformation($text); - list($statusCode, $data) = $this->getUpdateInformation($extensions, $force); + $extensions = $this->getExtensions($text); + list($statusCode, $data) = $this->getUpdateInformation($extensions); if ($statusCode!=200 || !empty($data)) { $this->updates = 0; if ($statusCode==200) $statusCode = $this->downloadExtensions($data); - if ($statusCode==200) $statusCode = $this->updateExtensions("update", $force); + if ($statusCode==200) $statusCode = $this->updateExtensions("update"); if ($statusCode>=400) echo "ERROR updating files: ".$this->yellow->page->get("pageError")."\n"; echo "Yellow $command: Website ".($statusCode!=200 ? "not " : "")."updated"; echo ", $this->updates update".($this->updates!=1 ? "s" : "")." installed\n"; @@ -392,7 +392,7 @@ class YellowUpdate { $statusCode = 200; if ($this->yellow->extension->isExisting($extension) && $action=="uninstall") { $value = $this->yellow->extension->data[$extension]; - if (method_exists($value["obj"], "onUpdate")) $value["obj"]->onUpdate($action); + if (method_exists($value["object"], "onUpdate")) $value["object"]->onUpdate($action); } $updateNotification = $this->yellow->system->get("updateNotification"); if ($updateNotification=="none") $updateNotification = ""; @@ -406,17 +406,9 @@ class YellowUpdate { return $statusCode; } - // Return extension information - public function getExtensionInformation($text) { - $extensions = array_unique(array_filter($this->yellow->toolbox->getTextArguments($text), "strlen")); - $force = false; - foreach ($extensions as $key=>$value) { - if ($value=="force") { - $force = true; - unset($extensions[$key]); - } - } - return array($extensions, $force); + // Return extensions from text, space separated + public function getExtensions($text) { + return array_unique(array_filter($this->yellow->toolbox->getTextArguments($text), "strlen")); } // Return install information @@ -471,29 +463,28 @@ class YellowUpdate { } // Return update information - public function getUpdateInformation($extensions, $force) { + public function getUpdateInformation($extensions) { $data = array(); list($statusCodeCurrent, $dataCurrent) = $this->getExtensionsVersion(); list($statusCodeLatest, $dataLatest) = $this->getExtensionsVersion(true, true); - list($statusCodeModified, $dataModified) = $this->getExtensionsModified(); - $statusCode = max($statusCodeCurrent, $statusCodeLatest, $statusCodeModified); + $statusCode = max($statusCodeCurrent, $statusCodeLatest); if (empty($extensions)) { foreach ($dataCurrent as $key=>$value) { if (isset($dataLatest[$key])) { list($version, $dummy1, $dummy2) = $this->yellow->toolbox->getTextList($dataLatest[$key], ",", 3); if (strnatcasecmp($dataCurrent[$key], $version)<0) $data[$key] = $dataLatest[$key]; - if (isset($dataModified[$key]) && !empty($version) && $force) $data[$key] = $dataLatest[$key]; } } } else { + $force = false; foreach ($extensions as $extension) { $found = false; + if ($extension=="force") { $force = true; continue; } foreach ($dataCurrent as $key=>$value) { if (isset($dataLatest[$key])) { list($version, $dummy1, $dummy2) = $this->yellow->toolbox->getTextList($dataLatest[$key], ",", 3); - if (strtoloweru($key)==strtoloweru($extension) && !empty($version)) { + if (!empty($version) && strtoloweru($key)==strtoloweru($extension)) { $data[$key] = $dataLatest[$key]; - $dataModified = array_intersect_key($dataModified, $data); $found = true; break; } @@ -504,15 +495,15 @@ class YellowUpdate { $this->yellow->page->error($statusCode, "Can't find extension '$extension'!"); } } + if (!$force) { + $statusCode = 500; + $this->yellow->page->error($statusCode, "Please use 'force' to update an extension!"); + } } if ($statusCode==200) { - foreach (array_merge($dataModified, $data) as $key=>$value) { + foreach ($data as $key=>$value) { list($version, $dummy1, $dummy2) = $this->yellow->toolbox->getTextList($value, ",", 3); - if (!isset($dataModified[$key]) || $force) { - echo ucfirst($key)." $version\n"; - } else { - echo ucfirst($key)." $version has been modified - Force update\n"; - } + echo ucfirst($key)." $version\n"; } } return array($statusCode, $data); @@ -557,12 +548,12 @@ class YellowUpdate { } // Update extensions - public function updateExtensions($action, $force = false) { + public function updateExtensions($action) { $statusCode = 200; if (function_exists("opcache_reset")) opcache_reset(); $path = $this->yellow->system->get("coreExtensionDirectory"); foreach ($this->yellow->toolbox->getDirectoryEntries($path, "/^.*\.zip$/", true, false) as $entry) { - $statusCode = max($statusCode, $this->updateExtensionArchive($entry, $action, $force)); + $statusCode = max($statusCode, $this->updateExtensionArchive($entry, $action)); if (!$this->yellow->toolbox->deleteFile($entry)) { $statusCode = 500; $this->yellow->page->error($statusCode, "Can't delete file '$entry'!"); @@ -572,7 +563,7 @@ class YellowUpdate { } // Update extension from archive - public function updateExtensionArchive($path, $action, $force = false) { + public function updateExtensionArchive($path, $action) { $statusCode = 200; $zip = new ZipArchive(); if ($zip->open($path)===true) { @@ -609,7 +600,7 @@ class YellowUpdate { $fileData = $zip->getFromName($fileNameSource); $lastModified = $this->yellow->toolbox->getFileModified($fileNameDestination); $statusCode = $this->updateExtensionFile($fileNameDestination, $fileData, - $modified, $lastModified, $lastPublished, $flags, $force, $extension); + $modified, $lastModified, $lastPublished, $flags, $extension); } if ($statusCode!=200) break; } @@ -627,7 +618,7 @@ class YellowUpdate { } // Update extension from file - public function updateExtensionFile($fileName, $fileData, $modified, $lastModified, $lastPublished, $flags, $force, $extension) { + public function updateExtensionFile($fileName, $fileData, $modified, $lastModified, $lastPublished, $flags, $extension) { $statusCode = 200; $fileName = $this->yellow->toolbox->normaliseTokens($fileName); if ($this->yellow->lookup->isValidFile($fileName) && !empty($extension)) { @@ -636,7 +627,7 @@ class YellowUpdate { 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->yellow->extension->isExisting($extension)) $create = $update = $delete = false; - if (preg_match("/careful/i", $flags) && is_file($fileName) && $lastModified!=$lastPublished && !$force) $update = false; + if (preg_match("/careful/i", $flags) && is_file($fileName) && $lastModified!=$lastPublished) $update = false; if ($create) { if (!$this->yellow->toolbox->createFile($fileName, $fileData, true) || !$this->yellow->toolbox->modifyFile($fileName, $modified)) { @@ -772,46 +763,13 @@ class YellowUpdate { return array($statusCode, $data); } - // Return extensions modified files - public function getExtensionsModified() { - $data = array(); - $url = $this->yellow->system->get("updateExtensionUrl")."/raw/master/".$this->yellow->system->get("updateWaffleFile"); - list($statusCode, $dataCurrent) = $this->getExtensionsVersion(); - list($statusCode, $fileData) = $this->getExtensionFile($url); - if ($statusCode==200) { - $extension = ""; - $lastModified = $lastPublished = 0; - foreach ($this->yellow->toolbox->getTextLines($fileData) as $line) { - preg_match("/^\s*(.*?)\s*:\s*(.*?)\s*$/", $line, $matches); - if (!empty($matches[1]) && !empty($matches[2])) { - $fileName = $matches[1]; - list($extensionNew, $dummy, $flags) = $this->yellow->toolbox->getTextList(lcfirst($matches[2]), ",", 3); - if ($extension!=$extensionNew) { - $extension = $extensionNew; - $lastPublished = $this->yellow->toolbox->getFileModified($fileName); - } - if (isset($dataCurrent[$extension])) { - $lastModified = $this->yellow->toolbox->getFileModified($fileName); - if (preg_match("/update/i", $flags) && preg_match("/careful/i", $flags) && $lastModified!=$lastPublished) { - $data[$extension] = $dataCurrent[$extension]; - if (defined("DEBUG") && DEBUG>=2) { - echo "YellowUpdate::getExtensionsModified detected file:$fileName extension:$extension
\n"; - } - } - } - } - } - } - return array($statusCode, $data); - } - // Return extension file public function getExtensionFile($url) { $urlRequest = $url; if (preg_match("#^https://github.com/(.+)/raw/(.+)$#", $url, $matches)) $urlRequest = "https://raw.githubusercontent.com/".$matches[1]."/".$matches[2]; $curlHandle = curl_init(); curl_setopt($curlHandle, CURLOPT_URL, $urlRequest); - curl_setopt($curlHandle, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; DatenstromYellow/".YellowCore::VERSION."; SoftwareUpdater)"); + curl_setopt($curlHandle, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; YellowUpdate/".YellowUpdate::VERSION."; SoftwareUpdater)"); curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curlHandle, CURLOPT_CONNECTTIMEOUT, 30); $rawData = curl_exec($curlHandle);