if ($audio == '') { $audio = $welcomeSound; } else { $audio = $basepath . "audio/" . $audio['data']; } $msg = date("r", time()) . " -- Call in progress -- Number:{$userNumber} -- Audio:{$audio}\n"; file_put_contents($basepath . "logs/callLog.txt", $msg, FILE_APPEND); $query = "update logs set status='Connected' where autoID='{$dbid}'"; $result = mysql_query($query) or die("Database Error"); $keys = "Nil"; $count = 0; do { if ($count > 2) { break; } $result = $agi->get_data("{$audio}", 5000, 1); $keys = $result['result']; if ($keys == "1" or $keys == "2") { break; } $count++; } while ($keys != 1 and $keys != 2); $query = "update logs set options='{$keys}' where autoID='{$dbid}'"; $result = mysql_query($query) or die("Database Error"); $msg = date("r", time()) . " -- User pressed {$keys} -- Number:{$userNumber} -- Audio:{$audio}\n"; file_put_contents($basepath . "logs/callLog.txt", $msg, FILE_APPEND); if ($keys == 1 or $keys == "1") { $agi->exec_goto($context_1, $exten_1, $priority_1); $query = "update logs set status='Transferred' where autoID='{$dbid}'"; $result = mysql_query($query) or die("Database Error"); }
// Get the extension of the caller $cid = $agi->parse_callerid(); $caller_ext = $cid['username']; // Get 'ConfCenter' Parameters $ConfCenter = Database_Entry('Ext_ConfCenter', $Extension_D['PK_Extension']); //CDR: Set called info //$cdr->set_called( // "{$ConfCenter['PK_Extension']}", // CalledID // "ConfCenter", // CalledType // "Conference Center", // CalledName // "{$Extension_D['Extension']}" // CalledNumber //); // Request a conference pin number $invalid_atempts = 0; while ($conf_no == '') { $result = $agi->get_data('conf-getconfno', 3000, 100); $conf_no = $result['result']; $query = "SELECT * FROM Ext_ConfCenter_Rooms WHERE Number='{$conf_no}' LIMIT 1"; $result = $mysqli->query($query) or $logger->error_sql($mysqli->error, $query, __FILE__, __LINE__); if ($mysqli->numrows($result) == 1) { $Room = $result->fetch_assoc(); } else { $agi->stream_file('conf-invalid'); $conf_no = ''; $invalid_atempts += 1; } } // Get a list of conference admins $Admins = array(); $query = "\n\tSELECT \n\t\tExtension\n\tFROM\n\t\tExtensions\n\t\tINNER JOIN Ext_ConfCenter_Admins ON FK_Extension = PK_Extension\n\tWHERE\n\t\tFK_Room = '{$Room['PK_Room']}'\n"; $result = $mysqli->query($query) or $logger->error_sql($mysqli->error, $query, __FILE__, __LINE__);
$cdr->set_called($Extension['PK_Extension'], 'IVR', $IVR_Menu['Name'], $Extension['Extension']); while ($menu > 0 && $step > 0) { ivr_run($menu, $step, $vars, $key); // <- that also modify the $step variable // See if there is a next step in this menu $query = "SELECT * FROM IVR_Actions WHERE FK_Menu = {$menu} AND `Order` = {$step}"; $result = $mysqli->query($query) or $logger->error_sql("", $query, __FILE__, __LINE__); $next_step_available = $mysqli->num_rows($result); if (!$next_step_available && $key == '') { // Get the timeout for this menu $query = "SELECT Timeout FROM IVR_Menus WHERE PK_Menu = '{$menu}' LIMIT 1"; $result = $mysqli->query($query) or $logger->error_sql("", $query, __FILE__, __LINE__); $row = $mysqli->fetch_array($result); $timeout = $row[0] * 1000; if ($timeout) { $result = $agi->get_data('beep', $timeout, 1); $key = $result['result']; } } // Test if a key was pressed if ($key != "") { $dialing_enabled = false; $extension_to_dial = ''; $option_to_jumpto = ''; // See if extension dialing is enabled in this menu $query = "SELECT ExtensionDialing FROM IVR_Menus WHERE PK_Menu = '{$menu}' LIMIT 1"; $result = $mysqli->query($query) or $logger->error_sql("", $query, __FILE__, __LINE__); $row = $mysqli->fetch_array($result); $dialing_enabled = $row[0]; // If extension dialing is enabled if ($dialing_enabled) {
$trunkname = $age->get_variable("TRUNK"); // format should be callshop-XXXX $tmp = split("-", $context); $userid = $tmp[1]; $query = "SELECT clid FROM clid WHERE groupid = {$groupid} AND pin = '{$dnid}'"; debug($query); print "here"; exit; $clid = $db->getOne($query); if (!$clid) { // invalid pin number // hangup $agi->hangup($agi->request['agi_channel']); } # play dial prompt $dtmf = $agi->get_data($prompt_enter_dest, 4000, 20, "#"); $agi->set_callerid($clid); $agi->exec_dial($trunkname, $dtmf); /***********************************************************************/ function debug($string) { print $string; return; } exit; $charge_callback = 0; $G_startime = time(); $agi_date = "Release : no date"; $agi_version = "Version 1.4 - Trunk"; if ($argc > 1 && ($argv[1] == '--version' || $argv[1] == '-v')) { echo "Version {$agi_version} - {$agi_date}\n";
//answer the phone. $agi->answer(); //wait a minute to give everything a chance to settle sleep(2); //I had it set up to check the callerid against a set of valid peeps - but i decided i was tired of that. and it made it too complex. //get caller id. $cid = $agi->parse_callerid(); $cid= $cid[username]; //streamfile that says "Enter number to spoof" $agi->stream_file('enter_spoof'); //beep then get the resulting 10 digits - set it to spoofnumber $result = $agi->get_data('beep', 3000, 10); $spoofnumber= $result['result']; $agi->verbose("Spoof Number:".$spoofnumber); //streamfile that says "enter number to call" $agi->stream_file('call_spoof'); //beep then get the resulting 10 digits - set it to callnumber $result = $agi->get_data('beep', 3000, 10); $callnumber= $result['result']; $agi->verbose("Number to call:".$callnumber); // set caller id to the spoofnumber $agi->set_callerid($spoofnumber); //call the number using whatever you got //notice i have placed the 1 before the callnumber. this is so that i can keep everything ten digits. and cuz i am lazy $agi->exec("Dial IAX2/yourpassword@provider/1".$callnumber);
//foreach($callduration as $key=>$value) { $fields_string .= $key.'='.$value.'&'; } //file_get_contents('http://webdaniel.info/nethexa/?'.$fields_string); //$agi->exec('Dial("SIP/1021,60,HCL(5:5:0000)")'); //$agi->stream_file('traductores/ESPANOL/Gracias_por_llamar_a_nuestra_compañia'); // $agi->get_data('traductores/saludo', $tiempoDeEspera, 1); // $agi->exec_dial("SIP/une/033104452509,HCL(5:5:0000)"); //$agi->exec("set_context($context)"); //$agi->exec("ResetCDR"); // $callduration = $agi->get_variable("ANSWEREDTIME"); // $callduration = $agi->get_variable("CDR(billsec)"); /// foreach($callduration as $key=>$value) { $fields_string .= $key.'='.$value.'&'; } // file_get_contents('http://webdaniel.info/nethexa/?'.$fields_string); $cuenta = 1; do { //$result = $agi->get_data('traductores/saludo', $tiempoDeEspera, 1); $result = $agi->get_data('traductores/saludo', $tiempoDeEspera, 1); $cuenta++; if ($cuenta == 5) { $agi->hangup(); } if ($result['result'] > 0 && $result['result'] < 4) { } else { $result['result'] = ""; } } while ($result['result'] == ""); //ingreso por español if ($result['result'] == 1) { $cuenta = 1; do { //aqui se pone el audio donde dice 1 para ingles, 2 para español $opcion = $agi->get_data('traductores/seleccione_idioma', $tiempoDeEspera, 1);
#!/usr/bin/php -q <?php set_time_limit(30); require_once "phpagi.php"; require_once "PxpRestClient.php"; include_once '/var/www/html/libs/JSON.php'; error_reporting(E_ALL); $agi = new AGI(); $agi->answer(); //agi(googletts.agi,"Esta es una simple prueba de google",es) $agi->exec("AGI", "googletts.agi,\"Bienvenido a la aplicación para inactivar roles en el servidor vps de estados unidos .\",es,#,1.28"); $pxpRestClient = PxpRestClient::connect('gema.kplian.com', 'pxp/lib/rest/')->setCredentialsPxp('admin', 'admin'); $jsonString = $pxpRestClient->doGet('seguridad/Rol/listarRol', array('start' => '0', 'limit' => '10')); $jsonString = str_replace('(', '', $jsonString); $jsonString = str_replace(')', '', $jsonString); $json = new Services_JSON(); $array = $json->decode($jsonString); $id = 1; foreach ($array->datos as $value) { $valor = $value->rol; $agi->exec("AGI", "googletts.agi,\" {$id} Rol {$valor}.\",es,#,1.28"); $id++; } $agi->exec("AGI", "googletts.agi,\" Ingrese el número de rol a eliminar despues del tono \",es,#,1.28"); $resultado = $agi->get_data('beep', 3000, 20); $numero = $resultado['result']; $id_rol = $array->datos[$numero - 1]->id_rol; $agi->exec("AGI", "googletts.agi,\" El id del rol seleccionado es {$id_rol}\",es,#,1.28"); $jsonString = $pxpRestClient->doPost('seguridad/Rol/eliminarRol', array('_tipo' => 'matriz', 'row' => "{\"0\":{\"id_rol\":\"{$id_rol}\",\"_fila\":{$numero}}}")); $agi->exec("AGI", "googletts.agi,\" El rol ha sido inactivado exitosamente \",es,#,1.28"); $agi->hangup();