当前位置: 首页>>代码示例>>PHP>>正文


PHP AGI_AsteriskManager::connect方法代码示例

本文整理汇总了PHP中AGI_AsteriskManager::connect方法的典型用法代码示例。如果您正苦于以下问题:PHP AGI_AsteriskManager::connect方法的具体用法?PHP AGI_AsteriskManager::connect怎么用?PHP AGI_AsteriskManager::connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AGI_AsteriskManager的用法示例。


在下文中一共展示了AGI_AsteriskManager::connect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getContent


//.........这里部分代码省略.........
    $benchmark_starttime = microtime_float();
    /*************/
    $type = isset($_REQUEST['type']) ? $_REQUEST['type'] : 'setup';
    // Ojo, modifique ligeramente la sgte. linea para que la opcion por omision sea extensions
    if (isset($_REQUEST['display'])) {
        $display = $_REQUEST['display'];
    } else {
        $display = 'extensions';
        $_REQUEST['display'] = 'extensions';
    }
    $extdisplay = isset($_REQUEST['extdisplay']) ? $_REQUEST['extdisplay'] : null;
    $skip = isset($_REQUEST['skip']) ? $_REQUEST['skip'] : 0;
    $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
    $quietmode = isset($_REQUEST['quietmode']) ? $_REQUEST['quietmode'] : '';
    // determine module type to show, default to 'setup'
    $type_names = array('tool' => 'Tools', 'setup' => 'Setup', 'cdrcost' => 'Call Cost');
    /*************************************************************/
    /* Este bloque pertenece en su mayoria al archivo header.php */
    /* ya que no estaban registrando ciertas variables globales; */
    /* asi que lo repito aqui y evito parchar dicho archivo y    */
    /* otros mas.                                                */
    /*************************************************************/
    // include base functions
    global $amp_conf_defaults;
    require_once '/var/www/html/admin/functions.inc.php';
    require_once '/var/www/html/admin/common/php-asmanager.php';
    // Hack to avoid patching admin/functions.inc.php
    $GLOBALS['amp_conf_defaults'] = $amp_conf_defaults;
    // get settings
    $amp_conf = parse_amportal_conf("/etc/amportal.conf");
    $asterisk_conf = parse_asterisk_conf($amp_conf["ASTETCDIR"] . "/asterisk.conf");
    $astman = new AGI_AsteriskManager();
    // attempt to connect to asterisk manager proxy
    if (!isset($amp_conf["ASTMANAGERPROXYPORT"]) || !($res = $astman->connect("127.0.0.1:" . $amp_conf["ASTMANAGERPROXYPORT"], $amp_conf["AMPMGRUSER"], $amp_conf["AMPMGRPASS"]))) {
        // attempt to connect directly to asterisk, if no proxy or if proxy failed
        if (!($res = $astman->connect("127.0.0.1:" . $amp_conf["ASTMANAGERPORT"], $amp_conf["AMPMGRUSER"], $amp_conf["AMPMGRPASS"]))) {
            // couldn't connect at all
            unset($astman);
        }
    }
    if (!isset($astman) || is_null($astman)) {
        return _tr('Failed to connect to Asterisk Manager Interface') . ' - ' . "127.0.0.1:" . $amp_conf["ASTMANAGERPORT"];
    }
    $GLOBALS['amp_conf'] = $amp_conf;
    $GLOBALS['asterisk_conf'] = $asterisk_conf;
    $GLOBALS['astman'] = $astman;
    // Hack to avoid patching common/db_connect.php
    // I suppose the used database is mysql
    require_once 'DB.php';
    //PEAR must be installed
    $db_user = $amp_conf["AMPDBUSER"];
    $db_pass = $amp_conf["AMPDBPASS"];
    $db_host = $amp_conf["AMPDBHOST"];
    $db_name = $amp_conf["AMPDBNAME"];
    $datasource = 'mysql://' . $db_user . ':' . $db_pass . '@' . $db_host . '/' . $db_name;
    $db = DB::connect($datasource);
    // attempt connection
    $GLOBALS['db'] = $db;
    if (!isset($_SESSION['AMP_user'])) {
        $_SESSION['AMP_user'] = new ampuser($amp_conf['AMPDBUSER']);
        $_SESSION['AMP_user']->setAdmin();
    }
    // Requiring header.php
    include '/var/www/html/admin/header.php';
    // The next block is to fix a music on hold issue
    $category = strtr(isset($_REQUEST['category']) ? $_REQUEST['category'] : '', " ./\"\\'\\`", "------");
