1){ if($channelType == NULL || $channelType == 'SIP'){ $sipChannel_arr = $channel_arr; $sipChannel_arrCount = count($sipChannel_arr); $sipChannel_string = $sipChannel_arr[$sipChannel_arrCount - 2]; $sipChannel = explode(' ', $sipChannel_string); return $sipChannel[0]; }elseif($channelType == 'IAX2'){ $iax2Channel_arr = $channel_arr; $iax2Channel_arrCount = count($iax2Channel_arr); $iax2Channel_string = $iax2Channel_arr[$iax2Channel_arrCount - 2]; $iax2Channel = explode(' ', $iax2Channel_string); return $iax2Channel[0]; } } } function getRegistration($registration, $channelType = 'SIP'){ if($channelType == NULL || $channelType == 'SIP'){ $sipRegistration_arr = $registration; $sipRegistration_count = count($sipRegistration_arr); return $sipRegistration_count-3; }elseif($channelType == 'IAX2'){ $iax2Registration_arr = $registration; $iax2Registration_count = count($iax2Registration_arr); return $iax2Registration_count-3; } } function getPeer($peer, $channelType = NULL){ global $astver_major, $astver_minor; global $astver; if(count($peer) > 1){ if($channelType == NULL || $channelType == 'SIP'){ $sipPeer = $peer; $sipPeer_count = count($sipPeer); $sipPeerInfo_arr['sipPeer_count'] = $sipPeer_count -3; $sipPeerInfo_string = $sipPeer[$sipPeer_count -2]; $sipPeerInfo_arr2 = explode('[',$sipPeerInfo_string); $sipPeerInfo_arr3 = explode(' ',$sipPeerInfo_arr2[1]); if (version_compare($astver, '1.4', 'ge')) { $sipPeerInfo_arr['online'] = $sipPeerInfo_arr3[1] + $sipPeerInfo_arr3[6]; $sipPeerInfo_arr['offline'] = $sipPeerInfo_arr3[3] + $sipPeerInfo_arr3[8]; }else{ $sipPeerInfo_arr['online'] = $sipPeerInfo_arr3[0]; $sipPeerInfo_arr['offline'] = $sipPeerInfo_arr3[3]; } return $sipPeerInfo_arr; }elseif($channelType == 'IAX2'){ $iax2Peer = $peer; $iax2Peer_count = count($iax2Peer); $iax2PeerInfo_arr['iax2Peer_count'] = $iax2Peer_count -3; $iax2PeerInfo_string = $iax2Peer[$iax2Peer_count -2]; $iax2PeerInfo_arr2 = explode('[',$iax2PeerInfo_string); $iax2PeerInfo_arr3 = explode(' ',$iax2PeerInfo_arr2[1]); $iax2PeerInfo_arr['online'] = $iax2PeerInfo_arr3[0]; $iax2PeerInfo_arr['offline'] = $iax2PeerInfo_arr3[2]; $iax2PeerInfo_arr['unmonitored'] = $iax2PeerInfo_arr3[4]; return $iax2PeerInfo_arr; } } } function buildAsteriskInfo(){ global $astman; global $astver; $uptime = _("Uptime: "); $activesipchannels = _("Active SIP Channel(s): "); $activeiax2channels = _("Active IAX2 Channel(s): "); $sipregistry = _("Sip Registry: "); $iax2registry = _("IAX2 Registry: "); $sippeers = _("Sip Peers: "); $iax2peers = _("IAX2 Peers: "); $arr = array( $uptime => "show uptime", $activesipchannels => "sip show channels", $activeiax2channels => "iax2 show channels", $sipregistry => "sip show registry", $iax2registry => "iax2 show registry", $sippeers => "sip show peers", $iax2peers => "iax2 show peers", ); if (version_compare($astver, '1.4', 'ge')) { $arr[$uptime] = 'core show uptime'; } $htmlOutput = '
| '.$uptime[1]." ".$uptime[2]." | ";
$htmlOutput .= '|
| ".$key.$activeSipChannel_count." | "; break; case $activeiax2channels: $activeIAX2Channel = $astout; $activeIAX2Channel_count = getActiveChannel($activeIAX2Channel, $channelType = 'IAX2'); $htmlOutput .= "".$key.$activeIAX2Channel_count." | "; $htmlOutput .= '
| ".$key.$sipRegistration_count." | "; break; case $iax2registry: $iax2Registration = $astout; $iax2Registration_count = getRegistration($iax2Registration, $channelType = 'IAX2'); $htmlOutput .= "".$key.$iax2Registration_count." | "; $htmlOutput .= '
| ".$key." "._("Online: ").$sipPeer_arr['online']." "._("Offline: ")."".$sipPeer_arr['offline']." | ";
break;
case $iax2peers:
$iax2Peer = $astout;
$iax2Peer_arr = getPeer($iax2Peer, $channelType = 'IAX2');
if($iax2Peer_arr['offline'] != 0){
$iax2PeerColor = 'red';
}else{
$iax2PeerColor = '#000000';
}
$htmlOutput .= "".$key." "._("Online: ").$iax2Peer_arr['online']." "._("Offline: ")."".$iax2Peer_arr['offline']." "._("Unmonitored: ").$iax2Peer_arr['unmonitored']." | ";
$htmlOutput .= '