Skip to content

Commit

Permalink
Merge pull request #284 from WonderCMS/341
Browse files Browse the repository at this point in the history
Add 8.2 PHP compatibility fixes.
Add check and create custom modules object in database if it doesn't exist.
  • Loading branch information
robiso committed Jan 22, 2023
2 parents cee5968 + 64839fe commit 247c58b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .github/README.md
Expand Up @@ -32,7 +32,7 @@
- Transferring your website to a new host/server is done by only copy/pasting all files (no additional configuration/migration)
- Privacy oriented: no cookies, tracking or "powered by" links.
- Includes plugins ([via hooks/listeners](https://github.com/WonderCMS/wondercms/wiki/List-of-hooks)), [themes](https://github.com/WonderCMS/wondercms/wiki/Create-theme-in-8-easy-steps)/plugins installer, [backups](https://github.com/WonderCMS/wondercms/wiki/Backup-all-files), [1 click updates](https://github.com/WonderCMS/wondercms/wiki/One-click-update).
- Supports most server types (Apache, NGINX, IIS).
- Supports most server types (Apache, NGINX, IIS, Caddy).
- Project goal: keep it simple, tiny, hassle free (infrequent-ish 1 click updates).

<br>
Expand Down Expand Up @@ -76,7 +76,7 @@ Note: Some plugins also include other libraries such as jQuery, default WonderCM
- Track free and transparent - WonderCMS doesn't track users or store any personal cookies, there is only one session state cookie.
- Your WonderCMS installation is completely detached from WonderCMS servers. One click updates are pushed through GitHub.
- Supports HTTPS out of the box.
- [Check how to turn on "improved security" mode](https://github.com/WonderCMS/wondercms/wiki/Better-security-mode-(HTTPS-and-other-features)).
- [Check how to further improve security](https://github.com/WonderCMS/wondercms/wiki/Better-security-mode-(HTTPS-and-other-features)).
- All CSS and JS libraries include SubResource Integrity (SRI) tags. This prevents any changes to the libraries being loaded. If any changes are made, the libraries won't load for your and your visitors protection.
- [Check how to add SRI tags to your custom theme](https://github.com/WonderCMS/wondercms/wiki/Add-SRI-tags-to-your-theme-libraries#sri-subresource-integrity---3-steps-for-more-security). This step isn't necessary if you're using a theme from the official website.
- WonderCMS encourages you to change your default login URL. **Consider your custom login URL as your private username**.
Expand Down
28 changes: 22 additions & 6 deletions index.php
Expand Up @@ -7,7 +7,7 @@
*/

session_start();
define('VERSION', '3.4.0');
define('VERSION', '3.4.1');
mb_internal_encoding('UTF-8');

if (defined('PHPUNIT_TESTING') === false) {
Expand Down Expand Up @@ -431,10 +431,7 @@ public function createDb(): void
'password' => password_hash($password, PASSWORD_DEFAULT),
'lastLogins' => [],
'lastModulesSync' => null,
'customModules' => [
'themes' => [],
'plugins' => []
],
'customModules' => $this->defaultCustomModules(),
'menuItems' => [
'0' => [
'name' => 'Home',
Expand Down Expand Up @@ -506,6 +503,17 @@ public function createDb(): void
$this->save();
}

/**
* Default data for the Custom Modules
* @return array[]
*/
private function defaultCustomModules(): array {
return [
'themes' => [],
'plugins' => []
];
}

/**
* Create menu item
*
Expand Down Expand Up @@ -1268,6 +1276,7 @@ private function fetchModuleConfig(string $url, string $type): ?object
$this->alert('danger', 'The wcms-modules.json file does not contain all the required information.');
return null;
}
$wcmsModulesData = get_mangled_object_vars($wcmsModulesData);
$returnData = reset($wcmsModulesData);
$name = key($wcmsModulesData);
$returnData->dirName = $name;
Expand Down Expand Up @@ -1363,6 +1372,13 @@ private function cacheModulesData(): void

// Cache custom modules
$returnArray = $this->getJsonFileData($this->modulesCachePath);

// If custom modules is missing from the DB, we add it
if (!property_exists($db->config, 'customModules')) {
$this->set('config', 'customModules', $this->defaultCustomModules());
$db = $this->getDb();
}

$arrayCustom = (array)$db->config->customModules;
foreach ($arrayCustom as $type => $modules) {
foreach ($modules as $url) {
Expand Down Expand Up @@ -2749,7 +2765,7 @@ public function uploadFileAction(): void
$fileName = basename(str_replace(
['"', "'", '*', '<', '>', '%22', '&#39;', '%', ';', '#', '&', './', '../', '/', '+'],
'',
filter_var($_FILES['uploadFile']['name'], FILTER_SANITIZE_STRING)
htmlspecialchars(strip_tags($_FILES['uploadFile']['name']))
));
$nameExploded = explode('.', $fileName);
$ext = strtolower(array_pop($nameExploded));
Expand Down
2 changes: 1 addition & 1 deletion version
@@ -1 +1 @@
3.4.0
3.4.1

0 comments on commit 247c58b

Please sign in to comment.