开发者ID:hardikk,项目名称:HNH,代码行数:67,代码来源:contentFreePBX.php

示例2: getInstance

 /**
  * Get the instance
  *
  * @throws OSS_Asterisk_AMI_ConnectionException
  * @return AGI_AsteriskManager
  */
 public function getInstance()
 {
     if ($this->_instance === null) {
         $conf = $this->getOptions();
         if (!class_exists('AGI_AsteriskManager')) {
             require_once 'phpagi-asmanager.php';
         }
         $this->_instance = new AGI_AsteriskManager();
         if (!$this->_instance->connect($conf["host"], $conf["username"], $conf["secret"])) {
             throw new OSS_Asterisk_AMI_ConnectionException('Could not connect to the Asterisk server ' . $conf['host']);
         }
     }
     return $this->_instance;
 }
开发者ID:opensolutions,项目名称:oss-framework,代码行数:20,代码来源:AsteriskMI.php

示例3: AsteriskManagerAPI

 function AsteriskManagerAPI($action, $parameters, $return_data = false)
 {
     global $arrLang;
     $astman_host = "127.0.0.1";
     $astman_user = 'admin';
     $astman_pwrd = obtenerClaveAMIAdmin();
     $astman = new AGI_AsteriskManager();
     $astman->pagi = new dummy_pagi();
     if (!$astman->connect("{$astman_host}", "{$astman_user}", "{$astman_pwrd}")) {
         $this->errMsg = _tr("Error when connecting to Asterisk Manager");
     } else {
         $salida = $astman->send_request($action, $parameters);
         $astman->disconnect();
         if (strtoupper($salida["Response"]) != "ERROR") {
             if ($return_data) {
                 return $salida;
             } else {
                 return explode("\n", $salida["Response"]);
             }
         } else {
             return false;
         }
     }
     return false;
 }
开发者ID:hardikk,项目名称:HNH,代码行数:25,代码来源:paloSantoControlPanel.class.php

示例4: explode

 function AsteriskManager_Originate($host, $user, $password, $command_data)
 {
     global $arrLang;
     $astman = new AGI_AsteriskManager();
     if (!$astman->connect("{$host}", "{$user}", "{$password}")) {
         $this->errMsg = $arrLang["Error when connecting to Asterisk Manager"];
     } else {
         $parameters = $this->Originate($command_data['origen'], $command_data['destino'], $command_data['channel'], $command_data['description']);
         $salida = $astman->send_request('Originate', $parameters);
         $astman->disconnect();
         if (strtoupper($salida["Response"]) != "ERROR") {
             return explode("\n", $salida["Response"]);
         } else {
             return false;
         }
     }
     return false;
 }
开发者ID:hardikk,项目名称:HNH,代码行数:18,代码来源:paloSantoRecordings.class.php

示例5: get_agent_status

function get_agent_status($queue, $agent)
{
    global $queue_members;
    # Connect to AGI
    $asm = new AGI_AsteriskManager();
    $asm->connect();
    # Add event handlers to retrieve the answer
    $asm->add_event_handler('queuestatuscomplete', 'Aastra_asm_event_queues_Asterisk');
    $asm->add_event_handler('queuemember', 'Aastra_asm_event_agents_Asterisk');
    # Retrieve info
    while (!$queue_members) {
        $asm->QueueStatus();
        $count++;
        if ($count == 10) {
            break;
        }
    }
    # Get info for the given queue
    $status['Logged'] = False;
    $status['Paused'] = False;
    foreach ($queue_members as $agent_a) {
        if ($agent_a['Queue'] == $queue && $agent_a['Location'] == 'Local/' . $agent . '@from-queue/n' or $agent_a['Queue'] == $queue && $agent_a['Location'] == 'Local/' . $agent . '@from-internal/n') {
            $status['Logged'] = True;
            if ($agent_a['Paused'] == '1') {
                $status['Paused'] = True;
            }
            $status['Type'] = $agent_a['Membership'];
            $status['CallsTaken'] = $agent_a['CallsTaken'];
            $status['LastCall'] = $agent_a['LastCall'];
            break;
        }
        # Get Penalty
        $penalty = $asm->database_get('QPENALTY', $queue . '/agents/' . $agent);
        if ($penalty == '') {
            $penalty = '0';
        }
        $status['Penalty'] = $penalty;
    }
    # Disconnect properly
    $asm->disconnect();
    # Return Status
    return $status;
}
开发者ID:jamesrusso,项目名称:Aastra_Scripts,代码行数:43,代码来源:queues.php

