本文整理汇总了PHP中AGI_AsteriskManager::disconnect方法的典型用法代码示例。如果您正苦于以下问题:PHP AGI_AsteriskManager::disconnect方法的具体用法?PHP AGI_AsteriskManager::disconnect怎么用?PHP AGI_AsteriskManager::disconnect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AGI_AsteriskManager
的用法示例。
在下文中一共展示了AGI_AsteriskManager::disconnect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: array
function Reload_Asterisk_SIP_IAX($security_key)
{
if (!$this->Check_SecurityKey ($security_key)) {
return array("ERROR", "INVALID KEY");
}
include (dirname(__FILE__)."/phpagi/phpagi-asmanager.php");
$as = new AGI_AsteriskManager();
$res = $as->connect(MANAGER_HOST, MANAGER_USERNAME, MANAGER_SECRET);
if ($res) {
$res_sip = $as->Command('sip reload');
$res_iax = $as->Command('iax2 reload');
$as->disconnect();
} else {
return array(false, "Cannot connect to the Asterisk Manager !");
}
return array (true, 'Asterisk SIP / IAX config reloaded SUCCESS');
}
示例4: 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";
}
}
示例5: system
}
echo "Executing post apply script <b>" . $amp_conf["POST_RELOAD"] . "</b><pre>";
system($amp_conf["POST_RELOAD"]);
echo "</pre>";
if (!isset($amp_conf["POST_RELOAD_DEBUG"]) || $amp_conf["POST_RELOAD_DEBUG"] != "1" && $amp_conf["POST_RELOAD_DEBUG"] != "true") {
echo "</div><br>";
}
echo "\n\t\t\t<script>\n\t\t\t\tfunction hideWaitBanner()\n\t\t\t\t{\n\t\t\t\t\tdocument.getElementById('idWaitBanner').className = 'clsHidden';\n\t\t\t\t}\n\n\t\t\t\tdocument.getElementById('idWaitBanner').innerHTML = 'Configuration applied';\n\t\t\t\tdocument.getElementById('idWaitBanner').className = 'clsWaitFinishOK';\n\t\t\t\tsetTimeout('hideWaitBanner()',3000);\n\t\t\t</script>\n\t\t";
}
$amp_conf = parse_amportal_conf("/etc/amportal.conf");
$hosts = split(',', $amp_conf['MANAGERHOSTS']);
foreach ($hosts as $host) {
$astman = new AGI_AsteriskManager();
if ($res = $astman->connect($host, $amp_conf["AMPMGRUSER"], $amp_conf["AMPMGRPASS"])) {
$astman->command("reload");
$astman->disconnect();
} else {
echo "<h3>Cannot connect to Asterisk Manager {$host} with " . $amp_conf["AMPMGRUSER"] . "/" . $amp_conf["AMPMGRPASS"] . "</h3>This module requires access to the Asterisk Manager. Please ensure Asterisk is running and access to the manager is available.</div>";
exit;
}
}
$wOpBounce = rtrim($_SERVER['SCRIPT_FILENAME'], $currentFile) . 'bounce_op.sh';
exec($wOpBounce . '>/dev/null');
$sql = "UPDATE admin SET value = 'false' WHERE variable = 'need_reload'";
$result = $db->query($sql);
if (DB::IsError($result)) {
die($result->getMessage());
}
$need_reload[0] = 'false';
}
if ($need_reload[0] == 'true') {
示例6: Aastra_get_number_mapping_Asterisk
function Aastra_get_number_mapping_Asterisk()
{
# Connect to AGI
$as = new AGI_AsteriskManager();
$res = $as->connect();
# Get the list of users
$raw = $as->database_show('AMPUSER');
# Purge the answers
foreach ($raw as $key => $value) {
if (strstr($key, 'info/cell')) {
$array_out[$value] = preg_replace(array('/\\/AMPUSER\\//', '/\\/info\\/cell/'), array('', ''), $key);
}
if (strstr($key, 'info/home')) {
$array_out[$value] = preg_replace(array('/\\/AMPUSER\\//', '/\\/info\\/home/'), array('', ''), $key);
}
if (strstr($key, 'info/other')) {
$array_out[$value] = preg_replace(array('/\\/AMPUSER\\//', '/\\/info\\/other/'), array('', ''), $key);
}
}
# Disconnect properly
$as->disconnect();
# Return directory array
return $array_out;
}
示例7:
'',
'',
'1',
'ChanSpy',
$b.',qx',
'',
'',
'',
'',
'Async',
''
);
*/
$r = $manager->Originate('SIP/' . $a, $a, 'from-internal', '1', 'ChanSpy', $b . ',' . $type, '', $b, '', '', 'Async', '');
echo $r['Response'] . ' mode=' . $type;
$manager->disconnect();
//echo 'ok';
/*
'Канал для вызова, например SIP/1001',
'Экстеншн для диалплана',
'Контекст диалплана',
'Приоритет контекста диалплана',
'Или приложение астериска для запуска, например playback',
'параметры приложения, например путь к аудиофайлу',
'таймаут',
'Номер абонента от которого идет вызов или имя',
'переменные для диалплана',
'account - незнаю зачем, не использовал еще',
'Синхронный или асинхронный запрос (ждет или не ждет ответа о состоянии запроса)',
'actionid - тоже пока не использовал'
*/
示例8: is_agent_logged
function is_agent_logged($agent)
{
global $queue_members;
$queue_members = '';
# Transcode for device and user mode
$agent = Aastra_get_userdevice_Asterisk($agent);
# Not logged by default
$return = False;
# Connect to AGI
$asm = new AGI_AsteriskManager();
$asm->connect();
# Add event handlers to retrieve the answer
$asm->add_event_handler('queuestatuscomplete', 'asm_event_queues');
$asm->add_event_handler('queuemember', 'asm_event_agents');
# Retrieve info
while (!$queue_members) {
$asm->QueueStatus();
$count++;
if ($count == 10) {
break;
}
}
# Get info for all the queues
foreach ($queue_members as $agent_a) {
if ($agent_a['Location'] == 'Local/' . $agent . '@from-queue/n' or $agent_a['Location'] == 'Local/' . $agent . '@from-internal/n') {
$return = True;
break;
}
}
# Disconnect properly
$asm->disconnect();
# Return Status
return $return;
}
示例9: header
header("location:dialplan.php");
break;
case 'sip':
$asm = new AGI_AsteriskManager();
if ($asm->connect('localhost', 'admin', 'managerpwd')) {
$dp = $asm->command("sip reload");
sleep(1);
}
$asm->disconnect();
header("location:sipf.php");
break;
case 'iax':
$asm = new AGI_AsteriskManager();
if ($asm->connect('localhost', 'admin', 'managerpwd')) {
$dp = $asm->command("iax2 reload");
sleep(1);
}
$asm->disconnect();
header("location:iaxf.php");
break;
case 'dahdi':
$asm = new AGI_AsteriskManager();
if ($asm->connect('localhost', 'admin', 'managerpwd')) {
$dp = $asm->command("dahdi restart");
sleep(1);
}
$asm->disconnect();
header("location:dahdif.php");
break;
}
}
示例10:
function AMI_Command($command)
{
$astman = new AGI_AsteriskManager();
$return = false;
if (!$astman->connect("127.0.0.1", 'admin', obtenerClaveAMIAdmin())) {
$this->errMsg = "Error connect AGI_AsteriskManager";
$return = false;
} else {
$r = $astman->command($command);
$return = $r["data"];
$astman->disconnect();
}
return $return;
}
示例11: array
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 {
/* Para poder pasar el parámetro Data correctamente, se debe usar
* un valor separado por barra vertical (|) en Asterisk 1.4.x y una
* coma en Asterisk 1.6.x. Para es se requiere detectar la versión
* de Asterisk.
*/
// CoreSettings sólo está disponible en asterisk 1.6.x
$r = $astman->send_request('CoreSettings');
$asteriskVersion = array(1, 4, 0, 0);
if ($r['Response'] == 'Success' && isset($r['AsteriskVersion'])) {
$asteriskVersion = explode('.', $r['AsteriskVersion']);
// CoreSettings reporta la versión de Asterisk
} else {
// no hay soporte CoreSettings en Asterisk Manager, se asume Asterisk 1.4.x.
}
$versionMinima = array(1, 6, 0);
while (count($versionMinima) < count($asteriskVersion)) {
array_push($versionMinima, 0);
}
while (count($versionMinima) > count($asteriskVersion)) {
array_push($asteriskVersion, 0);
}
$sSeparador = $asteriskVersion >= $versionMinima ? ',' : '|';
$parameters = $this->Originate($command_data['device'], $command_data['callerid'], $command_data['room'], $sSeparador);
$salida = $astman->send_request('Originate', $parameters);
$astman->disconnect();
if (strtoupper($salida["Response"]) != "ERROR") {
return explode("\n", $salida["Response"]);
} else {
return false;
}
}
return false;
}
示例12: array
function AsteriskManager_Command($host, $user, $password, $command_data)
{
global $arrLang;
$salida = array();
$astman = new AGI_AsteriskManager();
//$salida = array();
if (!$astman->connect("{$host}", "{$user}", "{$password}")) {
$this->errMsg = $arrLang["Error when connecting to Asterisk Manager"];
} else {
foreach ($command_data as $key => $valor) {
$salida = $astman->send_request('Command', array('Command' => "{$valor}"));
}
$astman->disconnect();
$salida["Response"] = isset($salida["Response"]) ? $salida["Response"] : "";
if (strtoupper($salida["Response"]) != "ERROR") {
return explode("\n", $salida["Response"]);
} else {
return false;
}
}
return false;
}
示例13: getTrunkGroupsDAHDI
/**
* Procedimiento para listar todos los grupos de troncales DAHDI que han sido
* definidos. Este procedimiento requiere que Asterisk esté en ejecución en el
* sistema y que soporte el comando "dahdi show channels group N".
*
* @return mixed Arreglo de la siguiente forma:
* array(0 => array("DAHDI/1", "DAHDI/2", "DAHDI/3"), 1 => array("DAHDI/4", "DAHDI/5", "DAHDI/6"))
*/
function getTrunkGroupsDAHDI()
{
require_once '/var/lib/asterisk/agi-bin/phpagi-asmanager.php';
require_once 'libs/paloSantoConfig.class.php';
// Obtener las credenciales y abrir la conexión Asterisk
$pConfig = new paloConfig("/etc", "amportal.conf", "=", "[[:space:]]*=[[:space:]]*");
$arrConfig = $pConfig->leer_configuracion(false);
$astman = new AGI_AsteriskManager();
if (!$astman->connect('localhost', $arrConfig['AMPMGRUSER']['valor'], $arrConfig['AMPMGRPASS']['valor'])) {
// No se puede conectar a AMI, se intenta parsear configuración
return $grupos = getTrunkGroupsDAHDI_config();
} else {
/*
Chan Extension Context Language MOH Interpret Blocked State
1 from-pstn default In Service
2 from-pstn default In Service
3 from-pstn default In Service
4 from-pstn default In Service
*/
// Se conoce que los números de grupo van de 0 a 63
$grupos = array();
$bSoportado = TRUE;
// Se asume que el comando soporta listar por grupos
for ($iGrupo = 0; $iGrupo < 64 && $bSoportado; $iGrupo++) {
$r = $astman->Command("dahdi show channels group {$iGrupo}");
if (isset($r['data'])) {
$lineas = explode("\n", $r['data']);
foreach ($lineas as $sLinea) {
/* Si una línea empieza con Usage, entonces la versión de
Asterisk no soporta la extensión "group N" del comando
"dahdi show channels" */
if (strpos($sLinea, 'Usage') === 0) {
$bSoportado = FALSE;
break;
}
if (preg_match('/^\\s+(\\d+)/', $sLinea, $regs)) {
$grupos[$iGrupo][] = 'DAHDI/' . $regs[1];
}
}
}
}
$astman->disconnect();
if (!$bSoportado) {
// Comando AMI no soportado, se intenta parsear configuración
$grupos = getTrunkGroupsDAHDI_config();
}
return $grupos;
}
}
示例14: setrobstatus
function setrobstatus($account, $incomingvalue, $mode)
{
require_once 'common/php-asmanager.php';
$amp_conf = parse_amportal_conf("/etc/amportal.conf");
$hosts = split(',', $amp_conf['MANAGERHOSTS']);
foreach ($hosts as $host) {
$astman = new AGI_AsteriskManager();
if ($res = $astman->connect($host, $amp_conf["AMPMGRUSER"], $amp_conf["AMPMGRPASS"])) {
if ($mode == "write") {
if ($incomingvalue == "Never") {
$astman->database_del("ROBCHECK", $account);
}
if ($incomingvalue == "Always") {
$astman->database_put("ROBCHECK", $account, "ENABLED");
}
$robstatus = null;
}
if ($mode == "read") {
$existrobstatus = $astman->database_get("ROBCHECK", $account);
if ($existrobstatus) {
$robstatus = "Always";
} else {
$robstatus = "Never";
}
}
$astman->disconnect();
} else {
echo "<h3>Cannot connect to Asterisk Manager {$host} with " . $amp_conf["AMPMGRUSER"] . "/" . $amp_conf["AMPMGRPASS"] . "</h3>This module requires access to the Asterisk Manager. Please ensure Asterisk is running and access to the manager is available.</div>";
exit;
}
}
return $robstatus;
}
示例15: DbConnect
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';
$buddyfile = BUDDY_SIP_FILE;
$_SESSION["is_sip_changed"] = 0;
if ($_SESSION["is_iax_changed"] == 0) {
$_SESSION["is_sip_iax_change"] = 0;
}
} else {
$TABLE_BUDDY = 'cc_iax_buddies';
$buddyfile = BUDDY_IAX_FILE;
$_SESSION["is_iax_changed"] = 0;