Portions created by the Initial Developer are Copyright (C) 2008-2015 the Initial Developer. All Rights Reserved. Contributor(s): Mark J Crane James Rose */ include "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; if (permission_exists('system_status_sofia_status') || permission_exists('system_status_sofia_status_profile') || if_group("superadmin")) { //access granted } else { echo "access denied"; exit; } //add multi-lingual support $language = new text; $text = $language->get(); //define variables $c = 0; $row_style["0"] = "row_style0"; $row_style["1"] = "row_style1"; if ($_GET['a'] == "download") { if ($_GET['t'] == "cdrcsv") { $tmp = $_SESSION['switch']['log']['dir'].'/cdr-csv/'; $filename = 'Master.csv'; } if ($_GET['t'] == "backup") { $tmp = $backup_dir.'/'; $filename = 'backup.tgz'; if (!is_dir($backup_dir.'/')) { exec("mkdir ".$backup_dir."/"); } $parent_dir = realpath($_SESSION['switch']['base']['dir']."/.."); chdir($parent_dir); shell_exec('tar cvzf freeswitch '.$backup_dir.'/backup.tgz'); } session_cache_limiter('public'); $fd = fopen($tmp.$filename, "rb"); header("Content-Type: binary/octet-stream"); header("Content-Length: " . filesize($tmp.$filename)); header('Content-Disposition: attachment; filename="'.$filename.'"'); fpassthru($fd); exit; } //show the content require_once "resources/header.php"; $document['title'] = $text['title-sip-status']; $msg = $_GET["savemsg"]; $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); if (!$fp) { $msg = "
".$text['error-event-socket']."
"; } if (strlen($msg) > 0) { echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
".$text['label-message']."
$msg
\n"; echo "
\n"; } //get the gateways $sql = "select g.domain_uuid, g.gateway, g.gateway_uuid, d.domain_name from v_gateways as g, v_domains as d "; $sql .= "where d.domain_uuid = g.domain_uuid "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $gateways = $prep_statement->fetchAll(PDO::FETCH_NAMED); unset ($prep_statement, $sql); //get the sip profiles $sql = "select sip_profile_name from v_sip_profiles "; $sql .= "where sip_profile_enabled = 'true' "; $sql .= "order by sip_profile_name asc "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $sip_profiles = $prep_statement->fetchAll(); unset ($prep_statement, $sql); //sofia status if ($fp && permission_exists('system_status_sofia_status')) { $cmd = "api sofia xmlstatus"; $xml_response = trim(event_socket_request($fp, $cmd)); try { $xml = new SimpleXMLElement($xml_response); } catch(Exception $e) { echo $e->getMessage(); } echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
\n"; echo " ".$text['header-sip-status'].""; echo "

"; echo "
\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
".$text['title-sofia-status']."
\n"; echo "
"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; foreach ($xml->profile as $row) { echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "\n"; if ($c==0) { $c=1; } else { $c=0; } } foreach ($xml->gateway as $row) { $gateway_name = ''; $gateway_domain_name = ''; foreach($gateways as $field) { if ($field["gateway_uuid"] == strtolower($row->name)) { $gateway_name = $field["gateway"]; $gateway_domain_name = $field["domain_name"]; break; } } echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "\n"; if ($c==0) { $c=1; } else { $c=0; } } foreach ($xml->alias as $row) { //print_r($row); echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "\n"; if ($c==0) { $c=1; } else { $c=0; } } echo "
".$text['label-name']."".$text['label-type']."".$text['label-data']."".$text['label-state']."
".$row->name."".$row->type."".$row->data."".$row->state."
"; if ($_SESSION["domain_name"] == $gateway_domain_name) { echo "".$gateway_name."@".$gateway_domain_name.""; } else { echo $gateway_name."@".$gateway_domain_name; } echo " ".$row->type."".$row->data."".$row->state."
".$row->name."".$row->type."".$row->data."".$row->state."
\n"; echo "
\n"; unset($xml); } //sofia status profile if (permission_exists('system_status_sofia_status_profile')) { foreach ($sip_profiles as $row) { $sip_profile_name = $row["sip_profile_name"]; if ($fp) { $cmd = "api sofia xmlstatus profile ".$sip_profile_name.""; $xml_response = trim(event_socket_request($fp, $cmd)); if ($xml_response == "Invalid Profile!") { $xml_response = "Invalid Profile!"; $profile_state = 'stopped'; } else { $profile_state = 'running'; } $xml_response = str_replace("", "", $xml_response); $xml_response = str_replace("", "", $xml_response); try { $xml = new SimpleXMLElement($xml_response); } catch(Exception $e) { echo $e->getMessage(); exit; } echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
\n"; echo " ".$text['title-sofia-status-profile']." ".$sip_profile_name." \n"; echo "\n"; if ($sip_profile_name != "external") { echo " \n"; } echo " \n"; if ($profile_state == 'stopped') { echo " \n"; } if ($profile_state == 'running') { echo " \n"; } echo " \n"; echo " \n"; echo "
\n"; echo ""; unset($xml); } } } //status if ($fp && permission_exists('sip_status_switch_status')) { $cmd = "api status"; $response = event_socket_request($fp, $cmd); echo "".$text['title-status']."\n"; echo "
"; echo "
";
		echo trim($response);
		echo "
\n"; echo "
"; fclose($fp); } //include the footer require_once "resources/footer.php"; ?>