示例6: callback_engine

function callback_engine(&$A2B, $server, $username, $secret, $AmiVars, $destination, $tariff) {

    $A2B -> cardnumber = $AmiVars[4];

    if ($A2B -> callingcard_ivr_authenticate_light ($error_msg))
    {
	$RateEngine = new RateEngine();
	$RateEngine -> webui = 0;

//	LOOKUP RATE : FIND A RATE FOR THIS DESTINATION
	$A2B -> agiconfig['accountcode'] = $A2B -> cardnumber;
	$A2B -> agiconfig['use_dnid'] = 1;
	$A2B -> agiconfig['say_timetocall'] = 0;
	$A2B -> extension = $A2B -> dnid = $A2B -> destination = $destination;

	$resfindrate = $RateEngine->rate_engine_findrates($A2B, $destination, $tariff);

//	IF FIND RATE
	if ($resfindrate!=0)
	{
	    $res_all_calcultimeout = $RateEngine->rate_engine_all_calcultimeout($A2B, $A2B->credit);
	    if ($res_all_calcultimeout)
	    {
		$ast = new AGI_AsteriskManager();
		$res = $ast -> connect($server, $username, $secret);
		if (!$res) return -4;
//		MAKE THE CALL
		$res = $RateEngine->rate_engine_performcall(false, $destination, $A2B, 8, $AmiVars, $ast);
		$ast -> disconnect();
		if ($res !== false) return $res;
		else return -2; // not enough free trunk for make call
	    }
	    else return -3; // not have enough credit to call you back
	}
	else return -1; // no route to call back your phonenumber
    }
    else return -1; // ERROR MESSAGE IS CONFIGURE BY THE callingcard_ivr_authenticate_light
}
开发者ID:nixonch,项目名称:a2billing,代码行数:38,代码来源:callback_daemon.php

示例7: array

