diff --git a/app/call_centers/resources/dashboard/call_center_agents.php b/app/call_centers/resources/dashboard/call_center_agents.php index 39b9c0e365..b377b46069 100644 --- a/app/call_centers/resources/dashboard/call_center_agents.php +++ b/app/call_centers/resources/dashboard/call_center_agents.php @@ -49,6 +49,11 @@ $order_by = $_GET["order_by"]; $order = $_GET["order"]; +//connect to the database + if (!isset($database)) { + $database = new database; + } + //setup the event socket connection $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); @@ -62,7 +67,6 @@ $array['call_center_agents'][0]['call_center_agent_uuid'] = $row['id']; $array['call_center_agents'][0]['domain_uuid'] = $_SESSION['user']['domain_uuid']; $array['call_center_agents'][0]['agent_status'] = $row['agent_status']; - $database = new database; $database->app_name = 'call_centers_dashboard'; $database->app_uuid = '95788e50-9500-079e-2807-fd530b0ea370'; $database->save($array); @@ -103,7 +107,6 @@ $sql .= "where domain_uuid = :domain_uuid "; $sql .= "order by queue_extension asc "; $parameters['domain_uuid'] = $_SESSION['domain_uuid']; - $database = new database; $call_center_queues = $database->select($sql, $parameters, 'all'); $num_rows = !is_array($call_center_queues) ? 0 : @sizeof($call_center_queues); unset($sql, $parameters); @@ -114,7 +117,6 @@ $sql .= "and domain_uuid = :domain_uuid"; $parameters['user_uuid'] = $_SESSION['user_uuid']; $parameters['domain_uuid'] = $_SESSION['domain_uuid']; - $database = new database; $agents = $database->select($sql, $parameters, 'all'); if (count($agents) > 0) { $agent = $agents[0]; diff --git a/app/call_forward/resources/classes/call_forward.php b/app/call_forward/resources/classes/call_forward.php index 0fdf152605..3d12d5f8fb 100644 --- a/app/call_forward/resources/classes/call_forward.php +++ b/app/call_forward/resources/classes/call_forward.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Copyright (C) 2010 - 2016 + Copyright (C) 2010 - 2022 All Rights Reserved. Contributor(s): @@ -44,13 +44,15 @@ public $outbound_caller_id_number; public function set() { + //create the database connection + $database = new database; + //determine whether to update the dial string $sql = "select * from v_extensions "; $sql .= "where domain_uuid = :domain_uuid "; $sql .= "and extension_uuid = :extension_uuid "; $parameters['domain_uuid'] = $this->domain_uuid; $parameters['extension_uuid'] = $this->extension_uuid; - $database = new database; $row = $database->select($sql, $parameters, 'row'); if (is_array($row) && @sizeof($row) != 0) { $this->extension = $row["extension"]; @@ -77,7 +79,6 @@ $p->add('extension_add', 'temp'); //execute update - $database = new database; $database->app_name = 'calls'; $database->app_uuid = '19806921-e8ed-dcff-b325-dd3e5da4959d'; $database->save($array); @@ -112,6 +113,9 @@ */ public function toggle($records) { + //create the database connection + $database = new database; + //assign private variables $this->app_name = 'calls'; $this->app_uuid = '19806921-e8ed-dcff-b325-dd3e5da4959d'; @@ -156,7 +160,6 @@ $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; $parameters['domain_uuid'] = $_SESSION['domain_uuid']; - $database = new database; $rows = $database->select($sql, $parameters, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { foreach ($rows as $row) { @@ -216,7 +219,6 @@ $p->add('extension_edit', 'temp'); //save the array - $database = new database; $database->app_name = $this->app_name; $database->app_uuid = $this->app_uuid; $database->save($array); diff --git a/app/devices/resources/dashboard/device_keys.php b/app/devices/resources/dashboard/device_keys.php index 459030c256..8a9de465da 100644 --- a/app/devices/resources/dashboard/device_keys.php +++ b/app/devices/resources/dashboard/device_keys.php @@ -34,6 +34,11 @@ $language = new text; $text = $language->get($_SESSION['domain']['language']['code'], 'app/devices'); +//connect to the database + if (!isset($database)) { + $database = new database; + } + //get the vendor functions $sql = "select v.name as vendor_name, f.name, f.value "; $sql .= "from v_device_vendors as v, v_device_vendor_functions as f "; @@ -57,7 +62,6 @@ $sql .= "and v.enabled = 'true' "; $sql .= "and f.enabled = 'true' "; $sql .= "order by v.name asc, f.name asc "; - $database = new database; $vendor_functions = $database->select($sql, (is_array($parameters) ? $parameters : null), 'all'); unset($sql, $sql_where_or, $parameters); @@ -79,7 +83,6 @@ $sql = "select device_uuid, device_profile_uuid from v_devices "; $sql .= "where device_user_uuid = :device_user_uuid "; $parameters['device_user_uuid'] = $_SESSION['user_uuid']; - $database = new database; $row = $database->select($sql, $parameters, 'row'); if (is_array($row) && @sizeof($row) != 0) { $device_uuid = $row['device_uuid']; @@ -92,7 +95,6 @@ $sql = "select * from v_device_keys "; $sql .= "where device_profile_uuid = :device_profile_uuid "; $parameters['device_profile_uuid'] = $device_profile_uuid; - $database = new database; $device_profile_keys = $database->select($sql, $parameters, 'all'); unset($sql, $parameters); } @@ -102,7 +104,6 @@ $sql = "select * from v_device_keys "; $sql .= "where device_uuid = :device_uuid "; $parameters['device_uuid'] = $device_uuid; - $database = new database; $device_keys = $database->select($sql, $parameters, 'all'); unset($sql, $parameters); } @@ -219,7 +220,6 @@ $sql = "select device_uuid from v_devices "; $sql .= "where device_user_uuid = :device_user_uuid "; $parameters['device_user_uuid'] = $_SESSION['user_uuid']; - $database = new database; $device_uuid = $database->select($sql, $parameters, 'column'); unset($sql, $parameters); } @@ -268,7 +268,6 @@ $p->add('device_key_edit', 'temp'); //save the changes - $database = new database; $database->app_name = 'devices'; $database->app_uuid = '4efa1a1a-32e7-bf83-534b-6c8299958a8e'; $database->save($array); @@ -305,7 +304,6 @@ $sql = "select device_uuid, device_profile_uuid from v_devices "; $sql .= "where device_user_uuid = :device_user_uuid "; $parameters['device_user_uuid'] = $_SESSION['user_uuid']; - $database = new database; $row = $database->select($sql, $parameters, 'row'); if (is_array($row) && @sizeof($row) != 0) { $device_uuid = $row['device_uuid']; @@ -318,7 +316,6 @@ $sql = "select * from v_device_lines "; $sql .= "where device_uuid = :device_uuid "; $parameters['device_uuid'] = $device_uuid; - $database = new database; $device_lines = $database->select($sql, $parameters, 'all'); unset($sql, $parameters); } @@ -358,7 +355,6 @@ if (is_uuid($device_profile_uuid)) { $parameters['device_profile_uuid'] = $device_profile_uuid; } - $database = new database; $keys = $database->select($sql, $parameters, 'all'); unset($sql, $parameters); } diff --git a/app/domain_limits/resources/dashboard/domain_limits.php b/app/domain_limits/resources/dashboard/domain_limits.php index b8def62db9..7d49d6b990 100644 --- a/app/domain_limits/resources/dashboard/domain_limits.php +++ b/app/domain_limits/resources/dashboard/domain_limits.php @@ -21,6 +21,11 @@ $language = new text; $text = $language->get($_SESSION['domain']['language']['code'], 'core/user_settings'); +//connect to the database + if (!isset($database)) { + $database = new database; + } + //domain limits if (is_array($_SESSION['limit']) && sizeof($_SESSION['limit']) > 0) { echo "
\n"; @@ -33,7 +38,6 @@ $sql = "select count(extension_uuid) from v_extensions "; $sql .= "where domain_uuid = :domain_uuid "; $parameters['domain_uuid'] = $_SESSION['domain_uuid']; - $database = new database; $extension_total = $database->select($sql, $parameters, 'column'); unset($sql, $parameters); @@ -45,7 +49,6 @@ $sql = "select count(destination_uuid) from v_destinations "; $sql .= "where domain_uuid = :domain_uuid "; $parameters['domain_uuid'] = $_SESSION['domain_uuid']; - $database = new database; $destination_total = $database->select($sql, $parameters, 'column'); unset($sql, $parameters); diff --git a/app/extensions/resources/dashboard/caller_id.php b/app/extensions/resources/dashboard/caller_id.php index af3e83a508..cc1575ecd9 100644 --- a/app/extensions/resources/dashboard/caller_id.php +++ b/app/extensions/resources/dashboard/caller_id.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2017 - 2021 + Portions created by the Initial Developer are Copyright (C) 2017 - 2022 the Initial Developer. All Rights Reserved. Contributor(s): @@ -39,6 +39,11 @@ $language = new text; $text = $language->get($_SESSION['domain']['language']['code'], 'app/extensions'); + //connect to the database + if (!isset($database)) { + $database = new database; + } + //add or update the database if (is_array($_POST['extensions']) && @sizeof($_POST['extensions']) != 0) { @@ -89,7 +94,6 @@ $p->add("extension_edit", "temp"); //save to the data - $database = new database; $database->app_name = 'extensions'; $database->app_uuid = 'e68d9689-2769-e013-28fa-6214bf47fca3'; $database->save($array); @@ -136,7 +140,6 @@ $sql .= "and destination_type = 'inbound' "; $sql .= "order by destination_caller_id_name asc, destination_caller_id_number asc"; $parameters['domain_uuid'] = $_SESSION['domain_uuid']; - $database = new database; $destinations = $database->select($sql, $parameters, 'all'); unset($sql, $parameters); diff --git a/app/ring_groups/resources/dashboard/ring_group_forward.php b/app/ring_groups/resources/dashboard/ring_group_forward.php index d26e6450c6..f8b1a24659 100644 --- a/app/ring_groups/resources/dashboard/ring_group_forward.php +++ b/app/ring_groups/resources/dashboard/ring_group_forward.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2013-2021 + Portions created by the Initial Developer are Copyright (C) 2013-2022 the Initial Developer. All Rights Reserved. Contributor(s): @@ -51,6 +51,11 @@ $order_by = $_GET["order_by"]; $order = $_GET["order"]; +//connect to the database + if (!isset($database)) { + $database = new database; + } + //find the path switch ($_SERVER['REQUEST_URI']) { case PROJECT_PATH."/core/dashboard/index.php": @@ -91,7 +96,6 @@ $p = new permissions; $p->add('ring_group_edit', 'temp'); - $database = new database; $database->app_name = 'ring_groups'; $database->app_uuid = '1d61fb65-1eec-bc73-a6ee-a6203b4fe6f2'; $database->save($array); @@ -125,7 +129,6 @@ $parameters['domain_uuid'] = $domain_uuid; $parameters['user_uuid'] = $_SESSION['user']['user_uuid']; } - $database = new database; $num_rows = $database->select($sql, $parameters, 'column'); unset($parameters); @@ -158,7 +161,6 @@ } $sql .= order_by($order_by, $order, 'ring_group_extension', 'asc'); $sql .= limit_offset($rows_per_page, $offset); - $database = new database; $result = $database->select($sql, $parameters, 'all'); unset($sql, $parameters); diff --git a/app/system/resources/dashboard/system_counts.php b/app/system/resources/dashboard/system_counts.php index 5d40b5bf10..6aeda93b0b 100644 --- a/app/system/resources/dashboard/system_counts.php +++ b/app/system/resources/dashboard/system_counts.php @@ -13,6 +13,11 @@ exit; } +//connect to the database + if (!isset($database)) { + $database = new database; + } + //add multi-lingual support $language = new text; $text = $language->get($_SESSION['domain']['language']['code'], 'core/user_settings'); @@ -34,7 +39,6 @@ $stats['domain']['devices']['total'] = 0; $stats['domain']['devices']['disabled'] = 0; $sql = "select domain_uuid, device_enabled from v_devices"; - $database = new database; $result = $database->select($sql, null, 'all'); if (is_array($result) && sizeof($result) != 0) { $stats['system']['devices']['total'] = sizeof($result); @@ -56,7 +60,6 @@ $stats['domain']['extensions']['total'] = 0; $stats['domain']['extensions']['disabled'] = 0; $sql = "select domain_uuid, enabled from v_extensions"; - $database = new database; $result = $database->select($sql, null, 'all'); if (is_array($result) && sizeof($result) != 0) { $stats['system']['extensions']['total'] = sizeof($result); @@ -78,7 +81,6 @@ $stats['domain']['gateways']['total'] = 0; $stats['domain']['gateways']['disabled'] = 0; $sql = "select domain_uuid, enabled from v_gateways"; - $database = new database; $result = $database->select($sql, null, 'all'); if (is_array($result) && sizeof($result) != 0) { $stats['system']['gateways']['total'] = sizeof($result); @@ -100,7 +102,6 @@ $stats['domain']['users']['total'] = 0; $stats['domain']['users']['disabled'] = 0; $sql = "select domain_uuid, user_enabled from v_users"; - $database = new database; $result = $database->select($sql, null, 'all'); if (is_array($result) && sizeof($result) != 0) { $stats['system']['users']['total'] = sizeof($result); @@ -122,7 +123,6 @@ $stats['domain']['destinations']['total'] = 0; $stats['domain']['destinations']['disabled'] = 0; $sql = "select domain_uuid, destination_enabled from v_destinations"; - $database = new database; $result = $database->select($sql, null, 'all'); if (is_array($result) && sizeof($result) != 0) { $stats['system']['destinations']['total'] = sizeof($result); @@ -144,7 +144,6 @@ $stats['domain']['call_center_queues']['total'] = 0; $stats['domain']['call_center_queues']['disabled'] = 0; $sql = "select domain_uuid from v_call_center_queues"; - $database = new database; $result = $database->select($sql, null, 'all'); if (is_array($result) && sizeof($result) != 0) { $stats['system']['call_center_queues']['total'] = sizeof($result); @@ -166,7 +165,6 @@ $stats['domain']['ivr_menus']['total'] = 0; $stats['domain']['ivr_menus']['disabled'] = 0; $sql = "select domain_uuid, ivr_menu_enabled from v_ivr_menus"; - $database = new database; $result = $database->select($sql, null, 'all'); if (is_array($result) && sizeof($result) != 0) { $stats['system']['ivr_menus']['total'] = sizeof($result); @@ -188,7 +186,6 @@ $stats['domain']['ring_groups']['total'] = 0; $stats['domain']['ring_groups']['disabled'] = 0; $sql = "select domain_uuid, ring_group_enabled from v_ring_groups"; - $database = new database; $result = $database->select($sql, null, 'all'); if (is_array($result) && sizeof($result) != 0) { $stats['system']['ring_groups']['total'] = sizeof($result); @@ -210,7 +207,6 @@ $stats['domain']['voicemails']['total'] = 0; $stats['domain']['voicemails']['disabled'] = 0; $sql = "select domain_uuid, voicemail_enabled from v_voicemails"; - $database = new database; $result = $database->select($sql, null, 'all'); if (is_array($result) && sizeof($result) != 0) { $stats['system']['voicemails']['total'] = sizeof($result); @@ -232,7 +228,6 @@ $stats['domain']['messages']['total'] = 0; $stats['domain']['messages']['new'] = 0; $sql = "select domain_uuid, message_status from v_voicemail_messages"; - $database = new database; $result = $database->select($sql, null, 'all'); if (is_array($result) && sizeof($result) != 0) { $stats['system']['messages']['total'] = sizeof($result); @@ -256,7 +251,6 @@ $sql = "select "; $sql .= "(select count(*) from v_domains where domain_enabled = 'true') as active, "; $sql .= "(select count(*) from v_domains where domain_enabled = 'false') as inactive; "; - $database = new database; $row = $database->select($sql, null, 'row'); $domain_active = $row['active']; $domain_inactive = $row['inactive']; diff --git a/app/system/resources/dashboard/system_status.php b/app/system/resources/dashboard/system_status.php index 8e9d24393e..cc90892dd0 100644 --- a/app/system/resources/dashboard/system_status.php +++ b/app/system/resources/dashboard/system_status.php @@ -194,7 +194,7 @@ } } if ($sql != '') { - $database = new database; + if (!isset($database)) { $database = new database; } $connections = $database->select($sql, null, 'column'); unset($sql); } diff --git a/app/xml_cdr/resources/dashboard/missed_calls.php b/app/xml_cdr/resources/dashboard/missed_calls.php index b37dfd8137..48aa72a098 100644 --- a/app/xml_cdr/resources/dashboard/missed_calls.php +++ b/app/xml_cdr/resources/dashboard/missed_calls.php @@ -70,7 +70,7 @@ $parameters['domain_uuid'] = $_SESSION['domain_uuid']; //echo $sql; //view_array($parameters); - $database = new database; + if (!isset($database)) { $database = new database; } $result = $database->select($sql, $parameters, 'all'); $num_rows = is_array($result) ? sizeof($result) : 0; diff --git a/app/xml_cdr/resources/dashboard/recent_calls.php b/app/xml_cdr/resources/dashboard/recent_calls.php index 24d6f1bafb..44e76e88fb 100644 --- a/app/xml_cdr/resources/dashboard/recent_calls.php +++ b/app/xml_cdr/resources/dashboard/recent_calls.php @@ -70,7 +70,7 @@ order by start_epoch desc"; $parameters['domain_uuid'] = $_SESSION['domain_uuid']; - $database = new database; + if (!isset($database)) { $database = new database; } $result = $database->select($sql, $parameters, 'all'); $num_rows = is_array($result) ? sizeof($result) : 0;