Portions created by the Initial Developer are Copyright (C) 2008-2012 the Initial Developer. All Rights Reserved. Contributor(s): Mark J Crane */ require_once "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; if (permission_exists('gateway_view')) { //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']]; } //additional includes require_once "resources/header.php"; require_once "resources/paging.php"; //get variables used to control the order $order_by = check_str($_GET["order_by"]); $order = check_str($_GET["order"]); //connect to event socket $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); if ($fp) { if (strlen($_GET["a"]) > 0) { $profile = check_str($_GET["profile"]); if (strlen($profile) == 0) { $profile = 'external'; } if ($_GET["a"] == "stop") { $gateway_uuid = check_str($_GET["gateway"]); $cmd = 'api sofia profile '.$profile.' killgw '.$gateway_uuid; $response = trim(event_socket_request($fp, $cmd)); $msg = 'Stop Gateway:
'.$response.'
'; } if ($_GET["a"] == "start") { $gateway_uuid = $_GET["gateway"]; $cmd = 'api sofia profile '.$profile.' rescan'; $response = trim(event_socket_request($fp, $cmd)); $msg = 'Start Gateway:
'.$response.'
'; } } if (!function_exists('switch_gateway_status')) { function switch_gateway_status($gateway_uuid, $result_type = 'xml') { $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); $cmd = 'api sofia xmlstatus gateway '.$gateway_uuid; return trim(event_socket_request($fp, $cmd)); } } } //show the content echo "
"; echo "
"; echo "\n"; echo "\n"; echo " "; echo ""; echo "
\n"; echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
".$text['title-gateways'].""; echo " \n"; echo "
\n"; echo " \n"; echo " ".$text['description-gateway']."\n"; echo " \n"; echo "
\n"; echo "
\n"; //prepare to page the results $sql = "select count(*) as num_rows from v_gateways "; $sql .= "where domain_uuid = '$domain_uuid' "; $prep_statement = $db->prepare($sql); if ($prep_statement) { $prep_statement->execute(); $row = $prep_statement->fetch(PDO::FETCH_ASSOC); if ($row['num_rows'] > 0) { $num_rows = $row['num_rows']; } else { $num_rows = '0'; } } //get the list $sql = "select * from v_gateways "; $sql .= "where domain_uuid = '$domain_uuid' "; if (strlen($order_by) == 0) { $sql .= "order by gateway asc "; } else { $sql .= "order by $order_by $order "; } $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); unset ($prep_statement, $sql); $rows_per_page = 150; $param = ""; $page = check_str($_GET['page']); if (strlen($page) == 0) { $page = 0; } list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page); $offset = $rows_per_page * $page; $c = 0; $row_style["0"] = "row_style0"; $row_style["1"] = "row_style1"; echo "
\n"; echo "\n"; echo "\n"; echo th_order_by('gateway', $text['label-gateway'], $order_by, $order); echo th_order_by('context', $text['label-context'], $order_by, $order); if ($fp) { echo "\n"; echo "\n"; echo "\n"; } echo th_order_by('enabled', $text['label-enabled'], $order_by, $order); echo th_order_by('description', $text['label-description'], $order_by, $order); echo "\n"; echo "\n"; if ($num_rows > 0) { foreach($result as $row) { echo "\n"; echo " \n"; echo " \n"; if ($fp) { if ($row["enabled"] == "true") { $response = switch_gateway_status($row["gateway_uuid"]); if ($response == "Invalid Gateway!") { //not running echo " \n"; echo " \n"; echo " \n"; } else { //running try { $xml = new SimpleXMLElement($response); $state = $xml->state; echo " \n"; echo " \n"; echo " \n"; //REGED, NOREG, UNREGED } catch(Exception $e) { //echo $e->getMessage(); } } } else { echo " \n"; echo " \n"; echo " \n"; } if ($row["enabled"] == "true") { echo " \n"; } else { echo " \n"; } echo " \n"; echo " \n"; echo "\n"; } if ($c==0) { $c=1; } else { $c=0; } } //end foreach unset($sql, $result, $row_count); } //end if results echo "\n"; echo ""; echo ""; echo "
".$text['label-status']."".$text['label-action']."".$text['label-state'].""; if (permission_exists('gateway_add')) { echo "$v_link_label_add"; } echo "
".$row["gateway"]."".$row["context"]."".$text['label-status-stopped']."".$text['label-action-start']." ".$text['label-status-running']."".$text['label-action-stop']."".$state."   ".$text['label-true']."".$text['label-false']."".$row["description"]." "; if (permission_exists('gateway_edit')) { echo "$v_link_label_edit"; } if (permission_exists('gateway_delete')) { echo "$v_link_label_delete"; } echo "
\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
 $paging_controls"; if (permission_exists('gateway_add')) { echo "$v_link_label_add"; } else { echo " "; } echo "
\n"; echo "
\n"; if ($v_path_show) { echo " ".$_SESSION['switch']['gateways']['dir']."/sip_profiles\n"; } echo "
"; echo ""; echo "
"; echo "
"; echo "
"; echo "

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