$amp_conf =& $freepbx_conf->parse_amportal_conf("/etc/amportal.conf", $amp_conf);
// set the language so local module languages take
set_language();
$asterisk_conf =& $freepbx_conf->get_asterisk_conf();
$bootstrap_settings['amportal_conf_initialized'] = true;
//connect to cdrdb if requestes
if ($bootstrap_settings['cdrdb']) {
    $dsn = array('phptype' => $amp_conf['CDRDBTYPE'] ? $amp_conf['CDRDBTYPE'] : $amp_conf['AMPDBENGINE'], 'hostspec' => $amp_conf['CDRDBHOST'] ? $amp_conf['CDRDBHOST'] : $amp_conf['AMPDBHOST'], 'username' => $amp_conf['CDRDBUSER'] ? $amp_conf['CDRDBUSER'] : $amp_conf['AMPDBUSER'], 'password' => $amp_conf['CDRDBPASS'] ? $amp_conf['CDRDBPASS'] : $amp_conf['AMPDBPASS'], 'port' => $amp_conf['CDRDBPORT'] ? $amp_conf['CDRDBPORT'] : '3306', 'database' => $amp_conf['CDRDBNAME'] ? $amp_conf['CDRDBNAME'] : 'asteriskcdrdb');
    $cdrdb = DB::connect($dsn);
}
$bootstrap_settings['astman_connected'] = false;
if (!$bootstrap_settings['skip_astman']) {
    require_once $dirname . '/libraries/php-asmanager.php';
    $astman = new AGI_AsteriskManager($bootstrap_settings['astman_config'], $bootstrap_settings['astman_options']);
    // attempt to connect to asterisk manager proxy
    if (!$amp_conf["ASTMANAGERPROXYPORT"] || !($res = $astman->connect($amp_conf["ASTMANAGERHOST"] . ":" . $amp_conf["ASTMANAGERPROXYPORT"], $amp_conf["AMPMGRUSER"], $amp_conf["AMPMGRPASS"], $bootstrap_settings['astman_events']))) {
        // attempt to connect directly to asterisk, if no proxy or if proxy failed
        if (!($res = $astman->connect($amp_conf["ASTMANAGERHOST"] . ":" . $amp_conf["ASTMANAGERPORT"], $amp_conf["AMPMGRUSER"], $amp_conf["AMPMGRPASS"], $bootstrap_settings['astman_events']))) {
            // couldn't connect at all
            unset($astman);
            freepbx_log(FPBX_LOG_CRITICAL, "Connection attmempt to AMI failed");
        } else {
            $bootstrap_settings['astman_connected'] = true;
        }
    }
} else {
    $bootstrap_settings['astman_connected'] = true;
}
//Because BMO was moved upward we have to inject this lower
if (isset($astman)) {
    FreePBX::create()->astman = $astman;
开发者ID:ntadmin,项目名称:framework,代码行数:31,代码来源:bootstrap.php

示例8: deleteExtensions

 function deleteExtensions()
 {
     $astman = new AGI_AsteriskManager();
     if (!$astman->connect("127.0.0.1", 'admin', obtenerClaveAMIAdmin())) {
         $this->errMsg = "Error connect AGI_AsteriskManager";
         return FALSE;
     }
     $exito = TRUE;
     $this->_DB->beginTransaction();
     // Lista de extensiones a borrar
     $sql = "SELECT id FROM devices WHERE tech = 'sip' OR tech = 'iax2'";
     $recordset = $this->_DB->fetchTable($sql);
     if (!is_array($recordset)) {
         $this->errMsg = $this->_DB->errMsg;
         $exito = FALSE;
     }
     $extlist = array();
     foreach ($recordset as $tupla) {
         $extlist[] = $tupla[0];
     }
     unset($recordset);
     foreach ($extlist as $ext) {
         // Borrar propiedades en base de datos de Asterisk
         foreach (array('AMPUSER', 'DEVICE', 'CW', 'CF', 'CFB', 'CFU') as $family) {
             $r = $astman->command("database deltree {$family}/{$ext}");
             if (!isset($r['Response'])) {
                 $r['Response'] = '';
             }
             if (strtoupper($r['Response']) == 'ERROR') {
                 $this->errMsg = _tr('Could not delete the ASTERISK database');
                 $exito = FALSE;
                 break;
             }
         }
         if (!$exito) {
             break;
         }
     }
     if ($exito) {
         foreach (array("DELETE s FROM sip s INNER JOIN devices d ON s.id=d.id and d.tech='sip'", "DELETE i FROM iax i INNER JOIN devices d ON i.id=d.id and d.tech='iax2'", "DELETE u FROM users u INNER JOIN devices d ON u.extension=d.id and (d.tech='sip' or d.tech='iax2')", "DELETE FROM devices WHERE tech='sip' or tech='iax2'") as $sql) {
             if (!$this->_DB->genQuery($sql)) {
                 $this->errMsg = $this->_DB->errMsg;
                 $exito = FALSE;
                 break;
             }
         }
     }
     // Aplicar cambios a la base de datos
     if (!$exito) {
         $this->_DB->rollBack();
         return FALSE;
     }
     $this->_DB->commit();
     $exito = $this->_recargarAsterisk($astman);
     $astman->disconnect();
     return $exito;
 }
开发者ID:netconstructor,项目名称:elastix-mt-gui,代码行数:57,代码来源:paloSantoExtensionsBatch.class.php

示例9: Smarty

<?php

require_once 'lib/Smarty.class.php';
require_once 'lib/smarty-gettext.php';
require_once "lib/php-asmanager.php";
require_once "lib/functions.inc.php";
require_once "config.php";
unset($AgentAccount);
session_start();
$smarty = new Smarty();
$smarty->register->block('t', 'smarty_translate');
$ami = new AGI_AsteriskManager();
$res = $ami->connect($ami_host, $ami_user, $ami_secret);
ini_set('display_errors', 'no');
ini_set('register_globals', 'yes');
ini_set('short_open_tag', 'yes');
$AgentsEntry = array();
$QueueParams = array();
$QueueMember = array();
$QueueEntry = array();
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
if ($_REQUEST['button'] == 'Submit') {
    $out = "<pre>" . shell_exec('/usr/sbin/asterisk -rx "show queues"') . "</pre>";
    echo $out;
}
/*
Перед началом работы агент регистрируется, воодя свой номер и пинкод
开发者ID:Open-Source-GIS,项目名称:lynks-ajax-panel,代码行数:31,代码来源:extensions-realtime.php

示例10: Header

include '../lib/agent.module.access.php';
include '../lib/regular_express.inc';
include '../lib/phpagi/phpagi-asmanager.php';
include '../lib/agent.smarty.php';
$FG_DEBUG = 0;
getpost_ifset(array('action', 'atmenu'));
if (!has_rights(ACX_CUSTOMER)) {
    Header("HTTP/1.0 401 Unauthorized");
    Header("Location: PP_error.php?c=accessdenied");
    die;
}
$DBHandle = DbConnect();
if ($action == "reload") {
    $as = new AGI_AsteriskManager();
    // && CONNECTING  connect($server=NULL, $username=NULL, $secret=NULL)
    $res = $as->connect(MANAGER_HOST, MANAGER_USERNAME, MANAGER_SECRET);
    if ($res) {
        if ($atmenu == "sipfriend") {
            $res = $as->Command('sip reload');
        } else {
            $res = $as->Command('iax2 reload');
        }
        $actiondone = 1;
        // && DISCONNECTING
        $as->disconnect();
    } else {
        $error_msg = "</br><center><b><font color=red>" . gettext("Cannot connect to the asterisk manager!<br>Please check your manager configuration.") . "</font></b></center>";
    }
} else {
    if ($atmenu == "sipfriend") {
        $TABLE_BUDDY = 'cc_sip_buddies';
开发者ID:pearlvoip,项目名称:a2billing,代码行数:31,代码来源:CC_generate_friend_file.php

示例11: unset

<?php

require_once '../admin/libraries/php-asmanager.php';
$astman = new AGI_AsteriskManager();
// attempt to connect to asterisk manager proxy
if (!($res = $astman->connect('127.0.0.1:5038', 'username', 'password', 'off'))) {
    // couldn't connect at all
    unset($astman);
    $_SESSION['ari_error'] = _("ARI does not appear to have access to the Asterisk Manager.") . " ({$errno})<br>" . _("Check the ARI 'main.conf.php' configuration file to set the Asterisk Manager Account.") . "<br>" . _("Check /etc/asterisk/manager.conf for a proper Asterisk Manager Account") . "<br>" . _("make sure [general] enabled = yes and a 'permit=' line for localhost or the webserver.");
}
$extensions = array(8250, 8298, 12076605342, 12075052482, 12074162828, 12074781320);
foreach ($extensions as $ext) {
    $inputs = array('Channel' => 'local/' . $ext . '@from-internal', 'Exten' => $ext, 'Context' => 'from-internal', 'Priority' => '1', 'Timeout' => NULL, 'CallerID' => 'OMG', 'Variable' => '', 'Account' => NULL, 'Application' => 'playback', 'Data' => 'hello-world', 'Async' => 1);
    /* Arguments to Originate: channel, extension, context, priority, timeout, callerid, variable, account, application, data */
    $status = $astman->Originate($inputs);
    var_dump($status);
}
开发者ID:bangordailynews,项目名称:FreePBX,代码行数:17,代码来源:callme.php

