mikuli.cz

:)
git clone https://git.sr.ht/~ashymad/mikuli.cz
Log | Files | Refs

commit c63039f354bd8a944231255fb3fea74cbdab563b
parent e07ff273655a914d2c150b465640434db15e3de5
Author: markseu <mark2011@mayberg.se>
Date:   Fri, 30 Oct 2020 11:03:19 +0100

Updated API, more information for troubleshooting

Diffstat:
Msystem/extensions/core.php | 45+++++++++++++++++++++++++++++++--------------
Msystem/extensions/edit.php | 5++---
Msystem/extensions/update-current.ini | 12++++++------
Msystem/extensions/update.php | 21++++++++++++++-------
4 files changed, 53 insertions(+), 30 deletions(-)

diff --git a/system/extensions/core.php b/system/extensions/core.php @@ -2,7 +2,7 @@ // Core extension, https://github.com/datenstrom/yellow-extensions/tree/master/source/core class YellowCore { - const VERSION = "0.8.26"; + const VERSION = "0.8.27"; const RELEASE = "0.8.16"; public $page; // current page public $content; // content files @@ -91,11 +91,11 @@ class YellowCore { // Handle initialisation public function load() { $this->system->load($this->system->get("coreExtensionDirectory").$this->system->get("coreSystemFile")); + $this->lookup->detectFileSystem(); $this->user->load($this->system->get("coreExtensionDirectory").$this->system->get("coreUserFile")); $this->language->load($this->system->get("coreExtensionDirectory")); $this->language->load($this->system->get("coreExtensionDirectory").$this->system->get("coreLanguageFile")); $this->extension->load($this->system->get("coreExtensionDirectory")); - $this->lookup->detectFileSystem(); $this->startup(); } @@ -329,7 +329,8 @@ class YellowCore { } if ($statusCode==0) { $line = date("Y-m-d H:i:s")." ".trim($action)." ".trim($message)."\n"; - $this->toolbox->appendFile($this->system->get("coreExtensionDirectory").$this->system->get("coreLogFile"), $line); + $this->toolbox->appendFile($this->system->get("coreServerInstallDirectory"). + $this->system->get("coreExtensionDirectory").$this->system->get("coreLogFile"), $line); } } @@ -1906,6 +1907,7 @@ class YellowExtension { $this->yellow = $yellow; $this->modified = 0; $this->data = array(); + register_shutdown_function(array($this, "handleFatalError")); } // Load extensions @@ -1937,6 +1939,19 @@ class YellowExtension { } } + // Handle fatal extension error + public function handleFatalError() { + $error = error_get_last(); + $type = $error["type"]; + $fileName = $error["file"]; + if ($type==E_ERROR || $type==E_PARSE) { + if ($this->yellow->toolbox->getFileType($fileName)=="php") { + $fileName = substru($fileName, strlenu($this->yellow->system->get("coreServerInstallDirectory"))); + $this->yellow->log("error", "Can't run extension file '$fileName'!"); + } + } + } + // Return extension public function get($key) { return $this->data[$key]["object"]; @@ -1968,6 +1983,8 @@ class YellowLookup { list($pathRoot, $pathHome) = $this->findFileSystemInformation(); $this->yellow->system->set("coreContentRootDirectory", $pathRoot); $this->yellow->system->set("coreContentHomeDirectory", $pathHome); + $this->yellow->system->set("coreServerInstallDirectory", + substru(dirname(__FILE__), 0, 1-strlenu($this->yellow->system->get("coreExtensionDirectory")))); date_default_timezone_set($this->yellow->system->get("coreServerTimezone")); } @@ -2528,17 +2545,6 @@ class YellowToolbox { return $contentType; } - // Return number of bytes - public function getNumberBytes($string) { - $bytes = intval($string); - switch (strtoupperu(substru($string, -1))) { - case "G": $bytes *= 1024*1024*1024; break; - case "M": $bytes *= 1024*1024; break; - case "K": $bytes *= 1024; break; - } - return $bytes; - } - // Return files and directories public function getDirectoryEntries($path, $regex = "/.*/", $sort = true, $directories = true, $includePath = true) { $entries = array(); @@ -2716,6 +2722,17 @@ class YellowToolbox { return $group; } + // Return number of bytes + public function getNumberBytes($string) { + $bytes = intval($string); + switch (strtoupperu(substru($string, -1))) { + case "G": $bytes *= 1024*1024*1024; break; + case "M": $bytes *= 1024*1024; break; + case "K": $bytes *= 1024; break; + } + return $bytes; + } + // Return lines from text, including newline public function getTextLines($text) { $lines = preg_split("/\n/", $text); diff --git a/system/extensions/edit.php b/system/extensions/edit.php @@ -2,7 +2,7 @@ // Edit extension, https://github.com/datenstrom/yellow-extensions/tree/master/source/edit class YellowEdit { - const VERSION = "0.8.36"; + const VERSION = "0.8.37"; public $yellow; // access to API public $response; // web response public $merge; // text merge @@ -1260,8 +1260,7 @@ class YellowEditResponse { public function getToolbarButtons() { $toolbarButtons = $this->yellow->system->get("editToolbarButtons"); if ($toolbarButtons=="auto") { - $toolbarButtons = ""; - if ($this->yellow->extension->isExisting("markdown")) $toolbarButtons = "format, bold, italic, strikethrough, code, separator, list, link, file"; + $toolbarButtons = "format, bold, italic, strikethrough, code, separator, list, link, file"; if ($this->yellow->extension->isExisting("emojiawesome")) $toolbarButtons .= ", emojiawesome"; if ($this->yellow->extension->isExisting("fontawesome")) $toolbarButtons .= ", fontawesome"; $toolbarButtons .= ", status, preview"; diff --git a/system/extensions/update-current.ini b/system/extensions/update-current.ini @@ -21,21 +21,21 @@ Tag: feature system/extensions/command.php: command.php, create, update Extension: Core -Version: 0.8.26 +Version: 0.8.27 Description: Core functionality of the website. HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/core DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/core.zip -Published: 2020-10-27 16:19:30 +Published: 2020-10-29 20:49:27 Developer: Datenstrom Tag: feature system/extensions/core.php: core.php, create, update Extension: Edit -Version: 0.8.36 +Version: 0.8.37 Description: Edit your website in a web browser. HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/edit DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/edit.zip -Published: 2020-10-27 14:45:48 +Published: 2020-10-28 15:26:51 Developer: Datenstrom Tag: feature system/extensions/edit.php: edit.php, create, update @@ -89,11 +89,11 @@ system/themes/stockholm-opensans-light.woff: stockholm-opensans-light.woff, crea system/themes/stockholm-opensans-regular.woff: stockholm-opensans-regular.woff, create, update, careful Extension: Update -Version: 0.8.40 +Version: 0.8.41 Description: Keep your website up to date. HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/update DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/update.zip -Published: 2020-10-28 10:16:16 +Published: 2020-10-30 10:40:10 Developer: Datenstrom Tag: feature system/extensions/update.php: update.php, create, update diff --git 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.40"; + const VERSION = "0.8.41"; const PRIORITY = "2"; public $yellow; // access to API public $updates; // number of updates @@ -461,13 +461,13 @@ class YellowUpdate { if (defined("DEBUG") && DEBUG>=2) echo "YellowUpdate::updateExtensionArchive file:$path<br/>\n"; $pathBase = ""; if (preg_match("#^(.*\/).*?$#", $zip->getNameIndex(0), $matches)) $pathBase = $matches[1]; - $languages = $this->getExtensionArchiveLanguages($zip, $pathBase); $fileData = $zip->getFromName($pathBase.$this->yellow->system->get("updateExtensionFile")); $settings = $this->yellow->toolbox->getTextSettings($fileData, ""); - list($extension, $version, $newModified, $oldModified) = $this->getExtensionInformation($settings); + list($extension, $version, $newModified, $oldModified) = $this->getExtensionInformation($settings, $path); if (!empty($extension) && !empty($version)) { $statusCode = $this->updateExtensionSettings($extension, $settings, $action); if ($statusCode==200) { + $languages = $this->getExtensionArchiveLanguages($zip, $pathBase); foreach ($this->getExtensionFileNames($settings) as $fileName) { list($entry, $flags) = $this->yellow->toolbox->getTextList($settings[$fileName], ",", 2); if (!$this->yellow->lookup->isContentFile($fileName)) { @@ -734,17 +734,24 @@ class YellowUpdate { } // Return extension information - public function getExtensionInformation($settings) { + public function getExtensionInformation($settings, $path) { $extension = lcfirst($settings->get("extension")); $version = $settings->get("version"); $newModified = strtotime($settings->get("published")); $oldModified = 0; + $invalid = false; foreach ($settings as $key=>$value) { - if (strposu($key, "/") && is_file($key)) { - $oldModified = filemtime($key); - break; + if (strposu($key, "/")) { + if (!$this->yellow->lookup->isValidFile($key)) $invalid = true; + list($entry, $flags) = $this->yellow->toolbox->getTextList($value, ",", 2); + if (strposu($entry, ".")===false) $invalid = true; + if ($oldModified==0 && is_file($key)) $oldModified = filemtime($key); } } + if ($invalid) { + $this->yellow->log("error", "Can't detect extension file '$path'!"); + $extension = $version = ""; + } return array($extension, $version, $newModified, $oldModified); }