From 032a5aec39e279fdbf5e9208d9902942c5f1fb95 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Tue, 9 Nov 2021 18:42:14 -0700 Subject: [PATCH] Add a new dashboard --- .../dashboard/call_center_agents.php} | 1 - .../resources/dashboard/config.php | 14 + app/call_forward/call_forward.php | 12 +- app/call_forward/call_forward_edit.php | 2 +- .../resources/dashboard/call_forward.php | 51 ++ .../resources/dashboard/config.php | 22 + app/devices/resources/dashboard/config.php | 14 + .../dashboard/device_keys.php} | 0 .../resources/dashboard/config.php | 22 + .../resources/dashboard/domain_limits.php | 117 +++++ .../dashboard/caller_id.php} | 16 +- app/extensions/resources/dashboard/config.php | 22 + app/follow_me/app_menu.php | 2 +- .../resources/dashboard/config.php | 22 + .../dashboard}/ring_group_forward.php | 7 +- app/ring_groups/resources/dashboard/root.php | 90 ++++ app/system/resources/dashboard/config.php | 30 ++ .../resources/dashboard/system_counts.php | 197 ++++++++ .../resources/dashboard/system_status.php | 204 ++++++++ app/voicemails/resources/dashboard/config.php | 22 + .../resources/dashboard/voicemails.php | 94 ++++ app/xml_cdr/resources/dashboard/config.php | 43 ++ .../resources/dashboard/missed_calls.php | 144 ++++++ .../resources/dashboard/recent_calls.php | 176 +++++++ app/xml_cdr/resources/dashboard/root.php | 90 ++++ core/dashboard/app_config.php | 118 +++++ core/dashboard/app_defaults.php | 64 +++ core/dashboard/app_languages.php | 349 ++++++++++++++ core/dashboard/app_menu.php | 17 + core/dashboard/dashboard.php | 351 ++++++++++++++ core/dashboard/dashboard_edit.php | 450 ++++++++++++++++++ core/dashboard/index.php | 155 ++++++ .../dashboard/resources/classes/dashboard.php | 261 ++++++++++ core/dashboard/root.php | 90 ++++ 34 files changed, 3249 insertions(+), 20 deletions(-) rename app/call_centers/{call_center_agent_dashboard.php => resources/dashboard/call_center_agents.php} (99%) create mode 100644 app/call_centers/resources/dashboard/config.php create mode 100644 app/call_forward/resources/dashboard/call_forward.php create mode 100644 app/call_forward/resources/dashboard/config.php create mode 100644 app/devices/resources/dashboard/config.php rename app/devices/{device_dashboard.php => resources/dashboard/device_keys.php} (100%) create mode 100644 app/domain_limits/resources/dashboard/config.php create mode 100644 app/domain_limits/resources/dashboard/domain_limits.php rename app/extensions/{extension_dashboard.php => resources/dashboard/caller_id.php} (95%) create mode 100644 app/extensions/resources/dashboard/config.php create mode 100644 app/ring_groups/resources/dashboard/config.php rename app/ring_groups/{ => resources/dashboard}/ring_group_forward.php (97%) create mode 100644 app/ring_groups/resources/dashboard/root.php create mode 100644 app/system/resources/dashboard/config.php create mode 100644 app/system/resources/dashboard/system_counts.php create mode 100644 app/system/resources/dashboard/system_status.php create mode 100644 app/voicemails/resources/dashboard/config.php create mode 100644 app/voicemails/resources/dashboard/voicemails.php create mode 100644 app/xml_cdr/resources/dashboard/config.php create mode 100644 app/xml_cdr/resources/dashboard/missed_calls.php create mode 100644 app/xml_cdr/resources/dashboard/recent_calls.php create mode 100644 app/xml_cdr/resources/dashboard/root.php create mode 100644 core/dashboard/app_config.php create mode 100644 core/dashboard/app_defaults.php create mode 100644 core/dashboard/app_languages.php create mode 100644 core/dashboard/app_menu.php create mode 100644 core/dashboard/dashboard.php create mode 100644 core/dashboard/dashboard_edit.php create mode 100644 core/dashboard/index.php create mode 100644 core/dashboard/resources/classes/dashboard.php create mode 100644 core/dashboard/root.php diff --git a/app/call_centers/call_center_agent_dashboard.php b/app/call_centers/resources/dashboard/call_center_agents.php similarity index 99% rename from app/call_centers/call_center_agent_dashboard.php rename to app/call_centers/resources/dashboard/call_center_agents.php index c0a1ab3871..415b96c9a0 100644 --- a/app/call_centers/call_center_agent_dashboard.php +++ b/app/call_centers/resources/dashboard/call_center_agents.php @@ -28,7 +28,6 @@ require_once "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; - require_once "resources/paging.php"; //check permissions if (permission_exists('call_center_queue_view')) { diff --git a/app/call_centers/resources/dashboard/config.php b/app/call_centers/resources/dashboard/config.php new file mode 100644 index 0000000000..3a8d7a841b --- /dev/null +++ b/app/call_centers/resources/dashboard/config.php @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/app/call_forward/call_forward.php b/app/call_forward/call_forward.php index ff66f5bcbf..ffb4c1da49 100644 --- a/app/call_forward/call_forward.php +++ b/app/call_forward/call_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) 2008-2019 + Portions created by the Initial Developer are Copyright (C) 2008-2021 the Initial Developer. All Rights Reserved. Contributor(s): @@ -41,7 +41,7 @@ //add multi-lingual support $language = new text; - $text = $language->get($_SESSION['domain']['language']['code'], 'app/calls'); + $text = $language->get($_SESSION['domain']['language']['code'], 'app/call_forward'); //get posted data if (is_array($_POST['extensions'])) { @@ -73,7 +73,7 @@ break; } - header('Location: calls.php'.($search != '' ? '?search='.urlencode($search) : null)); + header('Location: call_forward.php'.($search != '' ? '?search='.urlencode($search) : null)); exit; } @@ -200,7 +200,7 @@ echo "
".$text['header-call_forward']."
\n"; echo "
\n"; if ($num_rows > 10) { - echo button::create(['type'=>'button','label'=>$text['button-view_all'],'icon'=>'project-diagram','collapse'=>false,'link'=>PROJECT_PATH.'/app/calls/calls.php']); + echo button::create(['type'=>'button','label'=>$text['button-view_all'],'icon'=>'project-diagram','collapse'=>false,'link'=>PROJECT_PATH.'/app/call_forward/call_forward.php']); } echo "
\n"; echo "
\n"; @@ -231,7 +231,7 @@ } echo ""; echo button::create(['label'=>$text['button-search'],'icon'=>$_SESSION['theme']['button_icon_search'],'type'=>'submit','id'=>'btn_search','style'=>($search != '' ? 'display: none;' : null)]); - echo button::create(['label'=>$text['button-reset'],'icon'=>$_SESSION['theme']['button_icon_reset'],'type'=>'button','id'=>'btn_reset','link'=>'calls.php','style'=>($search == '' ? 'display: none;' : null)]); + echo button::create(['label'=>$text['button-reset'],'icon'=>$_SESSION['theme']['button_icon_reset'],'type'=>'button','id'=>'btn_reset','link'=>'call_forward.php','style'=>($search == '' ? 'display: none;' : null)]); if ($paging_controls_mini != '') { echo "".$paging_controls_mini.""; } @@ -284,7 +284,7 @@ if (is_array($extensions)) { $x = 0; foreach($extensions as $row) { - $list_row_url = PROJECT_PATH."/app/calls/call_edit.php?id=".$row['extension_uuid']."&return_url=".urlencode($_SERVER['REQUEST_URI']); + $list_row_url = PROJECT_PATH."/app/call_forward/call_forward_edit.php?id=".$row['extension_uuid']."&return_url=".urlencode($_SERVER['REQUEST_URI']); echo "\n"; if (!$is_included && $extensions) { echo " \n"; diff --git a/app/call_forward/call_forward_edit.php b/app/call_forward/call_forward_edit.php index 0d864908d3..537fcd131a 100644 --- a/app/call_forward/call_forward_edit.php +++ b/app/call_forward/call_forward_edit.php @@ -495,7 +495,7 @@ echo "
\n"; echo "
".$text['title-call_forward']."
\n"; echo "
\n"; - echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','link'=>'calls.php']); + echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','link'=>'call_forward.php']); echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'id'=>'btn_save','style'=>'margin-left: 15px;']); echo "
\n"; echo "
\n"; diff --git a/app/call_forward/resources/dashboard/call_forward.php b/app/call_forward/resources/dashboard/call_forward.php new file mode 100644 index 0000000000..2034b93392 --- /dev/null +++ b/app/call_forward/resources/dashboard/call_forward.php @@ -0,0 +1,51 @@ + + Portions created by the Initial Developer are Copyright (C) 2021 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +//includes + //require_once "root.php"; + require_once "resources/require.php"; + require_once "resources/check_auth.php"; + +//check permissions + if (permission_exists('follow_me') || permission_exists('call_forward') || permission_exists('do_not_disturb')) { + //access granted + } + else { + echo "access denied"; + exit; + } + +//add multi-lingual support + $language = new text; + $text = $language->get($_SESSION['domain']['language']['code'], 'app/call_forward'); + +//set a variable for the included code to know its included + $is_included = true; + +//include the call forward + require_once "app/call_forward/call_forward.php"; + +?> diff --git a/app/call_forward/resources/dashboard/config.php b/app/call_forward/resources/dashboard/config.php new file mode 100644 index 0000000000..eeb58b4311 --- /dev/null +++ b/app/call_forward/resources/dashboard/config.php @@ -0,0 +1,22 @@ + \ No newline at end of file diff --git a/app/devices/resources/dashboard/config.php b/app/devices/resources/dashboard/config.php new file mode 100644 index 0000000000..a193daa0e3 --- /dev/null +++ b/app/devices/resources/dashboard/config.php @@ -0,0 +1,14 @@ + diff --git a/app/devices/device_dashboard.php b/app/devices/resources/dashboard/device_keys.php similarity index 100% rename from app/devices/device_dashboard.php rename to app/devices/resources/dashboard/device_keys.php diff --git a/app/domain_limits/resources/dashboard/config.php b/app/domain_limits/resources/dashboard/config.php new file mode 100644 index 0000000000..c13050bb38 --- /dev/null +++ b/app/domain_limits/resources/dashboard/config.php @@ -0,0 +1,22 @@ + \ No newline at end of file diff --git a/app/domain_limits/resources/dashboard/domain_limits.php b/app/domain_limits/resources/dashboard/domain_limits.php new file mode 100644 index 0000000000..7deac8bfa5 --- /dev/null +++ b/app/domain_limits/resources/dashboard/domain_limits.php @@ -0,0 +1,117 @@ +get($_SESSION['domain']['language']['code'], 'core/user_settings'); + +//domain limits + if (is_array($_SESSION['limit']) && sizeof($_SESSION['limit']) > 0) { + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + $show_stat = true; + if (permission_exists('extension_view')) { + $sql = "select count(extension_uuid) from v_extensions "; + $database = new database; + $extension_total = $database->select($sql, null, 'column'); + + $onclick = "onclick=\"document.location.href='".PROJECT_PATH."/app/extensions/extensions.php'\""; + $hud_stat = $extension_total; + $hud_stat_title = $text['label-total_extensions']; + } + else if (permission_exists('destination_view')) { + $sql = "select count(destination_uuid) from v_destinations "; + $database = new database; + $destination_total = $database->select($sql, null, 'column'); + + $onclick = "onclick=\"document.location.href='".PROJECT_PATH."/app/destinations/destinations.php'\""; + $hud_stat = $destination_total; + $hud_stat_title = $text['label-total_destinations']; + } + else { + $show_stat = false; + } + + echo "".$text['label-domain_limits'].""; + + if ($show_stat) { + echo "".$hud_stat.""; + echo "".$hud_stat_title."\n"; + } + + echo "
"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + foreach ($_SESSION['limit'] as $category => $value) { + $limit = $value['numeric']; + switch ($category) { + case 'users': + if (!permission_exists('user_view')) { continue 2; } + $url = '/core/users/users.php'; + break; + case 'call_center_queues': + if (!permission_exists('call_center_active_view')) { continue 2; } + $url = '/app/call_centers/call_center_queues.php'; + break; + case 'destinations': + if (!permission_exists('destination_view')) { continue 2; } + $url = '/app/destinations/destinations.php'; + break; + case 'devices': + if (!permission_exists('device_view')) { continue 2; } + $url = '/app/devices/devices.php'; + break; + case 'extensions': + if (!permission_exists('extension_view')) { continue 2; } + $url = '/app/extensions/extensions.php'; + break; + case 'gateways': + if (!permission_exists('gateway_view')) { continue 2; } + $url = '/app/gateways/gateways.php'; + break; + case 'ivr_menus': + if (!permission_exists('ivr_menu_view')) { continue 2; } + $url = '/app/ivr_menus/ivr_menus.php'; + break; + case 'ring_groups': + if (!permission_exists('ring_group_view')) { continue 2; } + $url = '/app/ring_groups/ring_groups.php'; + break; + } + $tr_link = "href='".PROJECT_PATH.$url."'"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + $c = ($c) ? 0 : 1; + } + + echo "
".$text['label-feature']."".$text['label-used']."".$text['label-total']."
".$text['label-'.$category]."".$stats['domain'][$category]['total']."".$limit."
\n"; + echo "
"; + $n++; + + echo " "; + } + +?> \ No newline at end of file diff --git a/app/extensions/extension_dashboard.php b/app/extensions/resources/dashboard/caller_id.php similarity index 95% rename from app/extensions/extension_dashboard.php rename to app/extensions/resources/dashboard/caller_id.php index 9c1e9b7771..e9973e00b4 100644 --- a/app/extensions/extension_dashboard.php +++ b/app/extensions/resources/dashboard/caller_id.php @@ -101,14 +101,14 @@ //update the session array foreach ($array['extensions'] as $row) { - $x=0; - foreach ($_SESSION['user']['extension'] as $field) { - if ($field['extension_uuid'] == $row['extension_uuid']) { - $_SESSION['user']['extension'][$x]['outbound_caller_id_name'] = $row['outbound_caller_id_name']; - $_SESSION['user']['extension'][$x]['outbound_caller_id_number'] = $row['outbound_caller_id_number']; - } - $x++; + $x=0; + foreach ($_SESSION['user']['extension'] as $field) { + if ($field['extension_uuid'] == $row['extension_uuid']) { + $_SESSION['user']['extension'][$x]['outbound_caller_id_name'] = $row['outbound_caller_id_name']; + $_SESSION['user']['extension'][$x]['outbound_caller_id_number'] = $row['outbound_caller_id_number']; } + $x++; + } } //remove the temporary permission @@ -232,4 +232,4 @@ echo "\n"; echo "\n"; -?> \ No newline at end of file +?> diff --git a/app/extensions/resources/dashboard/config.php b/app/extensions/resources/dashboard/config.php new file mode 100644 index 0000000000..0511fb03b2 --- /dev/null +++ b/app/extensions/resources/dashboard/config.php @@ -0,0 +1,22 @@ + diff --git a/app/follow_me/app_menu.php b/app/follow_me/app_menu.php index 49a62f75da..f8760ac645 100644 --- a/app/follow_me/app_menu.php +++ b/app/follow_me/app_menu.php @@ -24,7 +24,7 @@ $apps[$x]['menu'][$y]['uuid'] = "a1144e12-873e-4722-9818-02da1adb6ba3"; $apps[$x]['menu'][$y]['parent_uuid'] = "fd29e39c-c936-f5fc-8e2b-611681b266b5"; $apps[$x]['menu'][$y]['category'] = "internal"; - $apps[$x]['menu'][$y]['path'] = "/app/calls/calls.php"; + $apps[$x]['menu'][$y]['path'] = "/app/call_forward/call_forward.php"; $apps[$x]['menu'][$y]['groups'][] = "superadmin"; $apps[$x]['menu'][$y]['groups'][] = "admin"; $apps[$x]['menu'][$y]['groups'][] = "user"; diff --git a/app/ring_groups/resources/dashboard/config.php b/app/ring_groups/resources/dashboard/config.php new file mode 100644 index 0000000000..4afeb8de21 --- /dev/null +++ b/app/ring_groups/resources/dashboard/config.php @@ -0,0 +1,22 @@ + diff --git a/app/ring_groups/ring_group_forward.php b/app/ring_groups/resources/dashboard/ring_group_forward.php similarity index 97% rename from app/ring_groups/ring_group_forward.php rename to app/ring_groups/resources/dashboard/ring_group_forward.php index 3161c4fc87..d69b32487b 100644 --- a/app/ring_groups/ring_group_forward.php +++ b/app/ring_groups/resources/dashboard/ring_group_forward.php @@ -59,14 +59,14 @@ //find the path switch ($_SERVER['REQUEST_URI']) { - case PROJECT_PATH."/core/user_settings/user_dashboard.php": - $validated_path = PROJECT_PATH."/core/user_settings/user_dashboard.php"; + case PROJECT_PATH."/app/dashboard/index.php": + $validated_path = PROJECT_PATH."/app/dashboard/index.php"; break; case PROJECT_PATH."/app/ring_groups/ring_group_forward.php": $validated_path = PROJECT_PATH."/app/ring_groups/ring_group_forward.php"; break; default: - $validated_path = PROJECT_PATH."/app/ring_groups/ring_group_forward.php"; + $validated_path = PROJECT_PATH."/app/ring_groups/resources/dashboard/ring_group_forward.php"; } //update ring group forwarding @@ -107,6 +107,7 @@ //set message message::add($text['message-update']); + $validated_path = PROJECT_PATH."/app/dashboard/index.php"; //redirect the user header("Location: ".$validated_path); diff --git a/app/ring_groups/resources/dashboard/root.php b/app/ring_groups/resources/dashboard/root.php new file mode 100644 index 0000000000..6fdf32f37b --- /dev/null +++ b/app/ring_groups/resources/dashboard/root.php @@ -0,0 +1,90 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + umask(2); + if (!defined("PATH_SEPARATOR")) { + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } + } + + if (!isset($output_format)) $output_format = (PHP_SAPI == 'cli') ? 'text' : 'html'; + + // make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", '/', $_SERVER["SCRIPT_FILENAME"]); + if(PHP_SAPI == 'cli'){ + chdir(pathinfo(realpath($_SERVER["PHP_SELF"]), PATHINFO_DIRNAME)); + $script_full_path = str_replace("\\", '/', getcwd() . '/' . $_SERVER["SCRIPT_FILENAME"]); + $dirs = explode('/', pathinfo($script_full_path, PATHINFO_DIRNAME)); + if (file_exists('/project_root.php')) { + $path = '/'; + } else { + $i = 1; + $path = ''; + while ($i < count($dirs)) { + $path .= '/' . $dirs[$i]; + if (file_exists($path. '/project_root.php')) { + break; + } + $i++; + } + } + $_SERVER["DOCUMENT_ROOT"] = $path; + }else{ + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + } + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"]. '/fusionpbx')) { + define('PROJECT_PATH', '/fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"]. '/project_root.php')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= '/' . $dirs[$i]; + if (file_exists($path. '/project_root.php')) { + break; + } + $i++; + } + if(!file_exists($path. '/project_root.php')){ + die("Failed to locate the Project Root by searching for project_root.php please contact support for assistance"); + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); + } + +?> \ No newline at end of file diff --git a/app/system/resources/dashboard/config.php b/app/system/resources/dashboard/config.php new file mode 100644 index 0000000000..1d4816bf3f --- /dev/null +++ b/app/system/resources/dashboard/config.php @@ -0,0 +1,30 @@ + \ No newline at end of file diff --git a/app/system/resources/dashboard/system_counts.php b/app/system/resources/dashboard/system_counts.php new file mode 100644 index 0000000000..c3081b4c4b --- /dev/null +++ b/app/system/resources/dashboard/system_counts.php @@ -0,0 +1,197 @@ +get($_SESSION['domain']['language']['code'], 'core/user_settings'); + +//system counts + //if (is_array($selected_blocks) && in_array('counts', $selected_blocks)) { + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + $scope = (permission_exists('dialplan_add')) ? 'system' : 'domain'; + + $show_stat = true; + if (permission_exists('domain_view')) { + $onclick = "onclick=\"document.location.href='".PROJECT_PATH."/core/domains/domains.php'\""; + $hud_stat = $stats[$scope]['domains']['total'] - $stats[$scope]['domains']['disabled']; + $hud_stat_title = $text['label-active_domains']; + } + else if (permission_exists('extension_view') && file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/extensions/")) { + $onclick = "onclick=\"document.location.href='".PROJECT_PATH."/app/extensions/extensions.php'\""; + $hud_stat = $stats[$scope]['extensions']['total'] - $stats[$scope]['extensions']['disabled']; + $hud_stat_title = $text['label-active_extensions']; + } + else if ((permission_exists('user_view') || if_group("superadmin")) && file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/core/users/")) { + $onclick = "onclick=\"document.location.href='".PROJECT_PATH."/core/users/users.php'\""; + $hud_stat = $stats[$scope]['users']['total'] - $stats[$scope]['users']['disabled']; + $hud_stat_title = $text['label-active_users']; + } + else { + $show_stat = false; + } + + echo "".$text['label-system_counts'].""; + + if ($show_stat) { + echo "".$hud_stat.""; + echo "".$hud_stat_title."\n"; + } + + echo "
"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + //domains + if (permission_exists('domain_view')) { + $tr_link = "href='".PROJECT_PATH."/core/domains/domains.php'"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + $c = ($c) ? 0 : 1; + } + + //devices + if (permission_exists('device_view') && file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/devices/")) { + $tr_link = "href='".PROJECT_PATH."/app/devices/devices.php'"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + $c = ($c) ? 0 : 1; + } + + //extensions + if (permission_exists('extension_view') && file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/extensions/")) { + $tr_link = "href='".PROJECT_PATH."/app/extensions/extensions.php'"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + $c = ($c) ? 0 : 1; + } + + //gateways + if (permission_exists('gateway_view') && file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/gateways/")) { + $tr_link = "href='".PROJECT_PATH."/app/gateways/gateways.php'"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + $c = ($c) ? 0 : 1; + } + + //users + if ((permission_exists('user_view') || if_group("superadmin")) && file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/core/users/")) { + $tr_link = "href='".PROJECT_PATH."/core/users/users.php'"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + $c = ($c) ? 0 : 1; + } + + //destinations + if (permission_exists('destination_view') && file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/destinations/")) { + $tr_link = "href='".PROJECT_PATH."/app/destinations/destinations.php'"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + $c = ($c) ? 0 : 1; + } + + //call center queues + if (permission_exists('call_center_active_view') && file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/call_centers/")) { + $tr_link = "href='".PROJECT_PATH."/app/call_centers/call_center_queues.php'"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + $c = ($c) ? 0 : 1; + } + + //ivr menus + if (permission_exists('ivr_menu_view') && file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/ivr_menus/")) { + $tr_link = "href='".PROJECT_PATH."/app/ivr_menus/ivr_menus.php'"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + $c = ($c) ? 0 : 1; + } + + //ring groups + if (permission_exists('ring_group_view') && file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/ring_groups/")) { + $tr_link = "href='".PROJECT_PATH."/app/ring_groups/ring_groups.php'"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + $c = ($c) ? 0 : 1; + } + + //voicemails + if (permission_exists('voicemail_view') && file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/voicemails/")) { + $tr_link = "href='".PROJECT_PATH."/app/voicemails/voicemails.php'"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + $c = ($c) ? 0 : 1; + } + + //messages + if (permission_exists('voicemail_message_view') && file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/voicemails/")) { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + $tr_link = "href='".PROJECT_PATH."/app/voicemails/voicemails.php'"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + $c = ($c) ? 0 : 1; + } + + echo "
".$text['label-item']."".$text['label-disabled']."".$text['label-total']."
".$text['label-domains']."".$stats[$scope]['domains']['disabled']."".$stats[$scope]['domains']['total']."
".$text['label-devices']."".$stats[$scope]['devices']['disabled']."".$stats[$scope]['devices']['total']."
".$text['label-extensions']."".$stats[$scope]['extensions']['disabled']."".$stats[$scope]['extensions']['total']."
".$text['label-gateways']."".$stats[$scope]['gateways']['disabled']."".$stats[$scope]['gateways']['total']."
".$text['label-users']."".$stats[$scope]['users']['disabled']."".$stats[$scope]['users']['total']."
".$text['label-destinations']."".$stats[$scope]['destinations']['disabled']."".$stats[$scope]['destinations']['total']."
".$text['label-call_center_queues']."".$stats[$scope]['call_center_queues']['disabled']."".$stats[$scope]['call_center_queues']['total']."
".$text['label-ivr_menus']."".$stats[$scope]['ivr_menus']['disabled']."".$stats[$scope]['ivr_menus']['total']."
".$text['label-ring_groups']."".$stats[$scope]['ring_groups']['disabled']."".$stats[$scope]['ring_groups']['total']."
".$text['label-voicemail']."".$stats[$scope]['voicemails']['disabled']."".$stats[$scope]['voicemails']['total']."
".$text['label-item']."".$text['label-new']."".$text['label-total']."
".$text['label-messages']."".$stats[$scope]['messages']['new']."".$stats[$scope]['messages']['total']."
\n"; + echo "
"; + $n++; + //} + echo " "; + +?> \ No newline at end of file diff --git a/app/system/resources/dashboard/system_status.php b/app/system/resources/dashboard/system_status.php new file mode 100644 index 0000000000..806d408d47 --- /dev/null +++ b/app/system/resources/dashboard/system_status.php @@ -0,0 +1,204 @@ +get($_SESSION['domain']['language']['code'], 'core/user_settings'); + +//system status + //if (is_array($selected_blocks) && in_array('system', $selected_blocks)) { + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "".$text['label-system_status'].""; + + //disk usage + if (PHP_OS == 'FreeBSD' || PHP_OS == 'Linux') { + $tmp = shell_exec("df /home 2>&1"); + $tmp = explode("\n", $tmp); + $tmp = preg_replace('!\s+!', ' ', $tmp[1]); // multiple > single space + $tmp = explode(' ', $tmp); + foreach ($tmp as $stat) { + if (substr_count($stat, '%') > 0) { $percent_disk_usage = rtrim($stat,'%'); break; } + } + + if ($percent_disk_usage != '') { + echo "".$percent_disk_usage.""; + echo "".$text['label-disk_usage']." (%)\n"; + } + } + + echo "".$num_rows.""; + + echo "
"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + //pbx version + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + $c = ($c) ? 0 : 1; + + //os uptime + if (stristr(PHP_OS, 'Linux')) { + unset($tmp); + $cut = shell_exec("/usr/bin/which cut"); + $uptime = trim(shell_exec(escapeshellcmd($cut." -d. -f1 /proc/uptime"))); + $tmp['y'] = floor($uptime/60/60/24/365); + $tmp['d'] = $uptime/60/60/24%365; + $tmp['h'] = $uptime/60/60%24; + $tmp['m'] = $uptime/60%60; + $tmp['s'] = $uptime%60; + $uptime = (($tmp['y'] != 0 && $tmp['y'] != '') ? $tmp['y'].'y ' : null); + $uptime .= (($tmp['d'] != 0 && $tmp['d'] != '') ? $tmp['d'].'d ' : null); + $uptime .= (($tmp['h'] != 0 && $tmp['h'] != '') ? $tmp['h'].'h ' : null); + $uptime .= (($tmp['m'] != 0 && $tmp['m'] != '') ? $tmp['m'].'m ' : null); + $uptime .= (($tmp['s'] != 0 && $tmp['s'] != '') ? $tmp['s'].'s' : null); + if ($uptime != '') { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + $c = ($c) ? 0 : 1; + } + } + + //memory usage (for available memory, use "free | awk 'FNR == 3 {print $4/($3+$4)*100}'" instead) + if (stristr(PHP_OS, 'Linux')) { + $free = shell_exec("/usr/bin/which free"); + $awk = shell_exec("/usr/bin/which awk"); + $percent_memory = round(shell_exec(escapeshellcmd($free." | ".$awk." 'FNR == 3 {print $3/($3+$4)*100}'")), 1); + if ($percent_memory != '') { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + $c = ($c) ? 0 : 1; + } + } + + //memory available + if (stristr(PHP_OS, 'Linux')) { + $result = trim(shell_exec('free -hw | grep \'Mem:\' | cut -d\' \' -f 55-64')); + if ($result != '') { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + $c = ($c) ? 0 : 1; + } + } + + //disk usage + if (stristr(PHP_OS, 'Linux')) { + //calculated above + if ($percent_disk_usage != '') { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + $c = ($c) ? 0 : 1; + } + } + + //cpu usage + if (stristr(PHP_OS, 'Linux')) { + $result = shell_exec('ps -A -o pcpu'); + $percent_cpu = 0; + foreach (explode("\n", $result) as $value) { + if (is_numeric($value)) { $percent_cpu = $percent_cpu + $value; } + } + $result = trim(shell_exec("grep -P '^processor' /proc/cpuinfo")); + $cores = count(explode("\n", $result)); + if ($percent_cpu > 1) { $percent_cpu = $percent_cpu / $cores; } + $percent_cpu = round($percent_cpu, 2); + if ($percent_cpu != '') { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + $c = ($c) ? 0 : 1; + } + } + + //db connections + switch ($db_type) { + case 'pgsql': + $sql = "select count(*) from pg_stat_activity"; + break; + case 'mysql': + $sql = "show status where `variable_name` = 'Threads_connected'"; + break; + default: + unset($sql); + if ($db_path != '' && $dbfilename != '') { + $tmp = shell_exec("lsof ".realpath($db_path).'/'.$dbfilename); + $tmp = explode("\n", $tmp); + $connections = sizeof($tmp) - 1; + } + } + if ($sql != '') { + $database = new database; + $connections = $database->select($sql, null, 'column'); + unset($sql); + } + if ($connections != '') { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + $c = ($c) ? 0 : 1; + } + + //channel count + if ($fp) { + $tmp = event_socket_request($fp, 'api status'); + $matches = Array(); + preg_match("/(\d+)\s+session\(s\)\s+\-\speak/", $tmp, $matches); + $channels = $matches[1] ? $matches[1] : 0; + $tr_link = "href='".PROJECT_PATH."/app/calls_active/calls_active.php'"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + $c = ($c) ? 0 : 1; + } + + //registration count + if ($fp && file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/registrations/")) { + $registration = new registrations; + $registrations = $registration->count(); + $tr_link = "href='".PROJECT_PATH."/app/registrations/registrations.php'"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + $c = ($c) ? 0 : 1; + } + + echo "
".$text['label-item']."".$text['label-value']."
".$text['label-channels']."".$channels."
".$text['label-registrations']."".$registrations."
\n"; + echo "
"; + $n++; + //} + echo " "; + +?> \ No newline at end of file diff --git a/app/voicemails/resources/dashboard/config.php b/app/voicemails/resources/dashboard/config.php new file mode 100644 index 0000000000..f57f25e41a --- /dev/null +++ b/app/voicemails/resources/dashboard/config.php @@ -0,0 +1,22 @@ + diff --git a/app/voicemails/resources/dashboard/voicemails.php b/app/voicemails/resources/dashboard/voicemails.php new file mode 100644 index 0000000000..ad1171f0cc --- /dev/null +++ b/app/voicemails/resources/dashboard/voicemails.php @@ -0,0 +1,94 @@ +get($_SESSION['domain']['language']['code'], 'core/user_settings'); + +//used for missed and recent calls + $theme_image_path = $_SERVER["DOCUMENT_ROOT"]."/themes/".$_SESSION['domain']['template']['name']."/images/"; + +//voicemail + //if (is_array($selected_blocks) && in_array('voicemail', $selected_blocks) && permission_exists('voicemail_message_view') && file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/voicemails/")) { + //required class + require_once "app/voicemails/resources/classes/voicemail.php"; + //get the voicemail + $vm = new voicemail; + $vm->db = $db; + $vm->domain_uuid = $_SESSION['domain_uuid']; + $vm->order_by = $order_by; + $vm->order = $order; + $voicemails = $vm->messages(); + //sum total and new + $messages['total'] = 0; + $messages['new'] = 0; + if (sizeof($voicemails) > 0) { + foreach($voicemails as $field) { + $messages[$field['voicemail_uuid']]['ext'] = $field['voicemail_id']; + $messages[$field['voicemail_uuid']]['total'] = 0; + $messages[$field['voicemail_uuid']]['new'] = 0; + foreach($field['messages'] as &$row) { + if ($row['message_status'] == '') { + $messages[$field['voicemail_uuid']]['new']++; + $messages['new']++; + } + $messages[$field['voicemail_uuid']]['total']++; + $messages['total']++; + } + } + } + + echo "".$text['label-voicemail'].""; + + echo "".$messages['new'].""; + echo "".$text['label-new_messages']."\n"; + + echo "
"; + if (sizeof($voicemails) > 0) { + echo ""; + echo ""; + echo " "; + echo " "; + echo " "; + echo ""; + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + foreach ($messages as $voicemail_uuid => $row) { + if (is_uuid($voicemail_uuid)) { + $tr_link = "href='".PROJECT_PATH."/app/voicemails/voicemail_messages.php?id=".(permission_exists('voicemail_view') ? $voicemail_uuid : $row['ext'])."'"; + echo ""; + echo " "; + echo " "; + echo " "; + echo ""; + $c = ($c) ? 0 : 1; + } + } + + echo "
".$text['label-voicemail']."".$text['label-new']."".$text['label-total']."
".$row['ext']."".$row['new']."".$row['total']."
"; + } + else { + echo "
".$text['label-no_voicemail_assigned']; + } + echo "
"; + $n++; + //} + echo " "; + +?> diff --git a/app/xml_cdr/resources/dashboard/config.php b/app/xml_cdr/resources/dashboard/config.php new file mode 100644 index 0000000000..92e20437b8 --- /dev/null +++ b/app/xml_cdr/resources/dashboard/config.php @@ -0,0 +1,43 @@ + diff --git a/app/xml_cdr/resources/dashboard/missed_calls.php b/app/xml_cdr/resources/dashboard/missed_calls.php new file mode 100644 index 0000000000..5f9b429635 --- /dev/null +++ b/app/xml_cdr/resources/dashboard/missed_calls.php @@ -0,0 +1,144 @@ +get($_SESSION['domain']['language']['code'], 'core/user_settings'); + +//missed calls + //if (is_array($selected_blocks) && in_array('missed', $selected_blocks) && permission_exists('xml_cdr_view') && is_array($_SESSION['user']['extension']) && sizeof($_SESSION['user']['extension']) > 0) { + foreach ($_SESSION['user']['extension'] as $assigned_extension) { + $assigned_extensions[$assigned_extension['extension_uuid']] = $assigned_extension['user']; + } + unset($assigned_extension); + + //if also viewing system status, show more recent calls (more room avaialble) + $missed_limit = (is_array($selected_blocks) && in_array('counts', $selected_blocks)) ? 10 : 5; + + $sql = "select \n"; + $sql .= " direction, \n"; + $sql .= " start_stamp, \n"; + $sql .= " start_epoch, \n"; + $sql .= " caller_id_name, \n"; + $sql .= " caller_id_number, \n"; + $sql .= " answer_stamp \n"; + $sql .= "from \n"; + $sql .= " v_xml_cdr \n"; + $sql .= "where \n"; + $sql .= " domain_uuid = :domain_uuid \n"; + $sql .= " and ( \n"; + $sql .= " direction = 'inbound' \n"; + $sql .= " or direction = 'local' \n"; + $sql .= " ) \n"; + $sql .= " and (missed_call = true or bridge_uuid is null) "; + if (is_array($assigned_extensions) && sizeof($assigned_extensions) != 0) { + $x = 0; + foreach ($assigned_extensions as $assigned_extension_uuid => $assigned_extension) { + $sql_where_array[] = "extension_uuid = :assigned_extension_uuid_".$x; + $sql_where_array[] = "destination_number = :destination_number_".$x; + $parameters['assigned_extension_uuid_'.$x] = $assigned_extension_uuid; + $parameters['destination_number_'.$x] = $assigned_extension; + $x++; + } + if (is_array($sql_where_array) && sizeof($sql_where_array) != 0) { + $sql .= "and (".implode(' or ', $sql_where_array).") \n"; + } + unset($sql_where_array); + } + $sql .= "and start_epoch > ".(time() - 86400)." \n"; + $sql .= "order by \n"; + $sql .= "start_epoch desc \n"; + $parameters['domain_uuid'] = $_SESSION['domain_uuid']; +//echo $sql; +//view_array($parameters); + $database = new database; + $result = $database->select($sql, $parameters, 'all'); + + $num_rows = is_array($result) ? sizeof($result) : 0; + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "".$text['label-missed_calls'].""; + + echo "".$num_rows.""; + echo "".$text['label-last_24_hours']."\n"; + + echo "
"; + echo "\n"; + echo "\n"; + if ($num_rows > 0) { + echo "\n"; + } + echo "\n"; + echo "\n"; + echo "\n"; + + if ($num_rows > 0) { + $theme_cdr_images_exist = ( + file_exists($theme_image_path."icon_cdr_inbound_voicemail.png") && + file_exists($theme_image_path."icon_cdr_inbound_cancelled.png") && + file_exists($theme_image_path."icon_cdr_local_voicemail.png") && + file_exists($theme_image_path."icon_cdr_local_cancelled.png") + ) ? true : false; + + foreach($result as $index => $row) { + if ($index + 1 > $missed_limit) { break; } //only show limit + $tmp_year = date("Y", strtotime($row['start_stamp'])); + $tmp_month = date("M", strtotime($row['start_stamp'])); + $tmp_day = date("d", strtotime($row['start_stamp'])); + $tmp_start_epoch = ($_SESSION['domain']['time_format']['text'] == '12h') ? date("n/j g:ia", $row['start_epoch']) : date("n/j H:i", $row['start_epoch']); + //set click-to-call variables + if (permission_exists('click_to_call_call')) { + $tr_link = "onclick=\"send_cmd('".PROJECT_PATH."/app/click_to_call/click_to_call.php". + "?src_cid_name=".urlencode($row['caller_id_name']). + "&src_cid_number=".urlencode($row['caller_id_number']). + "&dest_cid_name=".urlencode($_SESSION['user']['extension'][0]['outbound_caller_id_name']). + "&dest_cid_number=".urlencode($_SESSION['user']['extension'][0]['outbound_caller_id_number']). + "&src=".urlencode($_SESSION['user']['extension'][0]['user']). + "&dest=".urlencode($row['caller_id_number']). + "&rec=".(isset($_SESSION['click_to_call']['record']['boolean'])?$_SESSION['click_to_call']['record']['boolean']:"false"). + "&ringback=".(isset($_SESSION['click_to_call']['ringback']['text'])?$_SESSION['click_to_call']['ringback']['text']:"us-ring"). + "&auto_answer=".(isset($_SESSION['click_to_call']['auto_answer']['boolean'])?$_SESSION['click_to_call']['auto_answer']['boolean']:"true"). + "');\" ". + "style='cursor: pointer;'"; + } + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + $c = ($c) ? 0 : 1; + } + } + unset($sql, $parameters, $result, $num_rows, $index, $row); + + echo "
 ".$text['label-cid_number']."".$text['label-missed']."
