From 557a5dcbf2aac25fa1e5da99a2b6e45cb67019f9 Mon Sep 17 00:00:00 2001 From: Belle Aerni Date: Thu, 20 Oct 2022 13:12:02 -0700 Subject: [PATCH] Miscellaneous Changes (#368) * Corrected "powered by" link in admin panel * Fix changing the admin theme https://github.com/boxbilling/boxbilling/pull/1346 * Avoid strtolower(): Passing null to parameter #1 ($string) of type string is deprecated * Also use isset * Avoid json_decode(): Passing null to parameter #1 ($json) of type string is deprecated --- src/bb-library/Box/Tools.php | 8 ++++++-- src/bb-library/Model/ServiceLicense.php | 8 ++++++-- src/bb-modules/Cart/Service.php | 12 ++++++------ src/bb-modules/Theme/Service.php | 2 +- .../admin_default/html/layout_default.html.twig | 2 +- 5 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/bb-library/Box/Tools.php b/src/bb-library/Box/Tools.php index 23604d0fa..2d5515e57 100644 --- a/src/bb-library/Box/Tools.php +++ b/src/bb-library/Box/Tools.php @@ -354,8 +354,12 @@ class Box_Tools public function decodeJ($json_str) { - $config = json_decode($json_str, true); - return is_array($config) ? $config : array(); + if(isset($json_str)){ + $config = json_decode($json_str, true); + return is_array($config) ? $config : array(); + } else { + return array(); + } } public function sortByOneKey(array $array, $key, $asc = true) { diff --git a/src/bb-library/Model/ServiceLicense.php b/src/bb-library/Model/ServiceLicense.php index 949f1a2d8..f023cd9ca 100644 --- a/src/bb-library/Model/ServiceLicense.php +++ b/src/bb-library/Model/ServiceLicense.php @@ -17,8 +17,12 @@ class Model_ServiceLicense extends \RedBean_SimpleModel { private function _decodeJson($j) { - $config = json_decode($j, true); - return is_array($config) ? $config : array(); + if(isset($j)){ + $config = json_decode($j, true); + return is_array($config) ? $config : array(); + } else { + return array(); + } } public function getAllowedIps() diff --git a/src/bb-modules/Cart/Service.php b/src/bb-modules/Cart/Service.php index 3fc678fec..a844642fd 100644 --- a/src/bb-modules/Cart/Service.php +++ b/src/bb-modules/Cart/Service.php @@ -509,12 +509,12 @@ class Service implements InjectionAwareInterface * It will, however, avoid instances like this when a domain name is entered with a capital letter: * https://github.com/boxbilling/boxbilling/discussions/1022#discussioncomment-1311819 */ - $item['register_sld'] = strtolower($item['register_sld']); - $item['transfer_sld'] = strtolower($item['transfer_sld']); - $item['sld'] = strtolower($item['sld']); - $item['domain']['owndomain_sld'] = strtolower($item['domain']['owndomain_sld']); - $item['domain']['register_sld'] = strtolower($item['domain']['register_sld']); - $item['domain']['transfer_sld'] = strtolower($item['domain']['transfer_sld']); + $item['register_sld'] = (isset($item['register_sld'])) ? strtolower($item['register_sld']) : null; + $item['transfer_sld'] = (isset($item['transfer_sld'])) ? strtolower($item['transfer_sld']) : null; + $item['sld'] = (isset($item['sld'])) ? strtolower($item['sld']) : null; + $item['domain']['owndomain_sld'] = (isset($item['domain']['owndomain_sld'])) ? strtolower($item['domain']['owndomain_sld']) : null; + $item['domain']['register_sld'] = (isset($item['domain']['register_sld'])) ? strtolower($item['domain']['register_sld']) : null; + $item['domain']['transfer_sld'] = (isset($item['domain']['transfer_sld'])) ? strtolower($item['domain']['transfer_sld']) : null; $order = $this->di['db']->dispense('ClientOrder'); $order->client_id = $client->id; diff --git a/src/bb-modules/Theme/Service.php b/src/bb-modules/Theme/Service.php index 784a6f8b0..49983654a 100644 --- a/src/bb-modules/Theme/Service.php +++ b/src/bb-modules/Theme/Service.php @@ -250,7 +250,7 @@ class Service implements InjectionAwareInterface '; $default = 'admin_default'; $theme = $this->di['db']->getCell($query, ['param' => 'admin_theme']); - $path = BB_PATH_THEMES.DIRECTORY_SEPARATOR.$theme; + $path = BB_PATH_THEMES.DIRECTORY_SEPARATOR; if (null == $theme || !file_exists($path.$theme)) { $theme = $default; } diff --git a/src/bb-themes/admin_default/html/layout_default.html.twig b/src/bb-themes/admin_default/html/layout_default.html.twig index 85de0df6a..fb7171a15 100644 --- a/src/bb-themes/admin_default/html/layout_default.html.twig +++ b/src/bb-themes/admin_default/html/layout_default.html.twig @@ -216,7 +216,7 @@