From 5483b9a9e6b11468fabc49f7a80f364ea9b6990f Mon Sep 17 00:00:00 2001 From: Max Pozdeev Date: Fri, 15 Apr 2022 18:41:46 +0300 Subject: [PATCH] - fix errors if language files are broken --- src/includes/class.lang.php | 6 ++++++ src/settings.php | 3 +++ 2 files changed, 9 insertions(+) diff --git a/src/includes/class.lang.php b/src/includes/class.lang.php index 879b791..cdb3ed5 100644 --- a/src/includes/class.lang.php +++ b/src/includes/class.lang.php @@ -54,6 +54,9 @@ class Lang { $this->code = $code; $json = json_decode($jsonString, true); + if ($json === null) { + $json = array(); + } //load default language if ( $code != $this->default ) { @@ -72,6 +75,9 @@ class Lang } $defStr = file_get_contents($this->langDir(). "{$this->default}.json"); $this->strings = json_decode($defStr, true); + if ($this->strings === null) { + die("Invalid JSON in default language file (". htmlspecialchars($this->default). ".json)"); + } } function get($key) diff --git a/src/settings.php b/src/settings.php index 9417200..8869239 100644 --- a/src/settings.php +++ b/src/settings.php @@ -153,6 +153,9 @@ function selectOptionsA($a, $key, $default=null) $s = ''; if($default !== null && !isset($a[$key])) $key = $default; foreach($a as $k=>$v) { + if (!is_array($v)) { + $v = array('name' => $k); + } $s .= '';