phpagi-asmanager.php

来自「asterisk 計費模塊」· PHP 代码 · 共 700 行 · 第 1/2 页

PHP
700
字号
    */    function Hangup($channel)    {      return $this->send_request('Hangup', array('Channel'=>$channel));  }   /**    * List IAX Peers    *    * @link http://www.voip-info.org/wiki-Asterisk+Manager+API+Action+IAXpeers    */    function IAXPeers()    {      return $this->send_request('IAXPeers');    }   /**    * List available manager commands    *    * @link http://www.voip-info.org/wiki-Asterisk+Manager+API+Action+ListCommands    */    function ListCommands()    {      return $this->send_request('ListCommands');    }   /**    * Logoff Manager    *    * @link http://www.voip-info.org/wiki-Asterisk+Manager+API+Action+Logoff    */    function Logoff()    {      return $this->send_request('Logoff');    }   /**    * Check Mailbox Message Count    *    * @link http://www.voip-info.org/wiki-Asterisk+Manager+API+Action+MailboxCount    * @param string $mailbox    */    function MailboxCount($mailbox)    {      return $this->send_request('MailboxCount', array('Mailbox'=>$mailbox));    }   /**    * Check Mailbox    *    * @link http://www.voip-info.org/wiki-Asterisk+Manager+API+Action+MailboxStatus    * @param string $mailbox    */    function MailboxStatus($mailbox)    {	      return $this->send_request('MailboxStatus', array('Mailbox'=>$mailbox));    }   /**    * Monitor a channel    *    * @link http://www.voip-info.org/wiki-Asterisk+Manager+API+Action+Monitor    * @param string $channel    * @param string $file    */    function Monitor($channel, $file)    {      return $this->send_request('Monitor', array('Channel'=>$channel, 'File'=>$file));    }   /**    * Originate Call    *    * @link http://www.voip-info.org/wiki-Asterisk+Manager+API+Action+Originate    * @param string $channel    * @param string $exten    * @param string $context    * @param string $priority    * @param integer $timeout    * @param string $callerid    * @param string $variable    * @param string $account    * @param string $application    * @param string $data    */    function Originate($channel, $exten, $context, $priority, $timeout, $callerid, $variable, $account, $application, $data)    {      $parameters = array();      if($channel) $parameters['Channel'] = $channel;      if($exten) $parameters['Exten'] = $exten;      if($context) $parameters['Context'] = $context;      if($priority) $parameters['Priority'] = $priority;      if($timeout) $parameters['Timeout'] = $timeout;      if($callerid) $parameters['CallerID'] = $callerid;      if($variable) $parameters['Variable'] = $variable;      if($account) $parameters['Account'] = $account;      if($application) $parameters['Application'] = $application;      if($data) $parameters['Data'] = $data;      return $this->send_request('Originate', $parameters);    }	   /**    * List parked calls    *    * @link http://www.voip-info.org/wiki-Asterisk+Manager+API+Action+ParkedCalls    */    function ParkedCalls()    {      return $this->send_request('ParkedCalls');    }   /**    * Ping    *    * @link http://www.voip-info.org/wiki-Asterisk+Manager+API+Action+Ping    */    function Ping()    {      return $this->send_request('Ping');    }   /**    * Queues    *    * @link http://www.voip-info.org/wiki-Asterisk+Manager+API+Action+Queues    */    function Queues()    {      return $this->send_request('Queues');    }   /**    * Queue Status    *    * @link http://www.voip-info.org/wiki-Asterisk+Manager+API+Action+QueueStatus    */    function QueueStatus()    {      return $this->send_request('QueueStatus');    }   /**    * Redirect    *    * @link http://www.voip-info.org/wiki-Asterisk+Manager+API+Action+Redirect    * @param string $channel    * @param string $extrachannel    * @param string $exten    * @param string $context    * @param string $priority    */    function Redirect($channel, $extrachannel, $exten, $context, $priority)    {      return $this->send_request('Redirect', array('Channel'=>$channel, 'ExtraChannel'=>$extrachannel, 'Exten'=>$exten,                                                   'Context'=>$context, 'Priority'=>$priority));    }   /**    * Set the CDR UserField    */    function SetCDRUserField()    {      // XXX need to look at source to find this function...      return $this->send_request('SetCDRUserField');    }   /**    * Set Channel Variable    *    * @link http://www.voip-info.org/wiki-Asterisk+Manager+API+Action+SetVar    * @param string $channel    * @param string $variable    * @param string $value    */    function SetVar($channel, $variable, $value)    {      return $this->send_request('SetVar', array('Channel'=>$channel, 'Variable'=>$variable, 'Value'=>$value));    }   /**    * List SIP Peers    */    function SIPpeers()    {      // XXX need to look at source to find this function...      return $this->send_request('SIPpeers');    }   /**    * Channel Status    *    * @link http://www.voip-info.org/wiki-Asterisk+Manager+API+Action+Status    * @param string $channel    */    function Status($channel)    {	      return $this->send_request('Status', array('Channel'=>$channel));    }   /**    * Stop monitoring a channel    *    * @link http://www.voip-info.org/wiki-Asterisk+Manager+API+Action+StopMonitor    * @param string $channel    */    function StopMontor($channel)    {      return $this->send_request('StopMonitor', array('Channel'=>$channel));    }   /**    * Dial over Zap channel while offhook    */    function ZapDialOffhook()    {      // XXX need to look at source to find this function...      return $this->send_request('ZapDialOffhook');    }   /**    * Toggle Zap channel Do Not Disturb status OFF    */    function ZapDNDoff()    {      // XXX need to look at source to find this function...      return $this->send_request('ZapDNDoff');    }   /**    * Toggle Zap channel Do Not Disturb status ON    */    function ZapDNDon()    {      // XXX need to look at source to find this function...      return $this->send_request('ZapDNDon');    }   /**    * Hangup Zap Channel    */    function ZapHangup()    {      // XXX need to look at source to find this function...      return $this->send_request('ZapHangup');    }   /**    * Transfer Zap Channel    */    function ZapTransfer()    {      // XXX need to look at source to find this function...      return $this->send_request('ZapTransfer');    }   /*    * Log a message    *    * @param string $message    * @param integer $level from 1 to 4    */    function log($message, $level=1)    {      if($this->pagi != false)        $this->pagi->conlog($message, $level);      else        error_log(date('r') . ' - ' . $message);    }   /**    * Add event handler    *    * Known Events include ( http://www.voip-info.org/wiki-asterisk+manager+events )    *   Link - Fired when two voice channels are linked together and voice data exchange commences.    *   Unlink - Fired when a link between two voice channels is discontinued, for example, just before call completion.    *   Newexten -    *   Hangup -    *   Newchannel -    *   Newstate -    *   Reload - Fired when the "RELOAD" console command is executed.    *   Shutdown -    *   ExtensionStatus -    *   Rename -    *   Newcallerid -    *   Alarm -    *   AlarmClear -    *   Agentcallbacklogoff -    *   Agentcallbacklogin -    *   Agentlogoff -    *   MeetmeJoin -    *   MessageWaiting -    *   join -    *   leave -    *   AgentCalled -    *   ParkedCall -    *   Cdr -    *   ParkedCallsComplete -    *   QueueParams -    *   QueueMember -    *   QueueStatusEnd -    *   Status -    *   StatusComplete -    *   ZapShowChannels -    *   ZapShowChannelsComplete -    *    * @param string $event type or * for default handler    * @param string $callback function    * @return boolean sucess    */    function add_event_handler($event, $callback)    {      $event = strtolower($event);      if(isset($this->event_handlers[$event]))      {        $this->log("$event handler is already defined, not over-writing.");        return false;      }      $this->event_handlers[$event] = $callback;      return true;    }   /**    * Process event    *    * @access private    * @param array $parameters    * @return mixed result of event handler or false if no handler was found    */    function process_event($parameters)    {      $ret = false;      $e = strtolower($parameters['Event']);      $this->log("Got event.. $e");		      $handler = '';      if(isset($this->event_handlers[$e])) $handler = $this->event_handlers[$e];      elseif(isset($this->event_handlers['*'])) $handler = $this->event_handlers['*'];      if(function_exists($handler))      {        $this->logg("Execute handler $handler");        $ret = $handler($e, $parameters, $this->server, $this->port);      }      else        $this->log("No event handler for event '$e'");      return $ret;    }  }?>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?