From 8e1d608e5fad25edc12b0c9968e26b9a30bc33e9 Mon Sep 17 00:00:00 2001
From: Ibnu Maksum <ibnumaksum@gmail.com>
Date: Mon, 29 Jul 2024 16:19:43 +0700
Subject: [PATCH] fix compability

---
 init.php   | 4 ++--
 update.php | 6 +++++-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/init.php b/init.php
index c88676ae..e5e02676 100644
--- a/init.php
+++ b/init.php
@@ -67,11 +67,11 @@ require_once $root_path . File::pathFixer('system/orm.php');
 require_once $root_path . File::pathFixer('system/autoload/PEAR2/Autoload.php');
 include $root_path . File::pathFixer('system/autoload/Hookers.php');
 
-if(!empty($db_password)){
+if($db_password != null && ($db_pass == null || empty($db_pass))){
     // compability for old version
     $db_pass = $db_password;
 }
-if(!empty($db_pass)){
+if($db_pass != null){
     // compability for old version
     $db_password = $db_pass;
 }
diff --git a/update.php b/update.php
index ceb4d63b..4a8a259b 100644
--- a/update.php
+++ b/update.php
@@ -8,6 +8,11 @@
 session_start();
 include "config.php";
 
+if($db_password != null && ($db_pass == null || empty($db_pass))){
+    // compability for old version
+    $db_pass = $db_password;
+}
+
 if (empty($update_url)) {
     $update_url = 'https://github.com/hotspotbilling/phpnuxbill/archive/refs/heads/master.zip';
 }
@@ -100,7 +105,6 @@ if (empty($step)) {
     }
 } else if ($step == 4) {
     if (file_exists("system/updates.json")) {
-        require 'config.php';
         $db = new pdo(
             "mysql:host=$db_host;dbname=$db_name",
             $db_user,