\n"; + if ($theme_cdr_images_exist) { + $call_result = ($row['answer_stamp'] != '') ? 'voicemail' : 'cancelled'; + if (isset($row['direction'])) { + echo " \n"; + } + } + echo "".((is_numeric($row['caller_id_number'])) ? format_phone($row['caller_id_number']) : $row['caller_id_number'])."".$tmp_start_epoch."
\n"; + echo "".$text['label-view_all']."\n"; + echo "
"; + $n++; + //} + echo " "; + +?> diff --git a/app/xml_cdr/resources/dashboard/recent_calls.php b/app/xml_cdr/resources/dashboard/recent_calls.php new file mode 100644 index 0000000000..c586c8c1ba --- /dev/null +++ b/app/xml_cdr/resources/dashboard/recent_calls.php @@ -0,0 +1,176 @@ +get($_SESSION['domain']['language']['code'], 'core/user_settings'); + +//recent calls + //if (is_array($selected_blocks) && in_array('recent', $selected_blocks) && permission_exists('xml_cdr_view') && is_array($_SESSION['user']['extension']) && sizeof($_SESSION['user']['extension']) > 0) { + foreach ($_SESSION['user']['extension'] as $assigned_extension) { + $assigned_extensions[$assigned_extension['extension_uuid']] = $assigned_extension['user']; + } + + //if also viewing system status, show more recent calls (more room avaialble) + $recent_limit = (is_array($selected_blocks) && in_array('counts', $selected_blocks)) ? 10 : 5; + + $sql = " + select + direction, + start_stamp, + start_epoch, + caller_id_name, + caller_id_number, + destination_number, + answer_stamp, + bridge_uuid, + sip_hangup_disposition + from + v_xml_cdr + where + domain_uuid = :domain_uuid "; + if (is_array($assigned_extensions) && sizeof($assigned_extensions) != 0) { + $x = 0; + foreach ($assigned_extensions as $assigned_extension_uuid => $assigned_extension) { + $sql_where_array[] = "extension_uuid = :extension_uuid_".$x; + $sql_where_array[] = "caller_id_number = :caller_id_number_".$x; + $sql_where_array[] = "destination_number = :destination_number_1_".$x; + $sql_where_array[] = "destination_number = :destination_number_2_".$x; + $parameters['extension_uuid_'.$x] = $assigned_extension_uuid; + $parameters['caller_id_number_'.$x] = $assigned_extension; + $parameters['destination_number_1_'.$x] = $assigned_extension; + $parameters['destination_number_2_'.$x] = '*99'.$assigned_extension; + $x++; + } + if (is_array($sql_where_array) && sizeof($sql_where_array) != 0) { + $sql .= "and (".implode(' or ', $sql_where_array).") "; + } + unset($sql_where_array); + } + $sql .= " + and start_epoch > ".(time() - 86400)." + order by + start_epoch desc"; + $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $database = new database; + $result = $database->select($sql, $parameters, 'all'); + $num_rows = is_array($result) ? sizeof($result) : 0; + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "".$text['label-recent_calls'].""; + + echo "".$num_rows.""; + echo "".$text['label-last_24_hours']."\n"; + + echo "
"; + echo "\n"; + echo "\n"; + if ($num_rows > 0) { + echo "\n"; + } + echo "\n"; + echo "\n"; + echo "\n"; + + if ($num_rows > 0) { + $theme_cdr_images_exist = ( + file_exists($theme_image_path."icon_cdr_inbound_answered.png") && + file_exists($theme_image_path."icon_cdr_inbound_voicemail.png") && + file_exists($theme_image_path."icon_cdr_inbound_cancelled.png") && + file_exists($theme_image_path."icon_cdr_inbound_failed.png") && + file_exists($theme_image_path."icon_cdr_outbound_answered.png") && + file_exists($theme_image_path."icon_cdr_outbound_cancelled.png") && + file_exists($theme_image_path."icon_cdr_outbound_failed.png") && + file_exists($theme_image_path."icon_cdr_local_answered.png") && + file_exists($theme_image_path."icon_cdr_local_voicemail.png") && + file_exists($theme_image_path."icon_cdr_local_cancelled.png") && + file_exists($theme_image_path."icon_cdr_local_failed.png") + ) ? true : false; + + foreach($result as $index => $row) { + if ($index + 1 > $recent_limit) { break; } //only show limit + $tmp_year = date("Y", strtotime($row['start_stamp'])); + $tmp_month = date("M", strtotime($row['start_stamp'])); + $tmp_day = date("d", strtotime($row['start_stamp'])); + $tmp_start_epoch = ($_SESSION['domain']['time_format']['text'] == '12h') ? date("n/j g:ia", $row['start_epoch']) : date("n/j H:i", $row['start_epoch']); + + //determine name + $cdr_name = ($row['direction'] == 'inbound' || ($row['direction'] == 'local' && is_array($assigned_extensions) && in_array($row['destination_number'], $assigned_extensions))) ? $row['caller_id_name'] : $row['destination_number']; + //determine number to display + if ($row['direction'] == 'inbound' || ($row['direction'] == 'local' && is_array($assigned_extensions) && in_array($row['destination_number'], $assigned_extensions))) { + $cdr_number = (is_numeric($row['caller_id_number'])) ? format_phone($row['caller_id_number']) : $row['caller_id_number']; + $dest = $row['caller_id_number']; + } + else if ($row['direction'] == 'outbound' || ($row['direction'] == 'local' && is_array($assigned_extensions) && in_array($row['caller_id_number'], $assigned_extensions))) { + $cdr_number = (is_numeric($row['destination_number'])) ? format_phone($row['destination_number']) : $row['destination_number']; + $dest = $row['destination_number']; + } + //set click-to-call variables + if (permission_exists('click_to_call_call')) { + $tr_link = "onclick=\"send_cmd('".PROJECT_PATH."/app/click_to_call/click_to_call.php". + "?src_cid_name=".urlencode($cdr_name). + "&src_cid_number=".urlencode($cdr_number). + "&dest_cid_name=".urlencode($_SESSION['user']['extension'][0]['outbound_caller_id_name']). + "&dest_cid_number=".urlencode($_SESSION['user']['extension'][0]['outbound_caller_id_number']). + "&src=".urlencode($_SESSION['user']['extension'][0]['user']). + "&dest=".urlencode($dest). + "&rec=".(isset($_SESSION['click_to_call']['record']['boolean'])?$_SESSION['click_to_call']['record']['boolean']:"false"). + "&ringback=".(isset($_SESSION['click_to_call']['ringback']['text'])?$_SESSION['click_to_call']['ringback']['text']:"us-ring"). + "&auto_answer=".(isset($_SESSION['click_to_call']['auto_answer']['boolean'])?$_SESSION['click_to_call']['auto_answer']['boolean']:"true"). + "');\" ". + "style='cursor: pointer;'"; + } + echo "\n"; + //determine call result and appropriate icon + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + unset($cdr_name, $cdr_number); + $c = ($c) ? 0 : 1; + } + } + unset($sql, $parameters, $result, $num_rows, $index, $row); + + echo "
 ".$text['label-cid_number']."".$text['label-date_time']."
