All pastes #1968 Raw Copy code Copy link Edit

agi error

public php v1 · immutable
#1968 ·published 2004-11-08 13:32 UTC
rendered paste body
#!/usr/bin/php -q  <?php  ob_implicit_flush(true);  set_time_limit(6);  error_reporting(0);  //added by user: democritus  $in = fopen("php://stdin","r");  $stdlog = fopen("/var/log/asterisk/my_agi.log", "w");  // toggle debugging output (more verbose)  $debug = true;  // Do function definitions before we start the main loop  function read() {    global $in, $debug, $stdlog;    $input = str_replace("\n", "", fgets($in, 4096));    if ($debug) fputs($stdlog, "read: $input\n");    return $input;  }  function errlog($line) {    global $err;    echo "VERBOSE \"$line\"\n";  }  function write($line) {    global $debug, $stdlog;    if ($debug) fputs($stdlog, "write: $line\n");    echo $line."\n";  }  // parse agi headers into array  while ($env=read()) {    $s = split(": ",$env);    $agi[str_replace("agi_","",$s[0])] = trim($s[1]);    if (($env == "") || ($env == "\n")) {      break;    }  }  write("SAY DIGITS $agi[callerid] X"); // X is the escape digit. since X is not DTMF, no exit is possible  read();   // clean up file handlers etc.  fclose($in);  fclose($stdlog);  exit;  ?>