Portions created by the Initial Developer are Copyright (C) 2008-2012 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 require_once "app_languages.php"; foreach($text as $key => $value) { $text[$key] = $value[$_SESSION['domain']['language']['code']]; } //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"; $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); //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 "
\n"; echo " ".$text['title-sofia-status']." \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"; 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"] == $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 "
NameTypeDataState
".$row->name."".$row->type."".$row->data."".$row->state."
".$gateway_name."@".$gateway_domain_name."".$row->type."".$row->data."".$row->state."
".$row->name."".$row->type."".$row->data."".$row->state."
\n"; unset($xml); echo "
\n\n"; } //sofia status profile if (permission_exists('system_status_sofia_status_profile')) { foreach (ListFiles($_SESSION['switch']['conf']['dir'].'/sip_profiles') as $key=>$sip_profile_file){ if (substr($sip_profile_file, -4) == ".xml") { $sip_profile_name = str_replace(".xml", "", $sip_profile_file); 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!"; } $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 "\n"; echo "
\n"; echo " ".$text['title-sofia-status-profile']." $sip_profile_name \n"; echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; if ($sip_profile_name != "external") { echo " \n"; } echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; foreach ($xml->profile_info as $row) { 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 " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; } echo "
  
name   ".$row->name." 
domain-name   ".$row->{'domain-name'}." 
auto-nat ".$row->{'auto-nat'}." 
db-name ".$row->{'db-name'}." 
pres-hosts ".$row->{'pres-hosts'}." 
dialplan ".$row->dialplan." 
context ".$row->context." 
challenge-realm ".$row->{'challenge-realm'}." 
rtp-ip ".$row->{'rtp-ip'}." 
ext-rtp-ip ".$row->{'ext-rtp-ip'}." 
sip-ip ".$row->{'sip-ip'}." 
ext-sip-ip ".$row->{'ext-sip-ip'}." 
url ".$row->url." 
bind-url ".$row->{'bind-url'}." 
tls-url ".$row->{'tls-url'}." 
tls-bind-url ".$row->{'tls-bind-url'}." 
hold-music ".$row->{'hold-music'}." 
outbound-proxy ".$row->{'outbound-proxy'}." 
inbound-codecs ".$row->{'inbound-codecs'}." 
outbound-codecs ".$row->{'outbound-codecs'}." 
tel-event ".$row->{'tel-event'}." 
dtmf-mode ".$row->{'dtmf-mode'}." 
cng ".$row->cng." 
session-to ".$row->{'session-to'}." 
max-dialog ".$row->{'max-dialog'}." 
nomedia ".$row->nomedia." 
late-neg ".$row->{'late-neg'}." 
proxy-media ".$row->{'proxy-media'}." 
aggressive-nat ".$row->{'aggressive-nat'}." 
stun-enabled ".$row->{'stun-enabled'}." 
stun-auto-disable ".$row->{'stun-auto-disable'}." 
user-agent-filter ".$row->{'user-agent-filter'}." 
max-registrations-per-extension ".$row->{'max-registrations-per-extension'}." 
calls-in ".$row->{'calls-in'}." 
calls-out ".$row->{'calls-out'}." 
failed-calls-in ".$row->{'failed-calls-in'}." 
failed-calls-out ".$row->{'failed-calls-out'}." 
\n"; unset($xml); echo "

\n\n"; } } } } //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 trim($response);
		echo "
\n"; fclose($fp); echo "

\n\n"; } //include the footer require_once "resources/footer.php"; ?>