Get information about a sip peer

  1. <?php
  2.   require_once('../phpagi-asmanager.php');
  3.  
  4.   if(!isset($_SERVER['argv'][1]))
  5.   {
  6.     echo "Usage:\t{$_SERVER['_']} {$_SERVER['argv'][0]} peer\n\n";
  7.     exit;
  8.   }
  9.  
  10.   $asm new AGI_AsteriskManager();
  11.   if($asm->connect())
  12.   {
  13.     $peer $asm->command("sip show peer {$_SERVER['argv'][1]}");
  14.     if(!strpos($peer['data']':'))
  15.       echo $peer['data'];
  16.     else
  17.     {
  18.       $data array();
  19.       foreach(explode("\n"$peer['data']as $line)
  20.       {
  21.         $a strpos('z'.$line':'1;
  22.         if($a >= 0$data[trim(substr($line0$a))trim(substr($line$a 1));
  23.       }
  24.       print_r($data);
  25.     }
  26.  
  27.     $asm->disconnect();
  28.   }
  29. ?>

Documentation generated on Thu, 30 Sep 2010 02:22:07 -0700 by phpDocumentor 1.4.2