/** * Método para compactibilidade com código do snep, aqui há uma melhoria * nas consultas simples reutilizando socket onde é possível. * * @param string $comando - Comando a ser executado * * @param string $quebra - Para retornar somente as linhas que contenham * o conteudo dessa variável * * @param boolean $tudo - Esse parametro não é usado (?!) * * @return Dados da consulta */ public function status_asterisk($comando, $quebra, $tudo = False) { if ($comando != "Agents" && $comando != "Status") { $cmd = self::$asterisk->command($comando); $retorno = $cmd['data']; if ($quebra != "") { $ret_quebrado = " "; foreach (explode("\n", $cmd['data']) as $line) { if (preg_match("/{$quebra}/", $line)) { $ret_quebrado .= $line; break; } } return $ret_quebrado; } else { return $cmd['data']; } } else { // Enviando requisição de status self::$asterisk->send_request($comando, array()); // Enviando esse objeto para cuidar dos responses self::$asterisk->wait_event($this); return $this->return; } }
function AsteriskManagerAPI($action, $parameters, $return_data = false) { global $arrLang; $astman_host = "127.0.0.1"; $astman_user = '******'; $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; }
/** * 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; }
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; }
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 }
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; }
// $bootstrap_settings['amportal_conf_initialized'] = false; $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
echo "0"; } elseif ($editpin == '') { echo "0"; } else { echo "1"; $fname = explode('<', $callerid); $cid = $fname[0]; $dname = explode('"', $cid); $name = $dname[1]; $sql = "INSERT INTO sip_buddies(name,accountcode,secret,callerid,context,mailbox,nat,host,callgroup,pickupgroup,qualify,allow,videosupport,type,permit,deny,transport,dtmfmode,directmedia,encryption) Values('{$extension}','{$account}','{$secret}','{$callerid}','{$context}','{$mailbox}','{$nat}','{$host}','{$callgroup}','{$pickupgroup}','{$qualify}','{$allow}','{$videosupport}','{$type}','{$permit}','{$deny}','{$transport}','{$dtmfmode}','{$directmedia}','{$encryption}')"; mysql_query($sql) or die(mysql_error()); $sql1 = "INSERT INTO claves(clave_nombre,user_edit,user_exten) Values('{$name}','{$editpin}','{$mailbox}')"; mysql_query($sql1) or die(mysql_error()); $sql2 = "INSERT INTO voicemail_users(customer_id,context,mailbox,password,fullname,email) Values('{$extension}','default','{$mailbox}','{$extension}','{$name}','{$email}')"; mysql_query($sql2) or die(mysql_error()); $file = basename("/etc/asterisk/extensions.conf"); $text = file_get_contents("/etc/asterisk/extensions.conf"); $text = str_replace(';;last line extensions', 'exten => ' . ${extension} . ',1,GoSub(subSTDExten,internalcall,1(${EXTEN}))\\r;;last line extensions', $text); $text = str_replace(';;last line hints', 'exten => ' . ${extension} . ',hint,SIP/' . ${extension} . '\\r;;last line hints', $text); file_put_contents('/etc/asterisk/' . $file, $text); $asm = new AGI_AsteriskManager(); if ($asm->connect('localhost', 'admin', 'managerpwd')) { $peer = $asm->command("sip reload"); sleep(1); $peer = $asm->command("dialplan reload"); sleep(1); } $asm->disconnect(); exec("sh /etc/asterisk/rn.sh"); } }
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; }
<?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; } /* Перед началом работы агент регистрируется, воодя свой номер и пинкод
**/ include '../lib/agent.defines.php'; 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 {
<?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); }
define('DEBUG_CONF', 1); $host = A2Billing::instance()->set_def_conf($manager_section, 'host', 'localhost'); $uname = A2Billing::instance()->set_def_conf($manager_section, 'username', 'a2billing'); $password = A2Billing::instance()->set_def_conf($manager_section, 'secret', ''); if ($verbose > 2) { echo "Starting manager-eventd.\n"; } $num_tries = 0; while ($num_tries < 10) { $num_tries++; $dbh = A2Billing::DBHandle(); if (!$dbh) { echo "Cannot connect to database, exiting.."; break; } $as = new AGI_AsteriskManager(); if ($verbose < 2) { $as->nolog = true; } else { if ($verbose > 3) { $as->debug = true; } } // && CONNECTING connect($server=NULL, $username=NULL, $secret=NULL) $res = $as->connect($host, $uname, $password); if (!$res) { echo str_params(_("Cannot connect to asterisk manager @%1. Please check manager configuration...\n"), array($host), 1); sleep(60); continue; } if ($verbose > 2) {
function Aastra_send_userevent_Asterisk($event, $data, $asm = NULL) { # Connect to AGI if needed if ($asm == NULL) { $as = new AGI_AsteriskManager(); $res = $as->connect(); } else { $as = $asm; } # Send request $res = $as->UserEvent($event, $data); # Disconnect properly if ($asm == NULL) { $as->disconnect(); } }
//if(strlen($b)==6){ // $b='78452'.$b; //} $context = get_param($a); $manager->Originate('SIP/' . $a, $b, $context, '1', '', '', '20000', 'SIP/' . $b, 'tTr', '', 'Async', ''); $manager->disconnect(); } if (isset($_GET['spy']) and isset($_GET['a']) and isset($_GET['b']) and isset($_GET['type'])) { print_r($_GET); $a = $_GET['a']; $b = $_GET['b']; echo $type = $_GET['type']; //$a= номер экстеншна //$b= канал который будем слушать include 'phpagi/phpagi.php'; $manager = new AGI_AsteriskManager(); $manager->connect(); //if(strlen($b)==6){ // $b='78452'.$b; //} //$context=get_param($a); /* $manager->Originate( 'SIP/'.$a, '', '', '1', 'ChanSpy', $b.',qx', '', '',
include '../lib/phpagi/phpagi-asmanager.php'; include '../lib/admin.smarty.php'; if (!has_rights(ACX_MAINTENANCE)) { Header("HTTP/1.0 401 Unauthorized"); Header("Location: PP_error.php?c=accessdenied"); die; } check_demo_mode_intro(); // #### HEADER SECTION $smarty->display('main.tpl'); ?> <br> <center> <?php $astman = new AGI_AsteriskManager(); $res = $astman->connect(MANAGER_HOST, MANAGER_USERNAME, MANAGER_SECRET); /* $Id: page.parking.php 2243 2006-08-12 17:13:17Z p_lindheimer $ */ //Copyright (C) 2006 Astrogen LLC // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License //as published by the Free Software Foundation; either version 2 //of the License, or (at your option) any later version. // //This program is distributed in the hope that it will be useful, //but WITHOUT ANY WARRANTY; without even the implied warranty of //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //GNU General Public License for more details. $dispnum = 'asteriskinfo'; //used for switch on config.php
<?php session_start(); if (!(isset($_SESSION['login']) && $_SESSION['login'] != '')) { header("Location: ../index.php"); } else { $app = $_GET['app']; require_once '/var/lib/asterisk/agi-bin/phpagi/phpagi-asmanager.php'; $asm = new AGI_AsteriskManager(); if ($asm->connect('localhost', 'admin', 'managerpwd')) { $peer = $asm->command("core show application " . $app); $test = preg_replace("/Privilege: Command/s", '', $peer['data']); $test1 = preg_replace("/\\n/s", '<br>', $test); $test2 = preg_replace("/\\[/s", '<b>[', $test1); $test3 = preg_replace("/\\]/s", ']</b>', $test2); echo $test3; } $asm->disconnect(); }
private function _get_AGI_AsteriskManager() { $ip_asterisk = '127.0.0.1'; $user_asterisk = 'admin'; $pass_asterisk = function_exists('obtenerClaveAMIAdmin') ? obtenerClaveAMIAdmin() : 'elastix456'; $astman = new AGI_AsteriskManager(); if (!$astman->connect($ip_asterisk, $user_asterisk, $pass_asterisk)) { $this->errMsg = "Error when connecting to Asterisk Manager"; return NULL; } else { return $astman; } }
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'); }
<?php /* * ivr-monitor.php * * Григорий Майстренко (Grygorii Maistrenko) * grygoriim@gmail.com */ include dirname(__FILE__) . "/lib/ivr-monitor.conf.php"; include dirname(__FILE__) . "/lib/phpagi-2.14/phpagi-asmanager.php"; //$_ivr_config_path $asm = new AGI_AsteriskManager(); /* * Try to connect to server */ if ($asm->connect($_asm_host, $_asm_user, $_asm_passwd)) { /* * Parse IVR config */ $menu_table = json_decode(file_get_contents($_ivr_config_path), TRUE); if (!$menu_table || !count($menu_table)) { return false; } /* * Get active channels with AGI lounched */ $info = $asm->command("core show channels"); $data = array(); /* * Filter lines with AGI */
<?php // // Copyright (C) 2009-2065 FreePBX-Swiss Urs Rueedi // require_once '../../modules/phoneprovision/functions.inc.php'; require_once 'include/config.inc.php'; require_once 'include/backend.inc.php'; require_once '../../functions.inc.php'; require_once '../../common/php-asmanager.php'; // get settings $amp_conf = parse_amportal_conf("/etc/amportal.conf"); $asterisk_conf = parse_asterisk_conf(rtrim($amp_conf["ASTETCDIR"], "/") . "/asterisk.conf"); $astman = new AGI_AsteriskManager(); if (!($res = $astman->connect("127.0.0.1", $amp_conf["AMPMGRUSER"], $amp_conf["AMPMGRPASS"]))) { unset($astman); } // get MAC address and type of phone $value = snom_decode_HTTP_header(); $ip = $value[3]; // adding portnumer if ($ip) { if (!preg_match("#:#", $ip)) { $ip = $ip . ":80"; } } $provdata = get_prov_data(); foreach ($provdata as $key => $value) { if ($value['ip'] == $ip) { $exten = $key; }
// Original Release by Philippe Lindheimer // Copyright Philippe Lindheimer (2009) // Copyright Bandwidth.com (2009) /* TODO: Get proper licensing. This is free to use and distribute for use. The licensing is NOT GPL or other open source and derivative work is not allowed. */ // TODO: set this in production error_reporting(0); include_once 'sipstation.utility.php'; if (!@(include_once "common/json.inc.php")) { include_once "/var/www/html/admin/common/json.inc.php"; include_once "/var/www/html/admin/functions.inc.php"; $amp_conf = parse_amportal_conf("/etc/amportal.conf"); require_once '/var/www/html/admin/common/php-asmanager.php'; $astman = new AGI_AsteriskManager(); if (!isset($amp_conf["ASTMANAGERPROXYPORT"]) || !($res = $astman->connect("127.0.0.1:" . $amp_conf["ASTMANAGERPROXYPORT"], $amp_conf["AMPMGRUSER"], $amp_conf["AMPMGRPASS"], 'off'))) { if (!($res = $astman->connect("127.0.0.1:" . $amp_conf["ASTMANAGERPORT"], $amp_conf["AMPMGRUSER"], $amp_conf["AMPMGRPASS"], 'off'))) { unset($astman); } } include_once "/var/www/html/admin/common/db_connect.php"; include_once "/var/www/html/admin/modules/core/functions.inc.php"; if (!isset($active_modules)) { $active_modules = array(); } } global $db; global $sipstation_xml_version; /* For testing: */
require_once 'functions.php'; $extdisplay = isset($_REQUEST['extdisplay']) ? $_REQUEST['extdisplay'] : 'summary'; $arr_all = array("Uptime" => "show uptime", "Active Channel(s)" => "core show channels", "Sip Channel(s)" => "sip show channels", "IAX2 Channel(s)" => "iax2 show channels", "Sip Registry" => "sip show registry", "Sip Peers" => "sip show peers", "IAX2 Registry" => "iax2 show registry", "IAX2 Peers" => "iax2 show peers", "Subscribe/Notify" => "core show hints", "Zaptel driver info" => "zap show channels", "Zaptel driver status" => "zap show status", "Conference Info" => "meetme", "Queues Info" => "queue show", "Voicemail users" => "voicemail show users"); $arr_registries = array("Sip Registry" => "sip show registry", "IAX2 Registry" => "iax2 show registry"); $arr_channels = array("Active Channel(s)" => "core show channels", "Sip Channel(s)" => "sip show channels", "IAX2 Channel(s)" => "iax2 show channels"); $arr_peers = array("Sip Peers" => "sip show peers", "IAX2 Peers" => "iax2 show peers"); $arr_sip = array("Sip Registry" => "sip show registry", "Sip Peers" => "sip show peers"); $arr_iax = array("IAX2 Registry" => "iax2 show registry", "IAX2 Peers" => "iax2 show peers"); $arr_conferences = array("Conference Info" => "meetme"); $arr_subscriptions = array("Subscribe/Notify" => "core show hints"); $arr_voicemail = array("Voicemail users" => "voicemail show users"); $arr_queues = array("Queues Info" => "queue show"); $arr_database = array("Database Info" => "database show"); $amp_conf = parse_amportal_conf("/etc/amportal.conf"); $host = $amp_conf['MANAGERHOSTS']; $astman = new AGI_AsteriskManager(); $res = $astman->connect($host, $amp_conf["AMPMGRUSER"], $amp_conf["AMPMGRPASS"]); if ($res) { //get version (1.4) $response = $astman->send_request('Command', array('Command' => 'core show version')); if (preg_match('/No such command/', $response['data'])) { // get version (1.2) $response = $astman->send_request('Command', array('Command' => 'show version')); } $verinfo = $response['data']; } else { // could not connect to asterisk manager, try console $verinfo = exec('asterisk -V'); } preg_match('/Asterisk (\\d+(\\.\\d+)*)(-?(\\S*))/', $verinfo, $matches); $verinfo = $matches[1];
echo "<div id='idWaitBanner' class='clsWait'> Please wait while applying configuration</div>"; if (!isset($amp_conf["POST_RELOAD_DEBUG"]) || $amp_conf["POST_RELOAD_DEBUG"] != "1" && $amp_conf["POST_RELOAD_DEBUG"] != "true") { echo "<div style='display:none'>"; } 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()); }
################################################################### # Main code ################################################################### # Wait 5 seconds to begin for not much other reason than this lets # you test the functionality with your own extension sleep(5); # Collect arguments $notifications = $argv[1]; $notify = explode(',', $notifications); $extension = $argv[2]; $vars['__EXTENSION'] = $extension; if ($argc == 4) { $vars['NAME_RECORDING'] = $argv[3]; } # Connect to the AGI $asm = new AGI_AsteriskManager(); $asm->connect(); # Get language $language = Aastra_get_language(); # Notify each phone for ($i = 0; $i < sizeof($notify); $i++) { $vars['__REALCALLERIDNUM'] = $notify[$i]; $state = $asm->ExtensionState($notify[$i], 'default'); if ($state['Status'] != 0) { $vars['NOTIFY_VM'] = 'true'; } while (list($key, $val) = each($vars)) { $vars_arr[] = "{$key}={$val}"; } if (Aastra_compare_version_Asterisk('1.6')) { $vars = implode(',', $vars_arr);
/** * 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"; } }
<?php session_start(); if (!(isset($_SESSION['login']) && $_SESSION['login'] != '')) { header("Location: ../index.php"); } else { require_once '/var/lib/asterisk/agi-bin/phpagi/phpagi-asmanager.php'; $asm = new AGI_AsteriskManager(); if ($asm->connect('localhost', 'admin', 'managerpwd')) { $peer = $asm->command("sip show peers"); //print_r($peer); preg_match('/\\[(.*)/', $peer['data'], $val); //print_r($val); $online = explode(",", $val[1]); $offline = explode(",", $val[1]); $offline = explode("Unmonitored", $offline[1]); echo "ONline: " . $online[0]; echo "\noffline: " . $offline[0]; } $asm->disconnect(); $jsondata['offiax'] = $offline[0]; echo json_encode($jsondata); } ?>
<?php require_once '/var/lib/asterisk/agi-bin/phpagi/phpagi-asmanager.php'; session_start(); if (!(isset($_SESSION['login']) && $_SESSION['login'] != '')) { header("Location: ../index.php"); } else { $asm = new AGI_AsteriskManager(); if ($asm->connect('localhost', 'admin', 'managerpwd')) { $peer = $asm->command("core show channels"); preg_match('/(.*) active call/', $peer['data'], $res); //print_r($res); $calls = explode(" ", $res[0]); } $asm->disconnect(); $jsondata['calls'] = $calls[0]; echo json_encode($jsondata); } ?>
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; } }
} } return $conf; } # Get configuration $amportalconf = isset($_ENV["FREEPBXCONFIG"]) && strlen($_ENV["FREEPBXCONFIG"]) ? $_ENV["FREEPBXCONFIG"] : "/etc/amportal.conf"; $amp_conf = getconf($amportalconf); if (!isset($amp_conf["ASTMANAGERHOST"])) { $amp_conf["ASTMANAGERHOST"] = '127.0.0.1'; } if (!isset($amp_conf["ASTMANAGERPORT"])) { $amp_conf["ASTMANAGERPORT"] = '5038'; } require_once $amp_conf['AMPWEBROOT'] . "/admin/functions.inc.php"; require_once $amp_conf['AMPWEBROOT'] . "/admin/common/php-asmanager.php"; $astman = new AGI_AsteriskManager(); if (!($res = $astman->connect($amp_conf["ASTMANAGERHOST"] . ":" . $amp_conf["ASTMANAGERPORT"], $amp_conf["AMPMGRUSER"], $amp_conf["AMPMGRPASS"]))) { unset($astman); exit(10); } if (!$argv[1] || strstr($argv[1], "/") || strstr($argv[1], "..")) { // You must supply a single filename, which will be written to /tmp exit(1); } $dump = file_get_contents("/tmp/ampbackups." . $argv[1] . "/astdb.dump"); // Before restoring, let's clear out all of the current settings for the main objects // but as a safety, if the dump file is empy, we won't clear it out. // if (!empty($dump)) { $arr = explode("\n", $dump); foreach ($deltree as $family) {