#!/usr/local/bin/php -q <?php set_time_limit(30); require('phpagi.php'); // die("Syntax ok\n"); // line A: uncomment for syntax test $agi = new AGI(); $agi->answer(); $agi->text2wav("Script begins"); $numlen = 3; $prompt = 'Enter the eye aye ecks number you wish me to cawl.'; $agi->text2wav($prompt); $result = $agi->get_data("beep",10000,$numlen); $num = $result['result']; $agi->text2wav('You have requested an eye aye ecks cawl to '); $agi->say_digits($num); $agi->text2wav('Press 1 to confirm or any other number to cancel'); $result = $agi->get_data("beep",10000,1); $conf = $result['result']; $agi->text2wav("User selected $conf"); if ($conf == 1) { $mess = phon_out("IAX2/",$num); $agi->text2wav($mess); } else { $agi->text2wav('User cancelled'); } $agi->text2wav("Script ends"); $agi->hangup(); // end of main. Begin functions section function phon_out($atyp,$phn) { $mess = "Channel: $atyp$phn CallerID: Callback service<00> MaxRetries: 1 RetryTime: 60 WaitTime: 30 Context: default Extension: 51 Priority: 1 "; $astfil = "test$phn.call"; $callfil = "/var/spool/asterisk/outcalls/$astfil"; $destfil = "/var/spool/asterisk/outgoing/$astfil"; if (!file_exists($destfil)) { if (file_put_contents($callfil,$mess)) { touch($callfil,time()); if (rename($callfil,$destfil)) { $msg .= "Success. Cawl queued"; } else { $msg .= "Error. Cawl file rename failed"; } } else { $msg .= "Error. Cannot write file"; } } else { $msg .= "Error. Cawl file already exists"; } return $msg; } ?>