. // // Copyright (C) 2006 Astrogen LLC // $dispnum = 'asteriskinfo'; //used for switch on config.php $tabindex = 0; $action = isset($_REQUEST['action'])?$_REQUEST['action']:''; $extdisplay = isset($_REQUEST['extdisplay'])?$_REQUEST['extdisplay']:'summary'; $chan_dahdi = ast_with_dahdi(); $modesummary = _("Summary"); $moderegistries = _("Registries"); $modechannels = _("Channels"); $modepeers = _("Peers"); $modesip = _("Sip Info"); $modeiax = _("IAX Info"); $modeconferences = _("Conferences"); $modesubscriptions = _("Subscriptions"); $modeall = _("Full Report"); $uptime = _("Uptime"); $activechannels = _("Active Channel(s)"); $sipchannels = _("Sip Channel(s)"); $iax2channels = _("IAX2 Channel(s)"); $iax2peers = _("IAX2 Peers"); $sipregistry = _("Sip Registry"); $sippeers = _("Sip Peers"); $iax2registry = _("IAX2 Registry"); $subscribenotify = _("Subscribe/Notify"); if ($chan_dahdi){ $zapteldriverinfo = _("DAHDI driver info"); } else { $zapteldriverinfo = _("Zaptel driver info"); } $conferenceinfo = _("Conference Info"); $voicemailusers = _("Voicemail Users"); $modes = array( "summary" => $modesummary, "registries" => $moderegistries, "channels" => $modechannels, "peers" => $modepeers, "sip" => $modesip, "iax" => $modeiax, "conferences" => $modeconferences, "subscriptions" => $modesubscriptions, "voicemail" => $voicemailusers, "all" => $modeall ); $arr_all = array( $uptime => "show uptime", $activechannels => "show channels", $sipchannels => "sip show channels", $iax2channels => "iax2 show channels", $sipregistry => "sip show registry", $sippeers => "sip show peers", $iax2registry => "iax2 show registry", $iax2peers => "iax2 show peers", $subscribenotify => "show hints", $zapteldriverinfo => "zap show channels", $conferenceinfo => "meetme", $voicemailusers => "show voicemail users", ); $arr_registries = array( $sipregistry => "sip show registry", $iax2registry => "iax2 show registry", ); $arr_channels = array( $activechannels => "show channels", $sipchannels => "sip show channels", $iax2channels => "iax2 show channels", ); $arr_peers = array( $sippeers => "sip show peers", $iax2peers => "iax2 show peers", ); $arr_sip = array( $sipregistry => "sip show registry", $sippeers => "sip show peers", ); $arr_iax = array( $iax2registry => "iax2 show registry", $iax2peers => "iax2 show peers", ); $arr_conferences = array( $conferenceinfo => "meetme", ); $arr_subscriptions = array( $subscribenotify => "show hints" ); $arr_voicemail = array( $voicemailusers => "show voicemail users", ); $engineinfo = engine_getinfo(); $astver = $engineinfo['version']; if (version_compare($astver, '1.4', 'ge')) { $arr_all[$uptime]="core show uptime"; $arr_all[$activechannels]="core show channels"; $arr_all[$subscribenotify]="core show hints"; $arr_all[$voicemailusers]="voicemail show users"; $arr_channels[$activechannels]="core show channels"; $arr_subscriptions[$subscribenotify]="core show hints"; $arr_voicemail[$voicemailusers]="voicemail show users"; } if ($chan_dahdi){ $arr_all[$zapteldriverinfo]="dahdi show channels"; } if ($chan_dahdi){ $arr_all[$zapteldriverinfo]="dahdi show channels"; } ?>

$value) { ?>

"._("The module was unable to connect to the Asterisk manager.
Make sure Asterisk is running and your manager.conf settings are proper.

"); ?>

								send_request('Command',array('Command'=>$value));
								$new_value = $response['data'];
								echo ltrim($new_value,'Privilege: Command');
								?>
							

" tabindex="">
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 = '
'; $htmlOutput .= ''; foreach ($arr as $key => $value) { $response = $astman->send_request('Command',array('Command'=>$value)); $astout = explode("\n",$response['data']); switch ($key) { case $uptime: $uptime = $astout; $htmlOutput .= '"; $htmlOutput .= ''; break; case $activesipchannels: $activeSipChannel = $astout; $activeSipChannel_count = getActiveChannel($activeSipChannel, $channelType = 'SIP'); $htmlOutput .= ''; $htmlOutput .= ""; break; case $activeiax2channels: $activeIAX2Channel = $astout; $activeIAX2Channel_count = getActiveChannel($activeIAX2Channel, $channelType = 'IAX2'); $htmlOutput .= ""; $htmlOutput .= ''; break; break; case $sipregistry: $sipRegistration = $astout; $sipRegistration_count = getRegistration($sipRegistration, $channelType = 'SIP'); $htmlOutput .= ''; $htmlOutput .= ""; break; case $iax2registry: $iax2Registration = $astout; $iax2Registration_count = getRegistration($iax2Registration, $channelType = 'IAX2'); $htmlOutput .= ""; $htmlOutput .= ''; break; case $sippeers: $sipPeer = $astout; $sipPeer_arr = getPeer($sipPeer, $channelType = 'SIP'); if($sipPeer_arr['offline'] != 0){ $sipPeerColor = 'red'; }else{ $sipPeerColor = '#000000'; } $htmlOutput .= ''; $htmlOutput .= ""; break; case $iax2peers: $iax2Peer = $astout; $iax2Peer_arr = getPeer($iax2Peer, $channelType = 'IAX2'); if($iax2Peer_arr['offline'] != 0){ $iax2PeerColor = 'red'; }else{ $iax2PeerColor = '#000000'; } $htmlOutput .= ""; $htmlOutput .= ''; break; default: } } $htmlOutput .= '
'.$uptime[1]."
".$uptime[2]."
".$key.$activeSipChannel_count."".$key.$activeIAX2Channel_count."
".$key.$sipRegistration_count."".$key.$iax2Registration_count."
".$key."
    "._("Online: ").$sipPeer_arr['online']."
    "._("Offline: ")."".$sipPeer_arr['offline']."
".$key."
    "._("Online: ").$iax2Peer_arr['online']."
    "._("Offline: ")."".$iax2Peer_arr['offline']."
    "._("Unmonitored: ").$iax2Peer_arr['unmonitored']."
'; return $htmlOutput."
"; } ?>