示例12: create_sipiax_friends_reload

	/**
     * Function create_sipiax_friends_reload
     * @public
     */
	static public function create_sipiax_friends_reload()
	{
		$FormHandler = FormHandler::GetInstance();
		self :: create_sipiax_friends();
		
		// RELOAD SIP & IAX CONF
		require_once (dirname(__FILE__)."/../phpagi/phpagi-asmanager.php");
		
		$as = new AGI_AsteriskManager();
		// && CONNECTING  connect($server=NULL, $username=NULL, $secret=NULL)
		$res =@  $as->connect(MANAGER_HOST,MANAGER_USERNAME,MANAGER_SECRET);				
		if	($res) {
			$res = $as->Command('sip reload');		
			$res = $as->Command('iax2 reload');		
			// && DISCONNECTING	
			$as->disconnect();
		} else {
			echo "Error : Manager Connection";
		}
	}
开发者ID:nixonch,项目名称:a2billing,代码行数:24,代码来源:Class.FormBO.php

示例13: array

$asm->disconnect();
?>
						<div id='appsinfo'></div>
						

                	                </div>

					<div class="tab-pane" id="funcs">
						<p>
							View the Help on the Listed Functions				
						</p>

						<?php 
require_once '/var/lib/asterisk/agi-bin/phpagi/phpagi-asmanager.php';
$asm = new AGI_AsteriskManager();
if ($asm->connect('localhost', 'admin', 'm4nag3rt3ts')) {
    $peer = $asm->command("core show functions");
    $data = array();
    echo "<select id='astfunc' name='astfunc' class='text ui-widget-content ui-corner-all'>";
    foreach (explode("\n", $peer['data']) as $line) {
        $func = explode(" ", $line);
        $astfunc = preg_replace("/\\s/", "", $func[0]);
        echo "<option value='" . $astfunc . "'>" . $func[0] . "</option>";
    }
    echo "</select>";
}
$asm->disconnect();
?>
						<div id='funcinfo'></div>

