2012-06-04 16:58:40 +02:00
|
|
|
<?php
|
|
|
|
|
/*
|
|
|
|
|
FusionPBX
|
|
|
|
|
Version: MPL 1.1
|
|
|
|
|
|
|
|
|
|
The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
|
1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
|
the License. You may obtain a copy of the License at
|
|
|
|
|
http://www.mozilla.org/MPL/
|
|
|
|
|
|
|
|
|
|
Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
|
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
|
for the specific language governing rights and limitations under the
|
|
|
|
|
License.
|
|
|
|
|
|
|
|
|
|
The Original Code is FusionPBX
|
|
|
|
|
|
|
|
|
|
The Initial Developer of the Original Code is
|
|
|
|
|
Mark J Crane <markjcrane@fusionpbx.com>
|
2025-02-20 19:25:36 +01:00
|
|
|
Portions created by the Initial Developer are Copyright (C) 2008-2025
|
2012-06-04 16:58:40 +02:00
|
|
|
the Initial Developer. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
Contributor(s):
|
|
|
|
|
Mark J Crane <markjcrane@fusionpbx.com>
|
|
|
|
|
*/
|
2014-01-19 02:30:10 +01:00
|
|
|
|
2025-03-11 21:37:31 +01:00
|
|
|
//class auto loader
|
|
|
|
|
if (!class_exists('auto_loader')) {
|
|
|
|
|
require_once __DIR__ . "/classes/auto_loader.php";
|
|
|
|
|
$autoload = new auto_loader();
|
2023-08-14 20:04:00 +02:00
|
|
|
}
|
|
|
|
|
|
2025-03-11 21:37:31 +01:00
|
|
|
//load config file
|
|
|
|
|
global $config;
|
|
|
|
|
$config = config::load();
|
|
|
|
|
|
2023-08-16 00:19:22 +02:00
|
|
|
//config.conf file not found re-direct the request to the install
|
2025-03-11 21:37:31 +01:00
|
|
|
if ($config->is_empty()) {
|
2023-08-16 00:19:22 +02:00
|
|
|
header("Location: /core/install/install.php");
|
|
|
|
|
exit;
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-11 21:37:31 +01:00
|
|
|
//compatibility settings - planned to deprecate
|
|
|
|
|
global $conf, $db_type, $db_host, $db_port, $db_name, $db_username, $db_password;
|
|
|
|
|
$conf = $config->configuration();
|
|
|
|
|
$db_type = $config->get('database.0.type');
|
|
|
|
|
$db_host = $config->get('database.0.host');
|
|
|
|
|
$db_port = $config->get('database.0.port');
|
|
|
|
|
$db_name = $config->get('database.0.name');
|
|
|
|
|
$db_username = $config->get('database.0.username');
|
|
|
|
|
$db_password = $config->get('database.0.password');
|
2022-10-10 21:16:32 +02:00
|
|
|
|
|
|
|
|
//set the error reporting
|
2023-04-26 19:19:45 +02:00
|
|
|
ini_set('display_errors', '1');
|
2025-03-11 21:37:31 +01:00
|
|
|
$error_reporting_scope = $config->get('error.reporting', 'user');
|
2023-04-26 19:19:45 +02:00
|
|
|
switch ($error_reporting_scope) {
|
|
|
|
|
case 'user':
|
2023-05-08 23:07:59 +02:00
|
|
|
error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING ^ E_DEPRECATED);
|
2023-04-26 19:19:45 +02:00
|
|
|
break;
|
|
|
|
|
case 'dev':
|
|
|
|
|
error_reporting(E_ALL ^ E_NOTICE);
|
|
|
|
|
break;
|
|
|
|
|
case 'all':
|
|
|
|
|
error_reporting(E_ALL);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
2023-05-08 23:07:59 +02:00
|
|
|
error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING ^ E_DEPRECATED);
|
2022-10-14 00:23:20 +02:00
|
|
|
}
|
2022-10-10 21:16:32 +02:00
|
|
|
|
|
|
|
|
//get the database connection settings
|
|
|
|
|
//$db_type = $settings['database']['type'];
|
|
|
|
|
//$db_host = $settings['database']['host'];
|
|
|
|
|
//$db_port = $settings['database']['port'];
|
|
|
|
|
//$db_name = $settings['database']['name'];
|
|
|
|
|
//$db_username = $settings['database']['username'];
|
|
|
|
|
//$db_password = $settings['database']['password'];
|
|
|
|
|
|
|
|
|
|
//debug info
|
|
|
|
|
//echo "Include Path: ".get_include_path()."\n";
|
|
|
|
|
//echo "Document Root: ".$_SERVER["DOCUMENT_ROOT"]."\n";
|
|
|
|
|
//echo "Project Root: ".$_SERVER["PROJECT_ROOT"]."\n";
|
2014-01-19 02:30:10 +01:00
|
|
|
|
2025-03-11 21:37:31 +01:00
|
|
|
|
|
|
|
|
//include global functions
|
|
|
|
|
require_once __DIR__ . "/functions.php";
|
|
|
|
|
|
|
|
|
|
//connect to the database
|
|
|
|
|
global $database;
|
|
|
|
|
$database = database::new(['config' => $config]);
|
|
|
|
|
|
|
|
|
|
//if not using the command line required files
|
|
|
|
|
global $no_session;
|
|
|
|
|
if (!defined('STDIN') && empty($no_session)) {
|
|
|
|
|
require_once __DIR__ . '/php.php';
|
2022-10-11 23:34:55 +02:00
|
|
|
}
|
2014-01-19 02:30:10 +01:00
|
|
|
|
2025-03-11 21:37:31 +01:00
|
|
|
//load settings
|
|
|
|
|
global $settings;
|
2025-03-15 05:55:00 +01:00
|
|
|
$settings = new settings(['database' => $database, 'domain_uuid' => $_SESSION['domain_uuid'] ?? '', 'user_uuid' => $_SESSION['user_uuid'] ?? '']);
|
2025-03-11 21:37:31 +01:00
|
|
|
|
|
|
|
|
//check if the cidr range is valid
|
|
|
|
|
global $no_cidr;
|
|
|
|
|
if (!defined('STDIN') && empty($no_cidr)) {
|
|
|
|
|
require_once __DIR__ . '/cidr.php';
|
2024-04-21 06:59:45 +02:00
|
|
|
}
|
2025-03-11 21:37:31 +01:00
|
|
|
|
|
|
|
|
//include switch functions when available
|
|
|
|
|
if (file_exists(__DIR__ . '/switch.php')) {
|
|
|
|
|
require_once __DIR__ . '/switch.php';
|
2016-05-05 21:22:08 +02:00
|
|
|
}
|
2015-01-18 08:54:19 +01:00
|
|
|
|
|
|
|
|
//change language on the fly - for translate tool (if available)
|
2023-09-11 09:45:19 +02:00
|
|
|
if (!defined('STDIN') && isset($_REQUEST['view_lang_code']) && ($_REQUEST['view_lang_code']) != '') {
|
2015-01-18 08:54:19 +01:00
|
|
|
$_SESSION['domain']['language']['code'] = $_REQUEST['view_lang_code'];
|
|
|
|
|
}
|
2020-11-04 01:21:41 +01:00
|
|
|
|
2025-02-20 19:25:36 +01:00
|
|
|
//change the domain
|
|
|
|
|
if (!empty($_GET["domain_uuid"]) && is_uuid($_GET["domain_uuid"]) && $_GET["domain_change"] == "true" && permission_exists('domain_select')) {
|
|
|
|
|
|
|
|
|
|
//include domains
|
|
|
|
|
if (file_exists($_SERVER["PROJECT_ROOT"]."/app/domains/app_config.php") && !permission_exists('domain_all')) {
|
|
|
|
|
include_once "app/domains/domains.php";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//update the domain session variables
|
|
|
|
|
$domain_uuid = $_GET["domain_uuid"];
|
|
|
|
|
$_SESSION["previous_domain_uuid"] = $_SESSION['domain_uuid'];
|
|
|
|
|
$_SESSION['domain_uuid'] = $domain_uuid;
|
|
|
|
|
|
|
|
|
|
//get the domain details
|
|
|
|
|
$sql = "select * from v_domains ";
|
|
|
|
|
$sql .= "order by domain_name asc ";
|
|
|
|
|
$domains = $database->select($sql, null, 'all');
|
|
|
|
|
if (!empty($domains)) {
|
|
|
|
|
foreach($domains as $row) {
|
|
|
|
|
$_SESSION['domains'][$row['domain_uuid']] = $row;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
unset($sql, $domains);
|
|
|
|
|
|
|
|
|
|
//update the domain session variables
|
|
|
|
|
$_SESSION["domain_name"] = $_SESSION['domains'][$domain_uuid]['domain_name'];
|
|
|
|
|
$_SESSION['domain']['template']['name'] = $_SESSION['domains'][$domain_uuid]['template_name'] ?? null;
|
|
|
|
|
$_SESSION["context"] = $_SESSION["domain_name"];
|
|
|
|
|
|
|
|
|
|
//clear the extension array so that it is regenerated for the selected domain
|
|
|
|
|
unset($_SESSION['extension_array']);
|
|
|
|
|
|
|
|
|
|
//set the setting arrays
|
|
|
|
|
$domain = new domains();
|
|
|
|
|
$domain->set();
|
|
|
|
|
}
|