mikuli.cz

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

commit 817532c88bbeb4ed97a4bb90f08a5bb0de7f3222
parent 7c99a54bb2722c525128aad521c6dd85de1caf1d
Author: markseu <mark2011@mayberg.se>
Date:   Tue, 27 Oct 2020 11:51:01 +0100

Updated extensions and settings

Diffstat:
Msystem/extensions/bundle.php | 38++++++--------------------------------
Msystem/extensions/command.php | 21++++++---------------
Msystem/extensions/core.php | 30+++++++++++++++++-------------
Msystem/extensions/edit.php | 42+++++++++++++++++++++---------------------
Msystem/extensions/image.php | 22++++++----------------
Msystem/extensions/install-languages.zip | 0
Msystem/extensions/install.php | 12++++++------
Msystem/extensions/stockholm.php | 4++--
Msystem/extensions/update.php | 139++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------
Rsystem/settings/language.ini -> system/extensions/yellow-language.ini | 0
Asystem/extensions/yellow-system.ini | 72++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Rsystem/settings/user.ini -> system/extensions/yellow-user.ini | 0
Dsystem/settings/system.ini | 70----------------------------------------------------------------------
13 files changed, 238 insertions(+), 212 deletions(-)

diff --git a/system/extensions/bundle.php b/system/extensions/bundle.php @@ -2,7 +2,7 @@ // Bundle extension, https://github.com/datenstrom/yellow-extensions/tree/master/source/bundle class YellowBundle { - const VERSION = "0.8.16"; + const VERSION = "0.8.17"; public $yellow; // access to API // Handle initialisation @@ -19,44 +19,18 @@ class YellowBundle { return $output; } - // Handle command - public function onCommand($command, $text) { - switch ($command) { - case "clean": $statusCode = $this->processCommandClean($command, $text); break; - default: $statusCode = 0; - } - return $statusCode; - } - - // Process command to clean bundles - public function processCommandClean($command, $text) { - $statusCode = 0; - if ($command=="clean" && $text=="all") { - $path = $this->yellow->system->get("coreExtensionDirectory"); - $statusCode = $this->cleanBundles($path); - if ($statusCode==500) echo "ERROR cleaning bundles: Can't delete files in directory '$path'!\n"; - } - return $statusCode; - } - // Handle update public function onUpdate($action) { - if ($action=="update") { + if ($action=="clean" || $action=="daily" || $action=="uninstall") { + $statusCode = 200; $path = $this->yellow->system->get("coreExtensionDirectory"); - $statusCode = $this->cleanBundles($path); + foreach ($this->yellow->toolbox->getDirectoryEntries($path, "/bundle-.*/", false, false) as $entry) { + if (!$this->yellow->toolbox->deleteFile($entry)) $statusCode = 500; + } if ($statusCode==500) $this->yellow->log("error", "Can't delete files in directory '$path'!\n"); } } - // Clean bundles - public function cleanBundles($path) { - $statusCode = 200; - foreach ($this->yellow->toolbox->getDirectoryEntries($path, "/bundle-.*/", false, false) as $entry) { - if (!$this->yellow->toolbox->deleteFile($entry)) $statusCode = 500; - } - return $statusCode; - } - // Normalise page head public function normaliseHead($text) { $dataMeta = $dataLink = $dataCss = $dataScriptDefer = $dataScriptNow = $dataOther = array(); diff --git 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.24"; + const VERSION = "0.8.25"; public $yellow; // access to API public $files; // number of files public $links; // number of links @@ -55,7 +55,7 @@ class YellowCommand { $statusCode = 500; $this->files = 0; $this->errors = 1; - $fileName = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("coreSystemFile"); + $fileName = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreSystemFile"); echo "ERROR building files: Please configure CoreStaticUrl in file '$fileName'!\n"; } echo "Yellow $command: $this->files file".($this->files!=1 ? "s" : ""); @@ -237,7 +237,7 @@ class YellowCommand { $statusCode = 500; $this->links = 0; $this->errors = 1; - $fileName = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("coreSystemFile"); + $fileName = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreSystemFile"); echo "ERROR checking files: Please configure CoreStaticUrl in file '$fileName'!\n"; } echo "Yellow $command: $this->links link".($this->links!=1 ? "s" : ""); @@ -392,7 +392,9 @@ class YellowCommand { $statusCode = 200; $path = rtrim(empty($path) ? $this->yellow->system->get("commandStaticBuildDirectory") : $path, "/"); if (empty($location)) { - $statusCode = max($statusCode, $this->broadcastCommand("clean", "all")); + foreach ($this->yellow->extension->data as $key=>$value) { + if (method_exists($value["object"], "onUpdate")) $value["object"]->onUpdate("clean"); + } $statusCode = max($statusCode, $this->cleanStaticDirectory($path)); } else { if ($this->yellow->lookup->isFileLocation($location)) { @@ -428,17 +430,6 @@ class YellowCommand { } return $statusCode; } - - // Broadcast command to other extensions - public function broadcastCommand($command, $text) { - $statusCode = 0; - foreach ($this->yellow->extension->data as $key=>$value) { - if (method_exists($value["object"], "onCommand") && $key!="command") { - $statusCode = max($statusCode, $value["object"]->onCommand($command, $text)); - } - } - return $statusCode; - } // Process command to start built-in web server public function processCommandServe($command, $text) { 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.24"; + const VERSION = "0.8.25"; const RELEASE = "0.8.16"; public $page; // current page public $content; // content files @@ -47,7 +47,6 @@ class YellowCore { $this->system->setDefault("coreImageDirectory", "media/images/"); $this->system->setDefault("coreSystemDirectory", "system/"); $this->system->setDefault("coreExtensionDirectory", "system/extensions/"); - $this->system->setDefault("coreSettingDirectory", "system/settings/"); $this->system->setDefault("coreLayoutDirectory", "system/layouts/"); $this->system->setDefault("coreThemeDirectory", "system/themes/"); $this->system->setDefault("coreTrashDirectory", "system/trash/"); @@ -60,9 +59,9 @@ class YellowCore { $this->system->setDefault("coreContentErrorFile", "page-error-(.*).md"); $this->system->setDefault("coreContentExtension", ".md"); $this->system->setDefault("coreDownloadExtension", ".download"); - $this->system->setDefault("coreSystemFile", "system.ini"); - $this->system->setDefault("coreUserFile", "user.ini"); - $this->system->setDefault("coreLanguageFile", "language.ini"); + $this->system->setDefault("coreSystemFile", "yellow-system.ini"); + $this->system->setDefault("coreUserFile", "yellow-user.ini"); + $this->system->setDefault("coreLanguageFile", "yellow-language.ini"); $this->system->setDefault("coreLogFile", "yellow.log"); $this->language->setDefault("coreDateFormatShort"); $this->language->setDefault("coreDateFormatMedium"); @@ -91,10 +90,10 @@ class YellowCore { // Handle initialisation public function load() { - $this->system->load($this->system->get("coreSettingDirectory").$this->system->get("coreSystemFile")); - $this->user->load($this->system->get("coreSettingDirectory").$this->system->get("coreUserFile")); - $this->language->load($this->system->get("coreExtensionDirectory")."(.*).txt"); - $this->language->load($this->system->get("coreSettingDirectory").$this->system->get("coreLanguageFile")); + $this->system->load($this->system->get("coreExtensionDirectory").$this->system->get("coreSystemFile")); + $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(); @@ -305,7 +304,7 @@ class YellowCore { if (method_exists($value["object"], "onStartup")) $value["object"]->onStartup(); } foreach ($this->extension->data as $key=>$value) { - if (method_exists($value["object"], "onUpdate")) $value["object"]->onUpdate("startup"); + if (method_exists($value["object"], "onUpdate")) $value["object"]->onUpdate("ready"); } } } @@ -1747,10 +1746,15 @@ class YellowLanguage { $this->language = ""; } - // Load language settings from file + // Load language settings from file or directory public function load($fileName) { - $path = dirname($fileName); - $regex = "/^".basename($fileName)."$/"; + if (substru($fileName, -1, 1)!="/") { + $path = dirname($fileName); + $regex = "/^".basename($fileName)."$/"; + } else { + $path = $fileName; + $regex = "/^.*\.txt$/"; + } foreach ($this->yellow->toolbox->getDirectoryEntries($path, $regex, true, false) as $entry) { if (defined("DEBUG") && DEBUG>=2) echo "YellowLanguage::load file:$entry<br/>\n"; $this->modified = max($this->modified, filemtime($entry)); 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.35"; + const VERSION = "0.8.36"; public $yellow; // access to API public $response; // web response public $merge; // text merge @@ -99,7 +99,7 @@ class YellowEdit { public function onUpdate($action) { if ($action=="update") { $cleanup = false; - $fileNameUser = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("coreUserFile"); + $fileNameUser = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreUserFile"); $fileData = $this->yellow->toolbox->readFile($fileNameUser); $fileDataNew = ""; foreach ($this->yellow->toolbox->getTextLines($fileData) as $line) { @@ -161,7 +161,7 @@ class YellowEdit { case "short": echo "ERROR updating settings: Please enter a longer password!\n"; break; } if ($status=="ok") { - $fileNameUser = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("coreUserFile"); + $fileNameUser = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreUserFile"); $settings = array( "name" => $name, "language" => $this->yellow->system->get("language"), @@ -201,7 +201,7 @@ class YellowEdit { case "short": echo "ERROR updating settings: Please enter a longer password!\n"; break; } if ($status=="ok") { - $fileNameUser = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("coreUserFile"); + $fileNameUser = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreUserFile"); $settings = array( "name" => empty($name) ? $this->yellow->user->getUser("name", $email) : $name, "hash" => empty($password) ? $this->yellow->user->getUser("hash", $email) : $this->response->createHash($password), @@ -229,7 +229,7 @@ class YellowEdit { case "unknown": echo "ERROR updating settings: Can't find email '$email'!\n"; break; } if ($status=="ok") { - $fileNameUser = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("coreUserFile"); + $fileNameUser = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreUserFile"); $status = $this->yellow->user->remove($fileNameUser, $email) ? "ok" : "error"; if ($status=="error") echo "ERROR updating settings: Can't write file '$fileNameUser'!\n"; $this->yellow->log($status=="ok" ? "info" : "error", "Remove user '".strtok($name, " ")."'"); @@ -297,7 +297,7 @@ class YellowEdit { // Process request for user login public function processRequestLogin($scheme, $address, $base, $location, $fileName) { - $fileNameUser = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("coreUserFile"); + $fileNameUser = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreUserFile"); $settings = array("failed" => "0", "modified" => date("Y-m-d H:i:s", time())); if ($this->yellow->user->save($fileNameUser, $this->response->userEmail, $settings)) { $home = $this->yellow->user->getUser("home", $this->response->userEmail); @@ -341,7 +341,7 @@ class YellowEdit { if ($this->response->status=="ok" && $this->response->isLoginRestriction()) $this->response->status = "next"; if ($this->response->status=="ok" && $this->isUserAccountTaken($email)) $this->response->status = "next"; if ($this->response->status=="ok") { - $fileNameUser = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("coreUserFile"); + $fileNameUser = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreUserFile"); $settings = array( "name" => $name, "language" => $this->yellow->lookup->findLanguageFromFile($fileName, $this->yellow->system->get("language")), @@ -376,7 +376,7 @@ class YellowEdit { $email = $this->yellow->page->getRequest("email"); $this->response->status = $this->getUserStatus($email, $this->yellow->page->getRequest("action")); if ($this->response->status=="ok") { - $fileNameUser = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("coreUserFile"); + $fileNameUser = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreUserFile"); $settings = array("failed" => "0", "modified" => date("Y-m-d H:i:s", time()), "status" => "unapproved"); $this->response->status = $this->yellow->user->save($fileNameUser, $email, $settings) ? "ok" : "error"; if ($this->response->status=="error") $this->yellow->page->error(500, "Can't write file '$fileNameUser'!"); @@ -397,7 +397,7 @@ class YellowEdit { $this->response->status = $this->getUserStatus($email, $this->yellow->page->getRequest("action")); if ($this->response->status=="ok") { $name = $this->yellow->user->getUser("name", $email); - $fileNameUser = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("coreUserFile"); + $fileNameUser = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreUserFile"); $settings = array("failed" => "0", "modified" => date("Y-m-d H:i:s", time()), "status" => "active"); $this->response->status = $this->yellow->user->save($fileNameUser, $email, $settings) ? "ok" : "error"; if ($this->response->status=="error") $this->yellow->page->error(500, "Can't write file '$fileNameUser'!"); @@ -437,7 +437,7 @@ class YellowEdit { if (empty($password)) $this->response->status = "password"; if ($this->response->status=="ok") $this->response->status = $this->getUserAccount($this->response->action, $email, $password); if ($this->response->status=="ok") { - $fileNameUser = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("coreUserFile"); + $fileNameUser = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreUserFile"); $settings = array("hash" => $this->response->createHash($password), "failed" => "0", "modified" => date("Y-m-d H:i:s", time())); $this->response->status = $this->yellow->user->save($fileNameUser, $email, $settings) ? "ok" : "error"; if ($this->response->status=="error") $this->yellow->page->error(500, "Can't write file '$fileNameUser'!"); @@ -458,7 +458,7 @@ class YellowEdit { $email = $this->yellow->page->getRequest("email"); $this->response->status = $this->getUserStatus($email, $this->yellow->page->getRequest("action")); if ($this->response->status=="ok") { - $fileNameUser = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("coreUserFile"); + $fileNameUser = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreUserFile"); $settings = array("failed" => "0", "modified" => date("Y-m-d H:i:s", time()), "status" => "active"); $this->response->status = $this->yellow->user->save($fileNameUser, $email, $settings) ? "done" : "error"; if ($this->response->status=="error") $this->yellow->page->error(500, "Can't write file '$fileNameUser'!"); @@ -478,7 +478,7 @@ class YellowEdit { if ($this->yellow->user->getUser("status", $emailSource)!="active") $this->response->status = "done"; } if ($this->response->status=="ok") { - $fileNameUser = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("coreUserFile"); + $fileNameUser = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreUserFile"); $settings = array("failed" => "0", "modified" => date("Y-m-d H:i:s", time()), "status" => "unchanged"); $this->response->status = $this->yellow->user->save($fileNameUser, $email, $settings) ? "ok" : "error"; if ($this->response->status=="error") $this->yellow->page->error(500, "Can't write file '$fileNameUser'!"); @@ -502,7 +502,7 @@ class YellowEdit { if (!$this->yellow->user->isExisting($email) || empty($hash)) $this->response->status = "done"; } if ($this->response->status=="ok") { - $fileNameUser = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("coreUserFile"); + $fileNameUser = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreUserFile"); $settings = array( "hash" => $hash, "pending" => "none", @@ -513,7 +513,7 @@ class YellowEdit { if ($this->response->status=="error") $this->yellow->page->error(500, "Can't write file '$fileNameUser'!"); } if ($this->response->status=="ok" && $email!=$emailSource) { - $fileNameUser = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("coreUserFile"); + $fileNameUser = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreUserFile"); $this->response->status = $this->yellow->user->remove($fileNameUser, $emailSource) ? "ok" : "error"; if ($this->response->status=="error") $this->yellow->page->error(500, "Can't write file '$fileNameUser'!"); } @@ -550,7 +550,7 @@ class YellowEdit { $this->response->status = $this->getUserStatus($email, $this->yellow->page->getRequest("action")); if ($this->response->status=="ok") { $name = $this->yellow->user->getUser("name", $email); - $fileNameUser = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("coreUserFile"); + $fileNameUser = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreUserFile"); $settings = array("failed" => "0", "modified" => date("Y-m-d H:i:s", time()), "status" => "removed"); $this->response->status = $this->yellow->user->save($fileNameUser, $email, $settings) ? "ok" : "error"; if ($this->response->status=="error") $this->yellow->page->error(500, "Can't write file '$fileNameUser'!"); @@ -561,7 +561,7 @@ class YellowEdit { if ($this->response->status=="error") $this->yellow->page->error(500, "Can't send email on this server!"); } if ($this->response->status=="ok") { - $fileNameUser = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("coreUserFile"); + $fileNameUser = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreUserFile"); $this->response->status = $this->yellow->user->remove($fileNameUser, $email) ? "ok" : "error"; if ($this->response->status=="error") $this->yellow->page->error(500, "Can't write file '$fileNameUser'!"); } @@ -587,7 +587,7 @@ class YellowEdit { if ($this->response->status=="ok") $this->response->status = $this->getUserAccount($this->response->action, $email, $password); if ($this->response->status=="ok" && $email!=$emailSource && $this->isUserAccountTaken($email)) $this->response->status = "taken"; if ($this->response->status=="ok" && $email!=$emailSource) { - $fileNameUser = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("coreUserFile"); + $fileNameUser = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreUserFile"); $settings = array( "name" => $name, "language" => $language, @@ -603,7 +603,7 @@ class YellowEdit { if ($this->response->status=="error") $this->yellow->page->error(500, "Can't write file '$fileNameUser'!"); } if ($this->response->status=="ok") { - $fileNameUser = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("coreUserFile"); + $fileNameUser = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreUserFile"); $settings = array( "name" => $name, "language" => $language, @@ -620,7 +620,7 @@ class YellowEdit { } } else { if ($this->response->status=="ok") { - $fileNameUser = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("coreUserFile"); + $fileNameUser = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreUserFile"); $settings = array("name" => $name, "language" => $language, "failed" => "0", "modified" => date("Y-m-d H:i:s", time())); $this->response->status = $this->yellow->user->save($fileNameUser, $email, $settings) ? "done" : "error"; if ($this->response->status=="error") $this->yellow->page->error(500, "Can't write file '$fileNameUser'!"); @@ -648,7 +648,7 @@ class YellowEdit { if (empty($email) || !filter_var($email, FILTER_VALIDATE_EMAIL)) $this->response->status = "invalid"; } if ($this->response->status=="ok") { - $fileName = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("coreSystemFile"); + $fileName = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreSystemFile"); $settings = array("sitename" => $sitename, "author" => $author, "email" => $email); $file = $this->response->getFileSystem($scheme, $address, $base, $location, $fileName, $settings); $this->response->status = (!$file->isError() && $this->yellow->system->save($fileName, $settings)) ? "done" : "error"; @@ -896,7 +896,7 @@ class YellowEdit { if ($this->response->userFailedExpire>time() && $this->yellow->user->isExisting($this->response->userFailedEmail)) { $email = $this->response->userFailedEmail; $failed = $this->yellow->user->getUser("failed", $email)+1; - $fileNameUser = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("coreUserFile"); + $fileNameUser = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreUserFile"); $status = $this->yellow->user->save($fileNameUser, $email, array("failed" => $failed)) ? "ok" : "error"; if ($status=="error") $this->yellow->page->error(500, "Can't write file '$fileNameUser'!"); if ($failed==$this->yellow->system->get("editBruteForceProtection")) { diff --git a/system/extensions/image.php b/system/extensions/image.php @@ -2,7 +2,7 @@ // Image extension, https://github.com/datenstrom/yellow-extensions/tree/master/source/image class YellowImage { - const VERSION = "0.8.10"; + const VERSION = "0.8.11"; public $yellow; // access to API // Handle initialisation @@ -59,27 +59,17 @@ class YellowImage { } } } - - // Handle command - public function onCommand($command, $text) { - switch ($command) { - case "clean": $statusCode = $this->processCommandClean($command, $text); break; - default: $statusCode = 0; - } - return $statusCode; - } - // Process command to clean thumbnails - public function processCommandClean($command, $text) { - $statusCode = 0; - if ($command=="clean" && $text=="all") { + // Handle update + public function onUpdate($action) { + if ($action=="clean") { + $statusCode = 200; $path = $this->yellow->system->get("imageThumbnailDirectory"); foreach ($this->yellow->toolbox->getDirectoryEntries($path, "/.*/", false, false) as $entry) { if (!$this->yellow->toolbox->deleteFile($entry)) $statusCode = 500; } - if ($statusCode==500) echo "ERROR cleaning thumbnails: Can't delete files in directory '$path'!\n"; + if ($statusCode==500) $this->yellow->log("error", "Can't delete files in directory '$path'!\n"); } - return $statusCode; } // Return image information, create thumbnail on demand diff --git a/system/extensions/install-languages.zip b/system/extensions/install-languages.zip Binary files differ. diff --git a/system/extensions/install.php b/system/extensions/install.php @@ -2,7 +2,7 @@ // Install extension, https://github.com/datenstrom/yellow class YellowInstall { - const VERSION = "0.8.38"; + const VERSION = "0.8.39"; const PRIORITY = "1"; public $yellow; // access to API @@ -103,7 +103,7 @@ class YellowInstall { $fileDataIni = $zip->getFromName($pathBase."$extension/extension.ini"); $statusCode = max($statusCode, $this->updateLanguageArchive($fileDataPhp, $fileDataTxt, $fileDataIni, $pathBase, "install")); } - $this->yellow->language->load($this->yellow->system->get("coreExtensionDirectory")."(.*).txt"); + $this->yellow->language->load($this->yellow->system->get("coreExtensionDirectory")); $zip->close(); } else { $statusCode = 500; @@ -150,7 +150,7 @@ class YellowInstall { $statusCode = 200; if (!empty($email) && !empty($password) && $this->yellow->extension->isExisting("edit")) { if (empty($name)) $name = $this->yellow->system->get("sitename"); - $fileNameUser = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("coreUserFile"); + $fileNameUser = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreUserFile"); $settings = array( "name" => $name, "language" => $language, @@ -196,12 +196,12 @@ class YellowInstall { // Update settings public function updateSettings($language) { $statusCode = 200; - $fileName = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("coreSystemFile"); + $fileName = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreSystemFile"); if (!$this->yellow->system->save($fileName, $this->getSystemData())) { $statusCode = 500; $this->yellow->page->error($statusCode, "Can't write file '$fileName'!"); } - $fileName = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("coreLanguageFile"); + $fileName = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreLanguageFile"); $fileData = $this->yellow->toolbox->readFile($fileName); if (strposu($fileData, "Language:")===false) { if (!empty($fileData)) $fileData .= "\n"; @@ -271,7 +271,7 @@ class YellowInstall { // Check web server write access public function checkServerWrite() { - $fileName = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("coreSystemFile"); + $fileName = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreSystemFile"); return $this->yellow->system->save($fileName, array()); } diff --git a/system/extensions/stockholm.php b/system/extensions/stockholm.php @@ -2,7 +2,7 @@ // Stockholm extension, https://github.com/datenstrom/yellow-extensions/tree/master/source/stockholm class YellowStockholm { - const VERSION = "0.8.9"; + const VERSION = "0.8.10"; public $yellow; // access to API // Handle initialisation @@ -12,7 +12,7 @@ class YellowStockholm { // Handle update public function onUpdate($action) { - $fileName = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("coreSystemFile"); + $fileName = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreSystemFile"); if ($action=="install") { $this->yellow->system->save($fileName, array("theme" => "stockholm")); } elseif ($action=="uninstall" && $this->yellow->system->get("theme")=="stockholm") { 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.36"; + const VERSION = "0.8.37"; const PRIORITY = "2"; public $yellow; // access to API public $updates; // number of updates @@ -14,6 +14,9 @@ class YellowUpdate { $this->yellow->system->setDefault("updateExtensionFile", "extension.ini"); $this->yellow->system->setDefault("updateCurrentFile", "update-current.ini"); $this->yellow->system->setDefault("updateLatestFile", "update-latest.ini"); + $this->yellow->system->setDefault("updateDailyTimestamp", "0"); + $this->yellow->system->setDefault("updateWeeklyTimestamp", "0"); + $this->yellow->system->setDefault("updateMonthlyTimestamp", "0"); $this->yellow->system->setDefault("updateNotification", "none"); } @@ -33,7 +36,6 @@ class YellowUpdate { if ($statusCode==0) { switch ($command) { case "about": $statusCode = $this->processCommandAbout($command, $text); break; - case "clean": $statusCode = $this->processCommandClean($command, $text); break; case "install": $statusCode = $this->processCommandInstall($command, $text); break; case "uninstall": $statusCode = $this->processCommandUninstall($command, $text); break; case "update": $statusCode = $this->processCommandUpdate($command, $text); break; @@ -54,7 +56,82 @@ class YellowUpdate { // Handle update public function onUpdate($action) { - if ($action=="update") { // TODO: remove later, converts old layout files + if ($action=="ready") { + if ($this->yellow->system->get("updateNotification")!="none") { + foreach (explode(",", $this->yellow->system->get("updateNotification")) as $token) { + list($extension, $action) = $this->yellow->toolbox->getTextList($token, "/", 2); + if ($this->yellow->extension->isExisting($extension) && ($action!="ready" && $action!="uninstall")) { + $value = $this->yellow->extension->data[$extension]; + if (method_exists($value["object"], "onUpdate")) $value["object"]->onUpdate($action); + } + } + $fileName = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreSystemFile"); + if (!$this->yellow->system->save($fileName, array("updateNotification" => "none"))) { + $this->yellow->log("error", "Can't write file '$fileName'!"); + } + $this->updateSystemSettings(); + $this->updateLanguageSettings(); + } + if ($this->yellow->system->get("updateDailyTimestamp") <= time()) { + foreach ($this->yellow->extension->data as $key=>$value) { + if (method_exists($value["object"], "onUpdate")) $value["object"]->onUpdate("daily"); + } + $this->updateTimestampSettings("updateDailyTimestamp"); + } + if ($this->yellow->system->get("updateWeeklyTimestamp") <= time()) { + foreach ($this->yellow->extension->data as $key=>$value) { + if (method_exists($value["object"], "onUpdate")) $value["object"]->onUpdate("weekly"); + } + $this->updateTimestampSettings("updateWeeklyTimestamp"); + } + if ($this->yellow->system->get("updateMonthlyTimestamp") <= time()) { + foreach ($this->yellow->extension->data as $key=>$value) { + if (method_exists($value["object"], "onUpdate")) $value["object"]->onUpdate("monthly"); + } + $this->updateTimestampSettings("updateMonthlyTimestamp"); + } + } + if ($action=="clean") { + $statusCode = 200; + $path = $this->yellow->system->get("coreExtensionDirectory"); + $regex = "/^.*\\".$this->yellow->system->get("coreDownloadExtension")."$/"; + foreach ($this->yellow->toolbox->getDirectoryEntries($path, $regex, false, false) as $entry) { + if (!$this->yellow->toolbox->deleteFile($entry)) $statusCode = 500; + } + if ($statusCode==500) $this->yellow->log("error", "Can't delete files in directory '$path'!\n"); + } + if ($action=="update") { // TODO: remove later, convert old settings files + if (is_dir("system/settings/")) { + $fileNameSource = "system/settings/system.ini"; + $fileNameDestination = "system/extensions/yellow-system.ini"; + if (is_file($fileNameSource)) { + $fileData = $fileDataNew = $this->yellow->toolbox->readFile($fileNameSource); + $fileDataNew = str_replace("user.ini", "yellow-user.ini", $fileDataNew); + $fileDataNew = str_replace("language.ini", "yellow-language.ini", $fileDataNew); + if (!$this->yellow->toolbox->createFile($fileNameDestination, $fileDataNew)) { + $this->yellow->log("error", "Can't write file '$fileNameDestination'!"); + } + } + $fileNameSource = "system/settings/user.ini"; + $fileNameDestination = "system/extensions/yellow-user.ini"; + if (is_file($fileNameSource) && !$this->yellow->toolbox->copyFile($fileNameSource, $fileNameDestination)) { + $this->yellow->log("error", "Can't write file '$fileNameDestination'!"); + } + $fileNameSource = "system/settings/language.ini"; + $fileNameDestination = "system/extensions/yellow-language.ini"; + if (is_file($fileNameSource) && !$this->yellow->toolbox->copyFile($fileNameSource, $fileNameDestination)) { + $this->yellow->log("error", "Can't write file '$fileNameDestination'!"); + } + if (!$this->yellow->toolbox->deleteDirectory("system/settings/", + $this->yellow->system->get("coreTrashDirectory"))) { + $this->yellow->log("error", "Can't delete directory 'system/settings/'!"); + } else { + $this->yellow->page->error(500, "The flux capacitor is charging, please reload page!"); + $this->yellow->log("info", "Convert old settings files"); + } + } + } + if ($action=="update") { // TODO: remove later, convert old layout files $path = $this->yellow->system->get("coreLayoutDirectory"); foreach ($this->yellow->toolbox->getDirectoryEntriesRecursive($path, "/^.*\.html$/", true, false) as $entry) { $key = str_replace("pages", "", $this->yellow->lookup->normaliseName(basename($entry), true, true)); @@ -70,28 +147,11 @@ class YellowUpdate { } } } - if ($action=="startup") { - if ($this->yellow->system->get("updateNotification")!="none") { - foreach (explode(",", $this->yellow->system->get("updateNotification")) as $token) { - 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["object"], "onUpdate")) $value["object"]->onUpdate($action); - } - } - $fileName = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("coreSystemFile"); - if (!$this->yellow->system->save($fileName, array("updateNotification" => "none"))) { - $this->yellow->log("error", "Can't write file '$fileName'!"); - } - $this->updateSystemSettings(); - $this->updateLanguageSettings(); - } - } } // Update system settings after update notification public function updateSystemSettings() { - $fileName = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("coreSystemFile"); + $fileName = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreSystemFile"); $fileData = $this->yellow->toolbox->readFile($fileName); $fileDataStart = $fileDataSettings = $fileDataComments = ""; $settings = new YellowArray(); @@ -122,7 +182,7 @@ class YellowUpdate { // Update language settings after update notification public function updateLanguageSettings() { - $fileName = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("coreLanguageFile"); + $fileName = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreLanguageFile"); $fileData = $this->yellow->toolbox->readFile($fileName); $fileDataStart = $fileDataSettings = $language = ""; $settings = new YellowArray(); @@ -162,6 +222,25 @@ class YellowUpdate { $this->yellow->log("error", "Can't write file '$fileName'!"); } } + + // Update timestamp settings in regular intervalls + public function updateTimestampSettings($key) { + $timestamp = $timeOffset = 0; + foreach(str_split($this->yellow->system->get("sitename")) as $char) { + $timeOffset = ($timeOffset+ord($char)) % 60; + } + if ($key=="updateDailyTimestamp") { + $timestamp = mktime(0, 0, 0) + 60*60*24 + $timeOffset; + } elseif ($key=="updateWeeklyTimestamp") { + $timestamp = mktime(0, 0, 0, date("n"), date("j")-date("N")+1) + 60*60*24*7 + $timeOffset; + } elseif ($key=="updateMonthlyTimestamp") { + $timestamp = mktime(0, 0, 0, date("n")+1, 1) + $timeOffset; + } + $fileName = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreSystemFile"); + if (!$this->yellow->system->save($fileName, array($key => $timestamp))) { + $this->yellow->log("error", "Can't write file '$fileName'!"); + } + } // Create extension settings from scratch public function createExtensionSettings() { @@ -229,20 +308,6 @@ class YellowUpdate { return $statusCode; } - // Process command to clean downloads - public function processCommandClean($command, $text) { - $statusCode = 0; - if ($command=="clean" && $text=="all") { - $path = $this->yellow->system->get("coreExtensionDirectory"); - $regex = "/^.*\\".$this->yellow->system->get("coreDownloadExtension")."$/"; - 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; - } - // Process command to install extensions public function processCommandInstall($command, $text) { $extensions = $this->getExtensionsFromText($text); @@ -322,7 +387,7 @@ class YellowUpdate { if ($updateNotification=="none") $updateNotification = ""; if (!empty($updateNotification)) $updateNotification .= ","; $updateNotification .= "$extension/$action"; - $fileName = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("coreSystemFile"); + $fileName = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreSystemFile"); if (!$this->yellow->system->save($fileName, array("updateNotification" => $updateNotification))) { $statusCode = 500; $this->yellow->page->error(500, "Can't write file '$fileName'!"); diff --git a/system/settings/language.ini b/system/extensions/yellow-language.ini diff --git a/system/extensions/yellow-system.ini b/system/extensions/yellow-system.ini @@ -0,0 +1,72 @@ +# Datenstrom Yellow system settings + +Sitename: Datenstrom Yellow +Author: Datenstrom +Email: webmaster +Language: en +Layout: default +Theme: stockholm +Parser: markdown +Status: public +CoreStaticUrl: +CoreServerUrl: auto +CoreServerTimezone: UTC +CoreMultiLanguageMode: 0 +CoreMediaLocation: /media/ +CoreDownloadLocation: /media/downloads/ +CoreImageLocation: /media/images/ +CoreExtensionLocation: /media/extensions/ +CoreThemeLocation: /media/themes/ +CoreMediaDirectory: media/ +CoreDownloadDirectory: media/downloads/ +CoreImageDirectory: media/images/ +CoreSystemDirectory: system/ +CoreExtensionDirectory: system/extensions/ +CoreLayoutDirectory: system/layouts/ +CoreThemeDirectory: system/themes/ +CoreTrashDirectory: system/trash/ +CoreCacheDirectory: cache/ +CoreContentDirectory: content/ +CoreContentRootDirectory: default/ +CoreContentHomeDirectory: home/ +CoreContentSharedDirectory: shared/ +CoreContentDefaultFile: page.md +CoreContentErrorFile: page-error-(.*).md +CoreContentExtension: .md +CoreDownloadExtension: .download +CoreUserFile: yellow-user.ini +CoreLanguageFile: yellow-language.ini +CoreLogFile: yellow.log +UpdateExtensionUrl: https://github.com/datenstrom/yellow-extensions +UpdateExtensionFile: extension.ini +UpdateCurrentFile: update-current.ini +UpdateLatestFile: update-latest.ini +UpdateDailyTimestamp: 0 +UpdateWeeklyTimestamp: 0 +UpdateMonthlyTimestamp: 0 +UpdateNotification: none +CommandStaticBuildDirectory: public/ +CommandStaticDefaultFile: index.html +CommandStaticErrorFile: 404.html +EditLocation: /edit/ +EditUploadNewLocation: /media/@group/@filename +EditUploadExtensions: .gif, .jpg, .pdf, .png, .svg, .zip +EditKeyboardShortcuts: ctrl+b bold, ctrl+i italic, ctrl+k strikethrough, ctrl+e code, ctrl+s save, ctrl+alt+p preview +EditToolbarButtons: auto +EditEndOfLine: auto +EditNewFile: page-new-(.*).md +EditUserPasswordMinLength: 8 +EditUserHashAlgorithm: bcrypt +EditUserHashCost: 10 +EditUserHome: / +EditUserAccess: create, edit, delete, upload +EditLoginRestriction: 0 +EditLoginSessionTimeout: 2592000 +EditBruteForceProtection: 25 +ImageUploadWidthMax: 1280 +ImageUploadHeightMax: 1280 +ImageUploadJpgQuality: 80 +ImageThumbnailLocation: /media/thumbnails/ +ImageThumbnailDirectory: media/thumbnails/ +ImageThumbnailJpgQuality: 80 +MetaDefaultImage: favicon diff --git a/system/settings/user.ini b/system/extensions/yellow-user.ini diff --git a/system/settings/system.ini b/system/settings/system.ini @@ -1,70 +0,0 @@ -# Datenstrom Yellow system settings - -Sitename: Datenstrom Yellow -Author: Datenstrom -Email: webmaster -Language: en -Layout: default -Theme: stockholm -Parser: markdown -Status: public -CoreStaticUrl: -CoreServerUrl: auto -CoreServerTimezone: UTC -CoreMultiLanguageMode: 0 -CoreMediaLocation: /media/ -CoreDownloadLocation: /media/downloads/ -CoreImageLocation: /media/images/ -CoreExtensionLocation: /media/extensions/ -CoreThemeLocation: /media/themes/ -CoreMediaDirectory: media/ -CoreDownloadDirectory: media/downloads/ -CoreImageDirectory: media/images/ -CoreSystemDirectory: system/ -CoreExtensionDirectory: system/extensions/ -CoreSettingDirectory: system/settings/ -CoreLayoutDirectory: system/layouts/ -CoreThemeDirectory: system/themes/ -CoreTrashDirectory: system/trash/ -CoreCacheDirectory: cache/ -CoreContentDirectory: content/ -CoreContentRootDirectory: default/ -CoreContentHomeDirectory: home/ -CoreContentSharedDirectory: shared/ -CoreContentDefaultFile: page.md -CoreContentErrorFile: page-error-(.*).md -CoreContentExtension: .md -CoreDownloadExtension: .download -CoreUserFile: user.ini -CoreLanguageFile: language.ini -CoreLogFile: yellow.log -UpdateExtensionUrl: https://github.com/datenstrom/yellow-extensions -UpdateExtensionFile: extension.ini -UpdateCurrentFile: update-current.ini -UpdateLatestFile: update-latest.ini -UpdateNotification: none -CommandStaticBuildDirectory: public/ -CommandStaticDefaultFile: index.html -CommandStaticErrorFile: 404.html -EditLocation: /edit/ -EditUploadNewLocation: /media/@group/@filename -EditUploadExtensions: .gif, .jpg, .pdf, .png, .svg, .zip -EditKeyboardShortcuts: ctrl+b bold, ctrl+i italic, ctrl+k strikethrough, ctrl+e code, ctrl+s save, ctrl+alt+p preview -EditToolbarButtons: auto -EditEndOfLine: auto -EditNewFile: page-new-(.*).md -EditUserPasswordMinLength: 8 -EditUserHashAlgorithm: bcrypt -EditUserHashCost: 10 -EditUserHome: / -EditUserAccess: create, edit, delete, upload -EditLoginRestriction: 0 -EditLoginSessionTimeout: 2592000 -EditBruteForceProtection: 25 -ImageUploadWidthMax: 1280 -ImageUploadHeightMax: 1280 -ImageUploadJpgQuality: 80 -ImageThumbnailLocation: /media/thumbnails/ -ImageThumbnailDirectory: media/thumbnails/ -ImageThumbnailJpgQuality: 80 -MetaDefaultImage: favicon