diff --git a/index.php b/index.php
index 38c13b1..1fa5736 100644
--- a/index.php
+++ b/index.php
@@ -1,13 +1,13 @@
forceSSL();
$this->loginStatus();
+ $this->getSiteLanguage();
$this->pageStatus();
$this->logoutAction();
$this->loginAction();
@@ -159,6 +163,28 @@ public function init(): void
}
}
+ /**
+ * Set site language based on logged-in user
+ * @return string
+ * @throws Exception
+ */
+ public function getSiteLanguage(): string
+ {
+ if ($this->loggedIn) {
+ $lang = $this->get('config', 'adminLang');
+ } else {
+ $lang = $this->get('config', 'siteLang');
+ }
+
+ if (gettype($lang) === 'object' && empty(get_object_vars($lang))) {
+ $lang = 'en';
+ $this->set('config', 'siteLang', $lang);
+ $this->set('config', 'adminLang', $lang);
+ }
+
+ return $lang;
+ }
+
/**
* Display the HTML. Called after init()
* @return void
@@ -442,6 +468,8 @@ public function createDb(): void
$this->db = (object)[
self::DB_CONFIG => [
'siteTitle' => 'Website title',
+ 'siteLang' => 'en',
+ 'adminLang' => 'en',
'theme' => 'sky',
'defaultPage' => 'home',
'login' => 'loginURL',
@@ -872,7 +900,7 @@ public function css(): string
{
if ($this->loggedIn) {
$styles = <<<'EOT'
-
+
EOT;
return $this->hook('css', $styles)[0];
}
@@ -1244,6 +1272,19 @@ public function getModulesCachedData(string $type = self::THEMES_DIR): array
return $data !== null && array_key_exists($type, $data) ? $data[$type] : [];
}
+ /**
+ * Retrieve cached single Theme/Plugin data
+ * @param string $moduleKey
+ * @param string $type
+ * @return array|null
+ * @throws Exception
+ */
+ public function getSingleModuleCachedData(string $moduleKey, string $type = self::THEMES_DIR): array
+ {
+ $data = $this->getModulesCachedData($type);
+ return $data !== null && array_key_exists($moduleKey, $data) ? $data[$moduleKey] : [];
+ }
+
/**
* Force cache refresh for updates
* @throws Exception
@@ -1469,9 +1510,15 @@ private function validateWcmsModuleStructure(object $wcmsModule): bool {
*/
public function addCustomModule(): void
{
- if (!isset($_POST['pluginThemeUrl'], $_POST['pluginThemeType']) || !$this->verifyFormActions()) {
+ if (!isset($_POST['pluginThemeUrl'], $_POST['pluginThemeType'], $_POST['password_recheck']) || !$this->verifyFormActions()) {
return;
}
+
+ if (!password_verify($_POST['password_recheck'], $this->get('config', 'password'))) {
+ $this->alert('danger', 'Invalid password.');
+ $this->redirect();
+ }
+
$type = $_POST['pluginThemeType'];
$url = rtrim(trim($_POST['pluginThemeUrl']), '/');
$customModules = (array)$this->get('config', 'customModules', $type);
@@ -1531,12 +1578,19 @@ public function getModuleVersion(string $type, string $name): ?string
*/
public function installUpdateModuleAction(): void
{
- if (!isset($_REQUEST['installModule'], $_REQUEST['directoryName'], $_REQUEST['type']) || !$this->verifyFormActions(true)) {
+ if (!isset($_REQUEST['installModule'], $_REQUEST['type']) || !$this->verifyFormActions(true)) {
return;
}
- $url = $_REQUEST['installModule'];
- $folderName = $_REQUEST['directoryName'];
+
+ $folderName = trim(htmlspecialchars($_REQUEST['installModule']));
$type = $_REQUEST['type'];
+ $cached = $this->getSingleModuleCachedData($folderName, $type);
+ $url = !empty($cached) ? $cached['zip'] : null;
+
+ if (empty($url)) {
+ $this->alert('danger', 'Unable to find theme or plugin.');
+ return;
+ }
$path = sprintf('%s/%s/', $this->rootDir, $type);
@@ -1609,10 +1663,14 @@ public function js(): string
$scripts = << Admin login URL Important: save your login URL to log in to your website next time: Important: save your login URL to log in to your website next time: Site language config HTML lang value for admin. HTML lang value for visitors. Password Save confirmation popup If this is turned "ON", WonderCMS will always ask you to confirm any changes you make.
' . self::url($this->get('config',
- 'login')) . '
+
' . self::url($this->get('config', 'login')) . '
Custom module
- - + '; return $output; } diff --git a/themes/sky/theme.php b/themes/sky/theme.php index 1e620e0..b670182 100644 --- a/themes/sky/theme.php +++ b/themes/sky/theme.php @@ -1,7 +1,7 @@ - + diff --git a/themes/sky/wcms-modules.json b/themes/sky/wcms-modules.json index b3bfdd3..bc6ae6b 100644 --- a/themes/sky/wcms-modules.json +++ b/themes/sky/wcms-modules.json @@ -6,7 +6,7 @@ "repo": "https://github.com/robiso/sky/tree/master", "zip": "https://github.com/robiso/sky/archive/master.zip", "summary": "Default WonderCMS theme (2022). Theme works without Bootstrap and jQuery.", - "version": "3.2.3", + "version": "3.2.4", "image": "https://raw.githubusercontent.com/robiso/sky/master/preview.jpg" } } diff --git a/version b/version index 4d9d11c..6cb9d3d 100644 --- a/version +++ b/version @@ -1 +1 @@ -3.4.2 +3.4.3