Esempio n. 1
0
             break;
         }
     }
 }
 $settings = sipstation_get_sip_settings();
 $json_array['asterisk_registerattempts'] = $settings['Outbound reg. attempts'];
 // Get the Asterisk Registration Status, retry once if bumping into Auth. Sent.
 //
 $try_again = false;
 $cnt = 0;
 do {
     if ($try_again) {
         sleep(1);
     }
     $cnt++;
     $trunk_status = sipstation_get_registration_status($json_array['sip_username']);
     foreach ($json_array['gateways'] as $gw => $trunk) {
         if (isset($trunk_status[$trunk])) {
             $json_array['asterisk_registry'][$gw] = $trunk_status[$trunk];
             $try_again = $trunk_status[$trunk] == 'Auth. Sent' ? true : $try_again;
         } else {
             $json_array['asterisk_registry'][$gw] = _("Not Registered");
         }
     }
 } while ($try_again && $cnt < 2);
 $routes = core_routing_list();
 foreach ($routes as $route) {
     $route_name = $route['name'] . $route['route_id'];
     $trunks = core_routing_getroutetrunksbyid($route['route_id']);
     $gw1 = array_search($trunknum1, $trunks);
     $gw1 = $gw1 === false ? 0 : $gw1 + 1;
Esempio n. 2
0
    }
}
/* For testing:
*/
/*
include_once("common/json.inc.php");
*/
/* We can use the cached config data as we were just told that
   trunk params have changed and chose to update
 */
$sip_username = $_POST['sip_username'];
$gateways['gw1'] = $_POST['gw1'];
$gateways['gw2'] = $_POST['gw2'];
$json_array['status'] = 'success';
// Get the Asterisk Registration Status
$trunk_status = sipstation_get_registration_status($sip_username);
foreach ($gateways as $gw => $trunk) {
    if (isset($trunk_status[$trunk])) {
        $json_array['asterisk_registry'][$gw] = $trunk_status[$trunk];
    } else {
        $json_array['asterisk_registry'][$gw] = _("Not Registered");
    }
}
for ($i = 1; $i < 3; $i++) {
    $channelid = "fpbx-{$i}-{$sip_username}";
    $trunk_status = sipstation_get_peer_status($channelid);
    if ($trunk_status['sipstation_status'] == 'ok') {
        $json_array['trunk_qualify']["gw{$i}"] = $trunk_status['Status'];
    }
}
$json = new Services_JSON();