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; $arr = array( "Uptime" => "show uptime", "Active SIP Channel(s)" => "sip show channels", "Active IAX2 Channel(s)" => "iax2 show channels", "Sip Registry" => "sip show registry", "IAX2 Registry" => "iax2 show registry", "Sip Peers" => "sip show peers", "IAX2 Peers" => "iax2 show peers", ); if (version_compare($astver, '1.4', 'ge')) { $arr['Uptime'] = 'core show uptime'; } $htmlOutput = '
| '.$uptime[1]." ".$uptime[2]." | ";
$htmlOutput .= '|
| Active Sip Channels: ".$activeSipChannel_count." | "; break; case 'Active IAX2 Channel(s)': $activeIAX2Channel = $astout; $activeIAX2Channel_count = getActiveChannel($activeIAX2Channel, $channelType = 'IAX2'); $htmlOutput .= "Active IAX2 Channels: ".$activeIAX2Channel_count." | "; $htmlOutput .= '
| SIP Registrations: ".$sipRegistration_count." | "; break; case 'IAX2 Registry': $iax2Registration = $astout; $iax2Registration_count = getRegistration($iax2Registration, $channelType = 'IAX2'); $htmlOutput .= "IAX2 Registrations: ".$iax2Registration_count." | "; $htmlOutput .= '
| SIP Peers Online: ".$sipPeer_arr['online']." Offline: ".$sipPeer_arr['offline']." | ";
break;
case 'IAX2 Peers':
$iax2Peer = $astout;
$iax2Peer_arr = getPeer($iax2Peer, $channelType = 'IAX2');
if($iax2Peer_arr['offline'] != 0){
$iax2PeerColor = 'red';
}else{
$iax2PeerColor = '#000000';
}
$htmlOutput .= "IAX2 Peers Online: ".$iax2Peer_arr['online']." Offline: ".$iax2Peer_arr['offline']." Unmonitored: ".$iax2Peer_arr['unmonitored']." | ";
$htmlOutput .= '