Ejemplo n.º 1
0
#!/usr/bin/php -q
<?php 
/**
 *  This file is part of SNEP.
 *
 *  SNEP 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 3 of the License, or
 *  (at your option) any later version.
 *
 *  SNEP 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.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with SNEP.  If not, see <http://www.gnu.org/licenses/>.
 */
require_once "agi_base.php";
if ($argc != 3) {
    $asterisk->verbose("This script expects one extension and variable name as parameter.");
    exit(1);
}
try {
    $peer = PBX_Interfaces::getChannelOwner($argv[1]);
} catch (Exception $e) {
    $asterisk->verbose("[{$requestid}] Failure to resolv extension: " . $e->getMessage(), 1);
    exit(1);
}
$asterisk->set_variable($argv[2], $peer->getNumero());
Ejemplo n.º 2
0
 /**
  * Construtor da requisição.
  *
  * Para identificar o objeto de origem estamos considerando seu callerid
  * como número de ramal. Isso, obviamente, irá identificar somente ramais.
  * Importante ressaltar que a "falsidade ideológica" entre os canais é mais
  * fácil de ser praticada nesse sistema.
  *
  * @param int $origem
  * @param string $destino
  * @param string $contexto
  */
 public function __construct($agi_request)
 {
     parent::__construct($agi_request);
     $log = Snep_Logger::getInstance();
     // Descobrindo se esse canal criado pertence a alguma entidade
     // cadastrada no snep.
     $channel = $this->request['channel'];
     // removendo o hash de controle do asterisk
     // de TECH/ID-HASH para TECH/ID
     $channel = strpos($channel, '-') ? substr($channel, 0, strpos($channel, '-')) : $channel;
     $object = PBX_Interfaces::getChannelOwner($channel);
     if ($object instanceof Snep_Trunk && $object->allowExtensionMapping()) {
         try {
             $exten = PBX_Usuarios::get($this->origem);
             if ($exten->getInterface() instanceof PBX_Asterisk_Interface_VIRTUAL) {
                 $object = $exten;
             }
         } catch (PBX_Exception_NotFound $ex) {
             // Ignore
         }
     }
     $this->setSrcObj($object);
     if (is_object($object)) {
         $classname = get_class($this->getSrcObj());
         $log->info("Identified source: {$this->getSrcObj()} ({$classname})");
     }
 }