forked from SimplesIP/pabx-app
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.1 KiB
54 lines
1.1 KiB
2 years ago
|
#!/usr/bin/php -q
|
||
|
<?php
|
||
|
include('bd.php');
|
||
|
|
||
|
ob_implicit_flush(true);
|
||
|
set_time_limit(6);
|
||
|
$in = fopen("php://stdin", "r");
|
||
|
$stdlog = fopen("/var/log/asterisk/canal_discagem_automatica.log", "w");
|
||
|
|
||
|
// toggle debugging output (more verbose)
|
||
|
$debug = false;
|
||
|
|
||
|
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;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
//parametro vindo do dialplan
|
||
|
$idcliente = $argv[1];
|
||
|
$canal = $agi["channel"];
|
||
|
|
||
|
$query = "insert into pbx_campanha_canais_discando (canal,id_cliente,data) values ('$canal', '$idcliente', 'now()')";
|
||
|
pg_query($query);
|
||
|
|
||
|
// clean up file handlers etc.
|
||
|
fclose($in);
|
||
|
fclose($stdlog);
|
||
|
?>
|