From 40f09dd479994e4fbcf0dc59aed7677f6f2e013f Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Tue, 3 Feb 2026 12:16:50 -0700 Subject: [PATCH] Get the domain_uuid using the domain name from the URL When the domain_uuid is not available, get the domain name from the URL. Use the domain to get the domain_uuid. This is needed to get the correct domain settings. --- resources/require.php | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/resources/require.php b/resources/require.php index e4cbf6dc78..1af82a16fd 100644 --- a/resources/require.php +++ b/resources/require.php @@ -106,9 +106,41 @@ session_start(); } +//get the domain_name and the domain_uuid + if (empty($_SESSION['domain_uuid'])) { + //get the domain from the url + $domain_name = $_SERVER["HTTP_HOST"]; + + //get the domain name from the http value + if (!empty($_REQUEST["domain_name"])) { + $domain_name = $_REQUEST["domain_name"]; + } + + //remote port number from the domain name + $domain_array = explode(":", $domain_name); + if (count($domain_array) > 1) { + $domain_name = $domain_array[0]; + } + + //get the domain_uuid from the database + $sql = "select domain_uuid from v_domains \n"; + $sql .= "where domain_name = :domain_name \n"; + $parameters['domain_name'] = $domain_name; + $row = $database->select($sql, $parameters, 'row'); + $domain_uuid = ''; + if (is_array($row) && sizeof($row) != 0) { + $domain_uuid = $row['domain_uuid']; + if (session_status() === PHP_SESSION_ACTIVE) { + $_SESSION['domain_uuid'] = $domain_uuid; + $_SESSION['domain_name'] = $domain_name; + } + } + unset($parameters, $row); + } + //load settings global $settings; - $settings = new settings(['database' => $database, 'domain_uuid' => $_SESSION['domain_uuid'] ?? '', 'user_uuid' => $_SESSION['user_uuid'] ?? '']); + $settings = new settings(['database' => $database, 'domain_uuid' => $_SESSION['domain_uuid'] ?? $domain_uuid, 'user_uuid' => $_SESSION['user_uuid'] ?? '']); //check if the cidr range is valid global $no_cidr;