\n"; + if ($theme_cdr_images_exist) { + if ($row['direction'] == 'inbound' || $row['direction'] == 'local') { + if ($row['answer_stamp'] != '' && $row['bridge_uuid'] != '') { $call_result = 'answered'; } + else if ($row['answer_stamp'] != '' && $row['bridge_uuid'] == '') { $call_result = 'voicemail'; } + else if ($row['answer_stamp'] == '' && $row['bridge_uuid'] == '' && $row['sip_hangup_disposition'] != 'send_refuse') { $call_result = 'cancelled'; } + else { $call_result = 'failed'; } + } + else if ($row['direction'] == 'outbound') { + if ($row['answer_stamp'] != '' && $row['bridge_uuid'] != '') { $call_result = 'answered'; } + else if ($row['answer_stamp'] == '' && $row['bridge_uuid'] != '') { $call_result = 'cancelled'; } + else { $call_result = 'failed'; } + } + if (isset($row['direction'])) { + echo "\n"; + } + } + echo "".$cdr_number."".$tmp_start_epoch."
\n"; + echo "".$text['label-view_all']."\n"; + echo "
"; + $n++; + //} + echo " "; + +?> diff --git a/app/xml_cdr/resources/dashboard/root.php b/app/xml_cdr/resources/dashboard/root.php new file mode 100644 index 0000000000..6fdf32f37b --- /dev/null +++ b/app/xml_cdr/resources/dashboard/root.php @@ -0,0 +1,90 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + umask(2); + if (!defined("PATH_SEPARATOR")) { + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } + } + + if (!isset($output_format)) $output_format = (PHP_SAPI == 'cli') ? 'text' : 'html'; + + // make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", '/', $_SERVER["SCRIPT_FILENAME"]); + if(PHP_SAPI == 'cli'){ + chdir(pathinfo(realpath($_SERVER["PHP_SELF"]), PATHINFO_DIRNAME)); + $script_full_path = str_replace("\\", '/', getcwd() . '/' . $_SERVER["SCRIPT_FILENAME"]); + $dirs = explode('/', pathinfo($script_full_path, PATHINFO_DIRNAME)); + if (file_exists('/project_root.php')) { + $path = '/'; + } else { + $i = 1; + $path = ''; + while ($i < count($dirs)) { + $path .= '/' . $dirs[$i]; + if (file_exists($path. '/project_root.php')) { + break; + } + $i++; + } + } + $_SERVER["DOCUMENT_ROOT"] = $path; + }else{ + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + } + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"]. '/fusionpbx')) { + define('PROJECT_PATH', '/fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"]. '/project_root.php')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= '/' . $dirs[$i]; + if (file_exists($path. '/project_root.php')) { + break; + } + $i++; + } + if(!file_exists($path. '/project_root.php')){ + die("Failed to locate the Project Root by searching for project_root.php please contact support for assistance"); + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); + } + +?> \ No newline at end of file diff --git a/core/dashboard/app_config.php b/core/dashboard/app_config.php new file mode 100644 index 0000000000..cd99cac09d --- /dev/null +++ b/core/dashboard/app_config.php @@ -0,0 +1,118 @@ + \ No newline at end of file diff --git a/core/dashboard/app_defaults.php b/core/dashboard/app_defaults.php new file mode 100644 index 0000000000..d7c48ccc21 --- /dev/null +++ b/core/dashboard/app_defaults.php @@ -0,0 +1,64 @@ +select($sql, $parameters, 'all'); + + //add the dashboard widgets + $config_files = glob($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/*/*/resources/dashboard/config.php'); + $x = 0; + foreach($config_files as $file) { + include ($file); + $x++; + } + $widgets = $array; + unset($array); + + //build the array + $x = 0; + foreach($widgets['dashboard'] as $row) { + $array['dashboard'][$x]['dashboard_uuid'] = $row['dashboard_uuid']; + $array['dashboard'][$x]['dashboard_name'] = $row['dashboard_name']; + $array['dashboard'][$x]['dashboard_path'] = $row['dashboard_path']; + $array['dashboard'][$x]['dashboard_order'] = $row['dashboard_order']; + $array['dashboard'][$x]['dashboard_enabled'] = $row['dashboard_enabled']; + $array['dashboard'][$x]['dashboard_description'] = $row['dashboard_description']; + $y = 0; + if (is_array($row['dashboard_groups'])) { + foreach ($row['dashboard_groups'] as $row) { + if (isset($row['group_name'])) { + foreach($groups as $field) { + if ($row['group_name'] == $field['group_name']) { + $array['dashboard'][$x]['dashboard_groups'][$y]['dashboard_group_uuid'] = $row['dashboard_group_uuid']; + $array['dashboard'][$x]['dashboard_groups'][$y]['dashboard_uuid'] = $row['dashboard_uuid']; + $array['dashboard'][$x]['dashboard_groups'][$y]['group_uuid'] = $field['group_uuid']; + } + } + $y++; + } + } + } + $x++; + } + + //save the data + $database = new database; + $database->app_name = 'dashboard'; + $database->app_uuid = '55533bef-4f04-434a-92af-999c1e9927f7'; + $database->save($array); + //$result = $database->message; + //view_array($result); + //exit; + +} + +?> diff --git a/core/dashboard/app_languages.php b/core/dashboard/app_languages.php new file mode 100644 index 0000000000..a93a61bf53 --- /dev/null +++ b/core/dashboard/app_languages.php @@ -0,0 +1,349 @@ + \ No newline at end of file diff --git a/core/dashboard/app_menu.php b/core/dashboard/app_menu.php new file mode 100644 index 0000000000..c1c853f219 --- /dev/null +++ b/core/dashboard/app_menu.php @@ -0,0 +1,17 @@ + \ No newline at end of file diff --git a/core/dashboard/dashboard.php b/core/dashboard/dashboard.php new file mode 100644 index 0000000000..89aff09b26 --- /dev/null +++ b/core/dashboard/dashboard.php @@ -0,0 +1,351 @@ + + Portions created by the Initial Developer are Copyright (C) 2021 + the Initial Developer. All Rights Reserved. +*/ + +//includes + require_once "root.php"; + require_once "resources/require.php"; + require_once "resources/check_auth.php"; + +//check permissions + if (permission_exists('dashboard_view')) { + //access granted + } + else { + echo "access denied"; + exit; + } + +//add multi-lingual support + $language = new text; + $text = $language->get(); + +//get the http post data + if (is_array($_POST['dashboard'])) { + $action = $_POST['action']; + $search = $_POST['search']; + $dashboard = $_POST['dashboard']; + } + +//process the http post data by action + if ($action != '' && is_array($dashboard) && @sizeof($dashboard) != 0) { + + switch ($action) { + case 'copy': + if (permission_exists('dashboard_add')) { + $obj = new dashboard; + $obj->copy($dashboard); + } + break; + case 'toggle': + if (permission_exists('dashboard_edit')) { + $obj = new dashboard; + $obj->toggle($dashboard); + } + break; + case 'delete': + if (permission_exists('dashboard_delete')) { + $obj = new dashboard; + $obj->delete($dashboard); + } + break; + } + + //redirect the user + header('Location: dashboard.php'.($search != '' ? '?search='.urlencode($search) : null)); + exit; + } + +//get order and order by + $order_by = $_GET["order_by"]; + $order = $_GET["order"]; + +//add the search + if (isset($_GET["search"])) { + $search = strtolower($_GET["search"]); + } + + +//action add or update + if (isset($_REQUEST["export"])) { + $export = $_REQUEST["export"]; + } + +//expore provider settings + if (isset($export) && $export == 'true') { + + //get the dashboard + $sql = "select "; + $sql .= "dashboard_uuid, "; + $sql .= "dashboard_name, "; + $sql .= "dashboard_path, "; + $sql .= "dashboard_order, "; + $sql .= "cast(dashboard_enabled as text), "; + $sql .= "dashboard_description "; + $sql .= "from v_dashboard "; + $database = new database; + $dashboard_widgets = $database->select($sql, $parameters, 'all'); + unset($sql, $parameters); + + //prepare the array + if (is_array($dashboard_widgets)) { + $x = 0; + $y = 0; + foreach ($dashboard_widgets as $row) { + //add to the array + $array['dashboard'][$x]['dashboard_uuid'] = $row["dashboard_uuid"]; + $array['dashboard'][$x]['dashboard_name'] = $row["dashboard_name"]; + $array['dashboard'][$x]['dashboard_path'] = $row["dashboard_path"]; + $array['dashboard'][$x]['dashboard_order'] = $row["dashboard_order"]; + $array['dashboard'][$x]['dashboard_enabled'] = $row["dashboard_enabled"]; + $array['dashboard'][$x]['dashboard_description'] = $row["dashboard_description"]; + + //get the dashboard groups + $sql = "select "; + $sql .= "dashboard_group_uuid, "; + $sql .= "dashboard_uuid, "; + $sql .= "group_uuid, "; + $sql .= "(select group_name from v_groups where v_dashboard_groups.group_uuid = group_uuid) as group_name "; + $sql .= "from v_dashboard_groups "; + $sql .= "where dashboard_uuid = :dashboard_uuid "; + $parameters['dashboard_uuid'] = $row["dashboard_uuid"]; + $database = new database; + $dashboard_groups = $database->select($sql, $parameters, 'all'); + unset($sql, $parameters); + if (is_array($dashboard_groups)) { + $y = 0; + foreach ($dashboard_groups as $row) { + $array['dashboard'][$x]['dashboard_groups'][$y]['dashboard_group_uuid'] = $row["dashboard_group_uuid"]; + $array['dashboard'][$x]['dashboard_groups'][$y]['dashboard_uuid'] = $row["dashboard_uuid"]; + //$array['dashboard'][$x]['dashboard_groups'][$y]['group_uuid'] = $row["group_uuid"]; + $array['dashboard'][$x]['dashboard_groups'][$y]['group_name'] = $row["group_name"]; + $y++; + } + } + + $x++; + } + } + + //write the code + echo "\n"; + exit; + } + +//get the count + $sql = "select count(dashboard_uuid) "; + $sql .= "from v_dashboard "; + if (isset($search)) { + $sql .= "where (\n"; + $sql .= " dashboard_name = :search \n"; + $sql .= " or dashboard_description = :search \n"; + $sql .= ")\n"; + $parameters['search'] = '%'.$search.'%'; + } + $database = new database; + $num_rows = $database->select($sql, $parameters, 'column'); + unset($sql, $parameters); + +//get the list + $sql = "select \n"; + $sql .= "dashboard_uuid, \n"; + $sql .= "dashboard_name,\n"; + $sql .= "( \n"; + $sql .= " select \n"; + $sql .= " string_agg(g.group_name, ', ') \n"; + $sql .= " from \n"; + $sql .= " v_dashboard_groups as dg, \n"; + $sql .= " v_groups as g \n"; + $sql .= " where \n"; + $sql .= " dg.group_uuid = g.group_uuid \n"; + $sql .= " and d.dashboard_uuid = dg.dashboard_uuid \n"; + $sql .= ") AS dashboard_groups, \n"; + $sql .= "dashboard_order, \n"; + $sql .= "cast(dashboard_enabled as text), \n"; + $sql .= "dashboard_description \n"; + $sql .= "from v_dashboard as d \n"; + if (isset($_GET["search"])) { + $sql .= "where (\n"; + $sql .= " lower(dashboard_name) like :search \n"; + $sql .= " or lower(dashboard_description) like :search \n"; + $sql .= ")\n"; + $parameters['search'] = '%'.strtolower($search).'%'; + } + $sql .= order_by($order_by, $order, '', ''); + $sql .= limit_offset($rows_per_page, $offset); + $database = new database; + $dashboard = $database->select($sql, $parameters, 'all'); + unset($sql, $parameters); + +//create token + $object = new token; + $token = $object->create($_SERVER['PHP_SELF']); + +//additional includes + $document['title'] = $text['title-dashboard']; + require_once "resources/header.php"; + +//show the content + echo "
\n"; + echo "
".$text['title-dashboard']." (".$num_rows.")
\n"; + echo "
\n"; + if (permission_exists('dashboard_add')) { + echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add'],'id'=>'btn_add','name'=>'btn_add','link'=>'dashboard_edit.php']); + } + if (permission_exists('dashboard_add') && $dashboard) { + echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'id'=>'btn_copy','name'=>'btn_copy','style'=>'display:none;','onclick'=>"modal_open('modal-copy','btn_copy');"]); + } + if (permission_exists('dashboard_edit') && $dashboard) { + echo button::create(['type'=>'button','label'=>$text['button-toggle'],'icon'=>$_SESSION['theme']['button_icon_toggle'],'id'=>'btn_toggle','name'=>'btn_toggle','style'=>'display:none;','onclick'=>"modal_open('modal-toggle','btn_toggle');"]); + } + if (permission_exists('dashboard_delete') && $dashboard) { + echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'id'=>'btn_delete','name'=>'btn_delete','style'=>'display:none;','onclick'=>"modal_open('modal-delete','btn_delete');"]); + } + echo "\n"; + echo "
\n"; + echo "
\n"; + echo "
\n"; + + if (permission_exists('dashboard_add') && $dashboard) { + echo modal::create(['id'=>'modal-copy','type'=>'copy','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_copy','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('copy'); list_form_submit('form_list');"])]); + } + if (permission_exists('dashboard_edit') && $dashboard) { + echo modal::create(['id'=>'modal-toggle','type'=>'toggle','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_toggle','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('toggle'); list_form_submit('form_list');"])]); + } + if (permission_exists('dashboard_delete') && $dashboard) { + echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('delete'); list_form_submit('form_list');"])]); + } + + + echo "
\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + if (permission_exists('dashboard_add') || permission_exists('dashboard_edit') || permission_exists('dashboard_delete')) { + echo " \n"; + } + echo th_order_by('dashboard_name', $text['label-dashboard_name'], $order_by, $order); + echo th_order_by('dashboard_groups', $text['label-dashboard_groups'], $order_by, $order); + echo th_order_by('dashboard_order', $text['label-dashboard_order'], $order_by, $order); + echo th_order_by('dashboard_enabled', $text['label-dashboard_enabled'], $order_by, $order, null, "class='center'"); + echo " \n"; + if (permission_exists('dashboard_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') { + echo " \n"; + } + echo "\n"; + + if (is_array($dashboard) && @sizeof($dashboard) != 0) { + $x = 0; + foreach ($dashboard as $row) { + if (permission_exists('dashboard_edit')) { + $list_row_url = "dashboard_edit.php?id=".urlencode($row['dashboard_uuid']); + } + echo "\n"; + if (permission_exists('dashboard_add') || permission_exists('dashboard_edit') || permission_exists('dashboard_delete')) { + echo " \n"; + } + echo " \n"; + echo " \n"; + echo " \n"; + if (permission_exists('dashboard_edit')) { + echo " \n"; + echo " \n"; + if (permission_exists('dashboard_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') { + echo " \n"; + } + echo "\n"; + $x++; + } + unset($dashboard); + } + + echo "
\n"; + echo " \n"; + echo " ".$text['label-dashboard_description']." 
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + if (permission_exists('dashboard_edit')) { + echo " ".escape($row['dashboard_name'])."\n"; + } + else { + echo " ".escape($row['dashboard_name']); + } + echo " ".escape($row['dashboard_groups'])."".escape($row['dashboard_order'])."\n"; + echo $text['label-'.$row['dashboard_enabled']]; + } + echo " ".escape($row['dashboard_description'])."\n"; + echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]); + echo "
\n"; + echo "
\n"; + echo "
".$paging_controls."
\n"; + echo "\n"; + echo "
\n"; + +//include the footer + require_once "resources/footer.php"; + +?> \ No newline at end of file diff --git a/core/dashboard/dashboard_edit.php b/core/dashboard/dashboard_edit.php new file mode 100644 index 0000000000..851d331542 --- /dev/null +++ b/core/dashboard/dashboard_edit.php @@ -0,0 +1,450 @@ + + Portions created by the Initial Developer are Copyright (C) 2021 + the Initial Developer. All Rights Reserved. +*/ + +//includes + require_once "root.php"; + require_once "resources/require.php"; + require_once "resources/check_auth.php"; + +//check permissions + if (permission_exists('dashboard_add') || permission_exists('dashboard_edit')) { + //access granted + } + else { + echo "access denied"; + exit; + } + +//add multi-lingual support + $language = new text; + $text = $language->get(); + +//action add or update + if (is_uuid($_REQUEST["id"])) { + $action = "update"; + $dashboard_uuid = $_REQUEST["id"]; + $id = $_REQUEST["id"]; + } + else { + $action = "add"; + } + +//get http post variables and set them to php variables + if (is_array($_POST)) { + $dashboard_name = $_POST["dashboard_name"]; + $dashboard_path = $_POST["dashboard_path"]; + $dashboard_groups = $_POST["dashboard_groups"]; + $dashboard_order = $_POST["dashboard_order"]; + $dashboard_enabled = $_POST["dashboard_enabled"]; + $dashboard_description = $_POST["dashboard_description"]; + } + +//delete the group from the sub table + if ($_REQUEST["a"] == "delete" && permission_exists("dashboard_group_delete") && is_uuid($_GET["dashboard_group_uuid"]) && is_uuid($_GET["dashboard_uuid"])) { + //get the uuid + $dashboard_group_uuid = $_GET["dashboard_group_uuid"]; + $dashboard_uuid = $_GET["dashboard_uuid"]; + //delete the group from the users + $array['dashboard_groups'][0]['dashboard_group_uuid'] = $dashboard_group_uuid; + $database = new database; + $database->app_name = 'dashboard'; + $database->app_uuid = '55533bef-4f04-434a-92af-999c1e9927f7'; + $database->delete($array); + unset($array); + //redirect the user + message::add($text['message-delete']); + header("Location: dashboard_edit.php?id=".urlencode($dashboard_uuid)); + return; + } + +//process the user data and save it to the database + if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { + //validate the token + $token = new token; + if (!$token->validate($_SERVER['PHP_SELF'])) { + message::add($text['message-invalid_token'],'negative'); + header('Location: dashboard.php'); + exit; + } + + //process the http post data by submitted action + if ($_POST['action'] != '' && strlen($_POST['action']) > 0) { + + //prepare the array(s) + //send the array to the database class + switch ($_POST['action']) { + case 'copy': + if (permission_exists('dashboard_add')) { + $obj = new database; + $obj->copy($array); + } + break; + case 'delete': + if (permission_exists('dashboard_delete')) { + $obj = new database; + $obj->delete($array); + } + break; + case 'toggle': + if (permission_exists('dashboard_update')) { + $obj = new database; + $obj->toggle($array); + } + break; + } + + //redirect the user + if (in_array($_POST['action'], array('copy', 'delete', 'toggle'))) { + header('Location: dashboard_edit.php?id='.$id); + exit; + } + } + + //check for all required data + $msg = ''; + //if (strlen($dashboard_name) == 0) { $msg .= $text['message-required']." ".$text['label-dashboard_name']."
\n"; } + //if (strlen($dashboard_path) == 0) { $msg .= $text['message-required']." ".$text['label-dashboard_path']."
\n"; } + //if (strlen($dashboard_groups) == 0) { $msg .= $text['message-required']." ".$text['label-dashboard_groups']."
\n"; } + //if (strlen($dashboard_order) == 0) { $msg .= $text['message-required']." ".$text['label-dashboard_order']."
\n"; } + //if (strlen($dashboard_enabled) == 0) { $msg .= $text['message-required']." ".$text['label-dashboard_enabled']."
\n"; } + //if (strlen($dashboard_description) == 0) { $msg .= $text['message-required']." ".$text['label-dashboard_description']."
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "resources/header.php"; + require_once "resources/persist_form_var.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "resources/footer.php"; + return; + } + + //add the dashboard_uuid + if (!is_uuid($_POST["dashboard_uuid"])) { + $dashboard_uuid = uuid(); + } + + //prepare the array + $array['dashboard'][0]['dashboard_uuid'] = $dashboard_uuid; + $array['dashboard'][0]['dashboard_name'] = $dashboard_name; + $array['dashboard'][0]['dashboard_path'] = $dashboard_path; + $array['dashboard'][0]['dashboard_order'] = $dashboard_order; + $array['dashboard'][0]['dashboard_enabled'] = $dashboard_enabled; + $array['dashboard'][0]['dashboard_description'] = $dashboard_description; + $y = 0; + if (is_array($dashboard_groups)) { + foreach ($dashboard_groups as $row) { + if (isset($row['group_uuid'])) { + $array['dashboard'][0]['dashboard_groups'][$y]['dashboard_group_uuid'] = uuid(); + $array['dashboard'][0]['dashboard_groups'][$y]['group_uuid'] = $row["group_uuid"]; + $y++; + } + } + } + + //save the data + $database = new database; + $database->app_name = 'dashboard'; + $database->app_uuid = '55533bef-4f04-434a-92af-999c1e9927f7'; + $database->save($array); + //$result = $database->message; + //view_array($result); + //exit; + + //redirect the user + if (isset($action)) { + if ($action == "add") { + $_SESSION["message"] = $text['message-add']; + } + if ($action == "update") { + $_SESSION["message"] = $text['message-update']; + } + //header('Location: dashboard.php'); + header('Location: dashboard_edit.php?id='.urlencode($dashboard_uuid)); + return; + } + } + +//pre-populate the form + if (is_array($_GET) && $_POST["persistformvar"] != "true") { + $sql = "select "; + $sql .= " dashboard_uuid, "; + $sql .= " dashboard_name, "; + $sql .= " dashboard_path, "; + $sql .= " dashboard_groups, "; + $sql .= " dashboard_order, "; + $sql .= " cast(dashboard_enabled as text), "; + $sql .= " dashboard_description "; + $sql .= "from v_dashboard "; + $sql .= "where dashboard_uuid = :dashboard_uuid "; + $parameters['dashboard_uuid'] = $dashboard_uuid; + $database = new database; + $row = $database->select($sql, $parameters, 'row'); + if (is_array($row) && @sizeof($row) != 0) { + $dashboard_name = $row["dashboard_name"]; + $dashboard_path = $row["dashboard_path"]; + $dashboard_groups = $row["dashboard_groups"]; + $dashboard_order = $row["dashboard_order"]; + $dashboard_enabled = $row["dashboard_enabled"]; + $dashboard_description = $row["dashboard_description"]; + } + unset($sql, $parameters, $row); + } + +//get the child data + if (is_uuid($dashboard_uuid)) { + $sql = "select "; + $sql .= " dashboard_group_uuid, "; + $sql .= " group_uuid "; + $sql .= "from v_dashboard_groups "; + $sql .= "where dashboard_uuid = :dashboard_uuid "; + $parameters['dashboard_uuid'] = $dashboard_uuid; + $database = new database; + $dashboard_groups = $database->select($sql, $parameters, 'all'); + unset ($sql, $parameters); + } + +//add the $dashboard_group_uuid + if (!is_uuid($dashboard_group_uuid)) { + $dashboard_group_uuid = uuid(); + } + +//add an empty row + $x = is_array($dashboard_groups) ? count($dashboard_groups) : 0; + $dashboard_groups[$x]['dashboard_uuid'] = $dashboard_uuid; + $dashboard_groups[$x]['dashboard_group_uuid'] = uuid(); + $dashboard_groups[$x]['group_uuid'] = ''; + +//create token + $object = new token; + $token = $object->create($_SERVER['PHP_SELF']); + +//show the header + $document['title'] = $text['title-dashboard']; + require_once "resources/header.php"; + +//get the child groups + $sql = "select * from v_dashboard_groups as x, v_groups as g "; + $sql .= "where x.dashboard_uuid = :dashboard_uuid "; + $sql .= "and x.group_uuid = g.group_uuid "; + $parameters['dashboard_uuid'] = $dashboard_uuid; + $database = new database; + $dashboard_groups = $database->select($sql, $parameters, 'all'); + unset ($sql, $parameters); + +//get the groups + $sql = "SELECT group_uuid, group_name FROM v_groups "; + $sql .= "WHERE (domain_uuid = :domain_uuid or domain_uuid is null)"; + $sql .= "ORDER by group_name asc "; + $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $database = new database; + $groups = $database->execute($sql, $parameters, 'all'); + unset ($sql, $parameters); + +//set the assigned_groups array + if (is_array($dashboard_groups) && sizeof($dashboard_groups) != 0) { + $assigned_groups = array(); + foreach ($dashboard_groups as $field) { + if (strlen($field['group_name']) > 0) { + if (is_uuid($field['group_uuid'])) { + $assigned_groups[] = $field['group_uuid']; + } + } + } + } + +//show the content + echo "
\n"; + echo "\n"; + + echo "
\n"; + echo "
".$text['title-dashboard']."
\n"; + echo "
\n"; + echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','collapse'=>'hide-xs','style'=>'margin-right: 15px;','link'=>'dashboard.php']); + if ($action == 'update') { + if (permission_exists('dashboard_group_add')) { + echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'id'=>'btn_copy','name'=>'btn_copy','style'=>'display: none;','onclick'=>"modal_open('modal-copy','btn_copy');"]); + } + if (permission_exists('dashboard_group_delete')) { + echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'id'=>'btn_delete','name'=>'btn_delete','style'=>'display: none; margin-right: 15px;','onclick'=>"modal_open('modal-delete','btn_delete');"]); + } + } + echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'id'=>'btn_save','collapse'=>'hide-xs']); + echo "
\n"; + echo "
\n"; + echo "
\n"; + + echo $text['title_description-dashboard']."\n"; + echo "

\n"; + + if ($action == 'update') { + if (permission_exists('dashboard_add')) { + echo modal::create(['id'=>'modal-copy','type'=>'copy','actions'=>button::create(['type'=>'submit','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_copy','style'=>'float: right; margin-left: 15px;','collapse'=>'never','name'=>'action','value'=>'copy','onclick'=>"modal_close();"])]); + } + if (permission_exists('dashboard_delete')) { + echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'submit','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','name'=>'action','value'=>'delete','onclick'=>"modal_close();"])]); + } + } + + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "
\n"; + echo " ".$text['label-dashboard_name']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-dashboard_name']."\n"; + echo "
\n"; + echo " ".$text['label-dashboard_path']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-dashboard_path']."\n"; + echo "
\n"; + echo " ".$text['label-dashboard_groups']."\n"; + echo "\n"; + if (is_array($dashboard_groups) && sizeof($dashboard_groups) != 0) { + echo "\n"; + foreach($dashboard_groups as $field) { + if (strlen($field['group_name']) > 0) { + echo "\n"; + echo " \n"; + if (permission_exists('dashboard_group_delete') || if_group("superadmin")) { + echo " \n"; + } + echo "\n"; + } + } + echo "
\n"; + echo $field['group_name'].(($field['group_domain_uuid'] != '') ? "@".$_SESSION['domains'][$field['group_domain_uuid']]['domain_name'] : null); + echo " \n"; + echo "".$v_link_label_delete."\n"; + echo "
\n"; + } + if (is_array($groups)) { + echo "
\n"; + echo "\n"; + echo button::create(['type'=>'submit','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add']]); + } + echo "
\n"; + echo $text['description-dashboard_groups']."\n"; + echo "
\n"; + echo " ".$text['label-dashboard_order']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-dashboard_order']."\n"; + echo "
\n"; + echo " ".$text['label-dashboard_enabled']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-dashboard_enabled']."\n"; + echo "
\n"; + echo " ".$text['label-dashboard_description']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-dashboard_description']."\n"; + echo "
"; + echo "

"; + + echo "\n"; + + echo "
"; + +//include the footer + require_once "resources/footer.php"; + +?> \ No newline at end of file diff --git a/core/dashboard/index.php b/core/dashboard/index.php new file mode 100644 index 0000000000..f0804f560a --- /dev/null +++ b/core/dashboard/index.php @@ -0,0 +1,155 @@ + + Portions created by the Initial Developer are Copyright (C) 2021 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +//include the root directory + include "root.php"; + +//if config.php file does not exist then redirect to the install page + if (file_exists($_SERVER["PROJECT_ROOT"]."/resources/config.php")) { + //do nothing + } elseif (file_exists($_SERVER["PROJECT_ROOT"]."/resources/config.php")) { + //original directory + } elseif (file_exists("/etc/fusionpbx/config.php")){ + //linux + } elseif (file_exists("/usr/local/etc/fusionpbx/config.php")){ + //bsd + } else { + header("Location: ".PROJECT_PATH."/core/install/install.php"); + exit; + } + +//additional includes + require_once "resources/check_auth.php"; + +//disable login message + if (isset($_GET['msg']) && $_GET['msg'] == 'dismiss') { + unset($_SESSION['login']['message']['text']); + + $sql = "update v_default_settings "; + $sql .= "set default_setting_enabled = 'false' "; + $sql .= "where "; + $sql .= "default_setting_category = 'login' "; + $sql .= "and default_setting_subcategory = 'message' "; + $sql .= "and default_setting_name = 'text' "; + $database = new database; + $database->execute($sql); + unset($sql); + } + +//build a list of groups the user is a member of to be used in a SQL in + foreach($_SESSION['user']['groups'] as $group) { + $group_uuids[] = $group['group_uuid']; + } + $group_uuids_in = "'".implode("','", $group_uuids)."'"; + +//get the list + $sql = "select \n"; + $sql .= "dashboard_uuid, \n"; + $sql .= "dashboard_name, \n"; + $sql .= "dashboard_path, \n"; + $sql .= "dashboard_order, \n"; + $sql .= "cast(dashboard_enabled as text), \n"; + $sql .= "dashboard_description \n"; + $sql .= "from v_dashboard as d \n"; + $sql .= "where dashboard_enabled = 'true' \n"; + $sql .= "and dashboard_uuid in (\n"; + $sql .= " select dashboard_uuid from v_dashboard_groups where group_uuid in (\n"; + $sql .= " ".$group_uuids_in." \n"; + $sql .= " )\n"; + $sql .= ")\n"; + $sql .= "order by dashboard_order asc \n"; + $database = new database; + $dashboard = $database->select($sql, $parameters, 'all'); + unset($sql, $parameters); + +//add multi-lingual support + $language = new text; + $text = $language->get(); + +//load the header + $document['title'] = $text['title-dashboard']; + require_once "resources/header.php"; + +//start the content + /* + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
"; + echo " ".$text['title-dashboard']."
"; + echo "
\n"; + if ($_SESSION['theme']['menu_style']['text'] != 'side') { + echo " ".$text['label-welcome']." ".$_SESSION["username"].""; + } + echo "
"; + echo " ".$text['description-dashboard']; + echo "
\n"; + echo "
"; + */ + +//show the content + echo "
\n"; + echo "
".$text['title-dashboard']."
\n"; + echo "
\n"; + if ($_SESSION['theme']['menu_style']['text'] != 'side') { + echo " ".$text['label-welcome']." ".$_SESSION["username"]."   "; + } + if (permission_exists('dashboard_edit')) { + echo button::create(['type'=>'button','label'=>$text['button-settings'],'icon'=>$_SESSION['theme']['button_icon_add'],'id'=>'btn_add','name'=>'btn_add','link'=>'dashboard.php']); + } + echo "
\n"; + echo "
".$text['description-dashboard']."
\n"; + echo "
\n"; + +//display login message + //if (if_group("superadmin") && isset($_SESSION['login']['message']['text']) && $_SESSION['login']['message']['text'] != '') { + // echo ""; + //} + +//include the dashboards + echo "
\n"; + $n = 0; + foreach($dashboard as $row) { + echo "
\n"; + echo "
\n"; + echo "
\n"; + include($row['dashboard_path']); + echo "
\n"; + echo "
\n"; + echo "
\n"; + $n++; + } + echo "
\n"; + +//show the footer + require_once "resources/footer.php"; + +?> \ No newline at end of file diff --git a/core/dashboard/resources/classes/dashboard.php b/core/dashboard/resources/classes/dashboard.php new file mode 100644 index 0000000000..25a07a4b10 --- /dev/null +++ b/core/dashboard/resources/classes/dashboard.php @@ -0,0 +1,261 @@ + + Portions created by the Initial Developer are Copyright (C) 2019 - 2021 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +/** + * dashboard class + * + * @method null delete + * @method null toggle + * @method null copy + */ +if (!class_exists('dashboard')) { + class dashboard { + + /** + * declare the variables + */ + private $app_name; + private $app_uuid; + private $name; + private $table; + private $toggle_field; + private $toggle_values; + private $description_field; + private $location; + + /** + * called when the object is created + */ + public function __construct() { + //assign the variables + $this->app_name = 'dashboard'; + $this->app_uuid = '55533bef-4f04-434a-92af-999c1e9927f7'; + $this->name = 'dashboard'; + $this->table = 'dashboard'; + $this->toggle_field = 'dashboard_enabled'; + $this->toggle_values = ['true','false']; + $this->description_field = 'dashboard_description'; + $this->location = 'dashboard.php'; + } + + /** + * called when there are no references to a particular object + * unset the variables used in the class + */ + public function __destruct() { + foreach ($this as $key => $value) { + unset($this->$key); + } + } + + /** + * delete rows from the database + */ + public function delete($records) { + if (permission_exists($this->name.'_delete')) { + + //add multi-lingual support + $language = new text; + $text = $language->get(); + + //validate the token + $token = new token; + if (!$token->validate($_SERVER['PHP_SELF'])) { + message::add($text['message-invalid_token'],'negative'); + header('Location: '.$this->location); + exit; + } + + //delete multiple records + if (is_array($records) && @sizeof($records) != 0) { + //build the delete array + $x = 0; + foreach ($records as $record) { + //add to the array + if ($record['checked'] == 'true' && is_uuid($record['uuid'])) { + $array[$this->table][$x]['dashboard_uuid'] = $record['dashboard_uuid']; + } + + //increment the id + $x++; + } + + //delete the checked rows + if (is_array($array) && @sizeof($array) != 0) { + //execute delete + $database = new database; + $database->app_name = $this->app_name; + $database->app_uuid = $this->app_uuid; + $database->delete($array); + unset($array); + + //set message + message::add($text['message-delete']); + } + unset($records); + } + } + } + + /** + * toggle a field between two values + */ + public function toggle($records) { + if (permission_exists($this->name.'_edit')) { + + //add multi-lingual support + $language = new text; + $text = $language->get(); + + //validate the token + $token = new token; + if (!$token->validate($_SERVER['PHP_SELF'])) { + message::add($text['message-invalid_token'],'negative'); + header('Location: '.$this->location); + exit; + } + + //toggle the checked records + if (is_array($records) && @sizeof($records) != 0) { + //get current toggle state + foreach($records as $record) { + if ($record['checked'] == 'true' && is_uuid($record['dashboard_uuid'])) { + $uuids[] = "'".$record['dashboard_uuid']."'"; + } + } + if (is_array($uuids) && @sizeof($uuids) != 0) { + $sql = "select ".$this->name."_uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." "; + $sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") "; + $database = new database; + $rows = $database->select($sql, $parameters, 'all'); + if (is_array($rows) && @sizeof($rows) != 0) { + foreach ($rows as $row) { + $states[$row['uuid']] = $row['toggle']; + } + } + unset($sql, $parameters, $rows, $row); + } + + //build update array + $x = 0; + foreach($states as $uuid => $state) { + //create the array + $array[$this->table][$x][$this->name.'_uuid'] = $uuid; + $array[$this->table][$x][$this->toggle_field] = $state == $this->toggle_values[0] ? $this->toggle_values[1] : $this->toggle_values[0]; + + //increment the id + $x++; + } + + //save the changes + if (is_array($array) && @sizeof($array) != 0) { + //save the array + $database = new database; + $database->app_name = $this->app_name; + $database->app_uuid = $this->app_uuid; + $database->save($array); + unset($array); + + //set message + message::add($text['message-toggle']); + } + unset($records, $states); + } + } + } + + /** + * copy rows from the database + */ + public function copy($records) { + if (permission_exists($this->name.'_add')) { + + //add multi-lingual support + $language = new text; + $text = $language->get(); + + //validate the token + $token = new token; + if (!$token->validate($_SERVER['PHP_SELF'])) { + message::add($text['message-invalid_token'],'negative'); + header('Location: '.$this->location); + exit; + } + + //copy the checked records + if (is_array($records) && @sizeof($records) != 0) { + + //get checked records + foreach($records as $record) { + if ($record['checked'] == 'true' && is_uuid($record['dashboard_uuid'])) { + $uuids[] = "'".$record['dashboard_uuid']."'"; + } + } + + //create the array from existing data + if (is_array($uuids) && @sizeof($uuids) != 0) { + $sql = "select * from v_".$this->table." "; + $sql .= "where dashboard_uuid in (".implode(', ', $uuids).") "; + $database = new database; + $rows = $database->select($sql, $parameters, 'all'); + if (is_array($rows) && @sizeof($rows) != 0) { + $x = 0; + foreach ($rows as $row) { + //copy data + $array[$this->table][$x] = $row; + + //add copy to the description + $array[$this->table][$x][dashboard.'_uuid'] = uuid(); + $array[$this->table][$x][$this->description_field] = trim($row[$this->description_field]).' ('.$text['label-copy'].')'; + + //increment the id + $x++; + } + } + unset($sql, $parameters, $rows, $row); + } + + //save the changes and set the message + if (is_array($array) && @sizeof($array) != 0) { + //save the array + $database = new database; + $database->app_name = $this->app_name; + $database->app_uuid = $this->app_uuid; + $database->save($array); + unset($array); + + //set message + message::add($text['message-copy']); + } + unset($records); + } + } + } + + } +} + +?> \ No newline at end of file diff --git a/core/dashboard/root.php b/core/dashboard/root.php new file mode 100644 index 0000000000..1ff8f7927e --- /dev/null +++ b/core/dashboard/root.php @@ -0,0 +1,90 @@ + + Portions created by the Initial Developer are Copyright (C) 2018 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + umask(2); + if (!defined("PATH_SEPARATOR")) { + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } + } + + if (!isset($output_format)) $output_format = (PHP_SAPI == 'cli') ? 'text' : 'html'; + + // make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", '/', $_SERVER["SCRIPT_FILENAME"]); + if(PHP_SAPI == 'cli'){ + chdir(pathinfo(realpath($_SERVER["PHP_SELF"]), PATHINFO_DIRNAME)); + $script_full_path = str_replace("\\", '/', getcwd() . '/' . $_SERVER["SCRIPT_FILENAME"]); + $dirs = explode('/', pathinfo($script_full_path, PATHINFO_DIRNAME)); + if (file_exists('/project_root.php')) { + $path = '/'; + } else { + $i = 1; + $path = ''; + while ($i < count($dirs)) { + $path .= '/' . $dirs[$i]; + if (file_exists($path. '/project_root.php')) { + break; + } + $i++; + } + } + $_SERVER["DOCUMENT_ROOT"] = $path; + }else{ + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + } + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"]. '/fusionpbx')) { + define('PROJECT_PATH', '/fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"]. '/project_root.php')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= '/' . $dirs[$i]; + if (file_exists($path. '/project_root.php')) { + break; + } + $i++; + } + if(!file_exists($path. '/project_root.php')){ + die("Failed to locate the Project Root by searching for project_root.php please contact support for assistance"); + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); + } + +?>