Advertisement
michelthiel

Untitled

Apr 27th, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.71 KB | None | 0 0
  1. <html>
  2.     <head>
  3.         <title>CHAMADA ATIVA URA INTELIGENTE</title>
  4.         <meta http-equiv="refresh" content="1"> <!-- See the difference? -->
  5.     </head>
  6.     <body>
  7.  
  8.         <?php
  9.         //$ramal=$_POST["ramal2"];
  10.  
  11.         include('https://189.76.240.26/teste/phpagi-asmanager.php');
  12.  
  13.         $db = 'connection';
  14.         $dbuser = 'root';
  15.         $dbpass = '0319ts';
  16.         $dbhost = 'localhost';
  17.  
  18.  
  19.         $conn = new mysqli($dbhost, $dbuser, $dbpass, $db);
  20.         if ($conn->connect_error) {
  21.             die("Erro ao conectar ao banco: " . $conn->connect_error);
  22.             //$agi->exec("NoOp","Erro ao conectar ao banco: " . $conn->connect_error);
  23.             //$agi->hangup();
  24.         }
  25.  
  26.  
  27.  
  28.         // $ramal = "267";
  29.  
  30.         echo "<h1>Canais ativos para o ramal: $ramal</h1>";
  31.  
  32.         $asm = new AGI_AsteriskManager();
  33.  
  34.         if ($asm->connect("189.76.240.26","rapidanet","1234qwer"))
  35.         {
  36.             $channels = $asm->command("core show channels verbose");
  37.             //$data = array();
  38.             foreach(explode("\n", $channels['data']) as $line)
  39.             {
  40.  
  41.                 //$line ="SIP/transit-novo-000 ext-queues           900                42 Up      Queue        900,t,,,,,,,,             51997160356     00:11:44 10024                   Local/267@from-queue";          
  42.                 $channel = trim(substr($line,0,21));
  43.                 $context = trim(substr($line,21,21));
  44.                 $ext = trim(substr($line,42,17));
  45.                 $clid = trim(substr($line,111,16));
  46.                 //$accountcode = trim(substr($line,136,12)); COMENTEI ESSA LINHA
  47.                 $accountcode="10026";
  48.                 $dst = trim(substr($line,160,20));
  49.  
  50.                 //echo "$accountcode - $clid - $dst\n";
  51.  
  52.                 if ($accountcode <> "") {
  53.                    // if (stristr($dst,$ramal) && stristr($channel,"transit")) {  COMENTEI ESSA LINHA
  54.                         // dados do cliente
  55.                         //$result = $conn->query("SELECT * FROM pabx WHERE Codigo = '$accountcode' LIMIT 1");
  56.                         $result = $conn->query("select clientes.*, pabx.* from clientes, pabx where clientes.Codigo = pabx.Cliente and pabx.Codigo = '$accountcode' limit 1");
  57.                         $row = $result->fetch_assoc();
  58.                         if ($result->num_rows > 0){
  59.                             print_r($row);
  60.  
  61.                         }
  62.                    // }  COMENTEI ESSA LINHA
  63.                 }
  64.                 //$clid="";
  65.                 //$dstch="";
  66.             }
  67.         }
  68.  
  69.         // echo "$accountcode - $clid - $ext";    
  70.         //print_r($v);
  71.  
  72.         $asm->disconnect();
  73.         $conn->close();
  74.  
  75.         ?>
  76.     </body>
  77. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement