Enhance [master] sip_status Add Stop Action (#2611)

add stop action
change cmd.php to use messages::add and also trim trailing \n so message
does render
This commit is contained in:
Mafoo 2017-05-30 20:45:06 +01:00 committed by FusionPBX
parent c295bd25e1
commit 862848c52a
3 changed files with 36 additions and 9 deletions

View File

@ -65,6 +65,22 @@ $text['title-sip-status']['ru-ru'] = "SIP Статус";
$text['title-sip-status']['sv-se'] = "SIP Status"; $text['title-sip-status']['sv-se'] = "SIP Status";
$text['title-sip-status']['uk-ua'] = "Стан SIP"; $text['title-sip-status']['uk-ua'] = "Стан SIP";
$text['label-action']['en-us'] = "Action";
$text['label-action']['ar-eg'] = "";
$text['label-action']['de-at'] = "Aktion";
$text['label-action']['de-de'] = "Aktion";
$text['label-action']['es-cl'] = "Acción";
$text['label-action']['fr-fr'] = "Action";
$text['label-action']['he-il'] = "";
$text['label-action']['it-it'] = "";
$text['label-action']['nl-nl'] = "";
$text['label-action']['pl-pl'] = "Operacja";
$text['label-action']['pt-br'] = "Ação";
$text['label-action']['pt-pt'] = "Acção";
$text['label-action']['ru-ru'] = "Действие";
$text['label-action']['sv-se'] = "Åtgärd";
$text['label-action']['uk-ua'] = "Дія";
$text['label-state']['en-us'] = "State"; $text['label-state']['en-us'] = "State";
$text['label-state']['ar-eg'] = ""; $text['label-state']['ar-eg'] = "";
$text['label-state']['de-at'] = "Status"; $text['label-state']['de-at'] = "Status";

View File

@ -45,7 +45,7 @@ else {
if ($cmd == "api reloadxml") { if ($cmd == "api reloadxml") {
//reloadxml //reloadxml
if ($cmd == "api reloadxml") { if ($cmd == "api reloadxml") {
$response = event_socket_request($fp, $cmd); messages::add(rtrim(event_socket_request($fp, $cmd)), 'alert');
unset($cmd); unset($cmd);
} }
@ -54,7 +54,7 @@ else {
//rescan the external profile to look for new or stopped gateways //rescan the external profile to look for new or stopped gateways
$tmp_cmd = 'api sofia profile external rescan'; $tmp_cmd = 'api sofia profile external rescan';
$response = event_socket_request($fp, $tmp_cmd); messages::add(rtrim(event_socket_request($fp, $tmp_cmd)), 'alert');
unset($tmp_cmd); unset($tmp_cmd);
} }
@ -66,13 +66,13 @@ else {
//reloadacl //reloadacl
if ($cmd == "api reloadacl") { if ($cmd == "api reloadacl") {
$response = event_socket_request($fp, $cmd); messages::add(rtrim(event_socket_request($fp, $cmd)), 'alert');
unset($cmd); unset($cmd);
} }
//sofia profile //sofia profile
if (substr($cmd, 0, 17) == "api sofia profile") { if (substr($cmd, 0, 17) == "api sofia profile") {
$response = event_socket_request($fp, $cmd); messages::add(rtrim(event_socket_request($fp, $cmd)), 'alert');
} }
//close the connection //close the connection
@ -85,7 +85,6 @@ else {
echo $response; echo $response;
} }
else { else {
$_SESSION["message"] = $response;
header("Location: sip_status.php"); header("Location: sip_status.php");
} }

View File

@ -128,6 +128,14 @@ if ($_GET['a'] == "download") {
catch(Exception $e) { catch(Exception $e) {
echo $e->getMessage(); echo $e->getMessage();
} }
$cmd = "api sofia xmlstatus gateway";
$xml_response = trim(event_socket_request($fp, $cmd));
try {
$xml_gateways = new SimpleXMLElement($xml_response);
}
catch(Exception $e) {
echo $e->getMessage();
}
echo "<table width='100%' cellpadding='0' cellspacing='0' border='0'>\n"; echo "<table width='100%' cellpadding='0' cellspacing='0' border='0'>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td width='50%'>\n"; echo "<td width='50%'>\n";
@ -156,6 +164,7 @@ if ($_GET['a'] == "download") {
echo "<th>".$text['label-type']."</th>\n"; echo "<th>".$text['label-type']."</th>\n";
echo "<th>".$text['label-data']."</th>\n"; echo "<th>".$text['label-data']."</th>\n";
echo "<th>".$text['label-state']."</th>\n"; echo "<th>".$text['label-state']."</th>\n";
echo "<th>".$text['label-action']."</th>\n";
echo "</tr>\n"; echo "</tr>\n";
foreach ($xml->profile as $row) { foreach ($xml->profile as $row) {
echo "<tr>\n"; echo "<tr>\n";
@ -163,10 +172,11 @@ if ($_GET['a'] == "download") {
echo " <td class='".$row_style[$c]."'>".$row->type."</td>\n"; echo " <td class='".$row_style[$c]."'>".$row->type."</td>\n";
echo " <td class='".$row_style[$c]."'>".$row->data."</td>\n"; echo " <td class='".$row_style[$c]."'>".$row->data."</td>\n";
echo " <td class='".$row_style[$c]."'>".$row->state."</td>\n"; echo " <td class='".$row_style[$c]."'>".$row->state."</td>\n";
echo " <td class='".$row_style[$c]."'>&nbsp;</td>\n";
echo "</tr>\n"; echo "</tr>\n";
if ($c==0) { $c=1; } else { $c=0; } if ($c==0) { $c=1; } else { $c=0; }
} }
foreach ($xml->gateway as $row) { foreach ($xml_gateways->gateway as $row) {
$gateway_name = ''; $gateway_name = '';
$gateway_domain_name = ''; $gateway_domain_name = '';
foreach($gateways as $field) { foreach($gateways as $field) {
@ -182,14 +192,15 @@ if ($_GET['a'] == "download") {
echo "<a href='".PROJECT_PATH."/app/gateways/gateway_edit.php?id=".strtolower($row->name)."'>".$gateway_name."@".$gateway_domain_name."</a>"; echo "<a href='".PROJECT_PATH."/app/gateways/gateway_edit.php?id=".strtolower($row->name)."'>".$gateway_name."@".$gateway_domain_name."</a>";
} }
elseif ($gateway_domain_name == '') { elseif ($gateway_domain_name == '') {
echo $gateway_name; echo $gateway_name ? $gateway_name : $row->name;
} else { } else {
echo $gateway_name."@".$gateway_domain_name; echo $gateway_name."@".$gateway_domain_name;
} }
echo " </td>\n"; echo " </td>\n";
echo " <td class='".$row_style[$c]."'>".$row->type."</td>\n"; echo " <td class='".$row_style[$c]."'>Gateway</td>\n";
echo " <td class='".$row_style[$c]."'>".$row->data."</td>\n"; echo " <td class='".$row_style[$c]."'>".$row->to."</td>\n";
echo " <td class='".$row_style[$c]."'>".$row->state."</td>\n"; echo " <td class='".$row_style[$c]."'>".$row->state."</td>\n";
echo " <td class='".$row_style[$c]."'><a onclick=\"document.location.href='cmd.php?cmd=api+sofia+profile+".$row->profile."+killgw+".$row->name."';\" />".$text['button-stop']."</a></td>\n";
echo "</tr>\n"; echo "</tr>\n";
if ($c==0) { $c=1; } else { $c=0; } if ($c==0) { $c=1; } else { $c=0; }
} }
@ -200,6 +211,7 @@ if ($_GET['a'] == "download") {
echo " <td class='".$row_style[$c]."'>".$row->type."</td>\n"; echo " <td class='".$row_style[$c]."'>".$row->type."</td>\n";
echo " <td class='".$row_style[$c]."'>".$row->data."</td>\n"; echo " <td class='".$row_style[$c]."'>".$row->data."</td>\n";
echo " <td class='".$row_style[$c]."'>".$row->state."</td>\n"; echo " <td class='".$row_style[$c]."'>".$row->state."</td>\n";
echo " <td class='".$row_style[$c]."'>&nbsp;</td>\n";
echo "</tr>\n"; echo "</tr>\n";
if ($c==0) { $c=1; } else { $c=0; } if ($c==0) { $c=1; } else { $c=0; }
} }