开发者ID:antirek,项目名称:DM-AsteriskGUI,代码行数:29,代码来源:dpgen.php

示例14: array

 function AsteriskManager_Command($command_data, $return_data = true)
 {
     global $arrLang;
     $salida = array();
     $astman = new AGI_AsteriskManager();
     if (!$astman->connect("127.0.0.1", "admin", obtenerClaveAMIAdmin())) {
         $this->errMsg = $arrLang["Error when connecting to Asterisk Manager"];
     } else {
         $salida = $astman->send_request('Command', array('Command' => "{$command_data}"));
         $astman->disconnect();
         $salida["Response"] = isset($salida["Response"]) ? $salida["Response"] : "";
         if (strtoupper($salida["Response"]) != "ERROR") {
             if ($return_data) {
                 return explode("\n", $salida["data"]);
             } else {
                 return explode("\n", $salida["Response"]);
             }
         } else {
             return false;
         }
     }
     return false;
 }
开发者ID:hardikk,项目名称:HNH,代码行数:23,代码来源:paloSantoSysInfo.class.php

示例15: explode

 function AsteriskManager_Hangup($host, $user, $password, $command_data)
 {
     $astman = new AGI_AsteriskManager();
     $channel = "";
     if (!$astman->connect("{$host}", "{$user}", "{$password}")) {
         $this->errMsg = _tr("Error when connecting to Asterisk Manager");
     } else {
         //
         $channelName = $command_data['channel'];
         $arrChannel = explode("/", $channelName);
         $pattern = "/^" . $arrChannel[0] . "\\/" . $arrChannel[1] . "/";
         exec("/usr/sbin/asterisk -rx 'core show channels concise'", $output, $retval);
         foreach ($output as $linea) {
             if (preg_match($pattern, $linea, $arrReg)) {
                 $arr = explode("!", $linea);
                 $channel = $arr[0];
             } else {
                 $channel = $channelName;
             }
         }
         $parameters = array('Channel' => $channel);
         $salida = $astman->send_request('Hangup', $parameters);
         $astman->disconnect();
         if (strtoupper($salida["Response"]) != "ERROR") {
             return explode("\n", $salida["Response"]);
         } else {
             return false;
         }
     }
     return false;
 }
开发者ID:netconstructor,项目名称:elastix-mt-gui,代码行数:31,代码来源:paloSantoRecordings.class.php


注:本文中的AGI_AsteriskManager::connect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。