|
|
|
#!/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/confirma_senha.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 = explode(": ", $env);
|
|
|
|
$agi[str_replace("agi_", "", $s[0])] = trim($s[1]);
|
|
|
|
if (($env == "") || ($env == "\n")) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
write("GET VARIABLE CONTA");
|
|
|
|
$CONTA2 = substr(strrchr(read(), "("), 1, -1);
|
|
|
|
|
|
|
|
$query = "select senha from pbx_cs_usuarios where matricula = '$CONTA2' and tag <> '2'";
|
|
|
|
$query_result = pg_query($query);
|
|
|
|
$result = pg_fetch_array($query_result);
|
|
|
|
|
|
|
|
$SENHA_DB = $result['senha'];
|
|
|
|
|
|
|
|
if ($SENHA_DB != "") {
|
|
|
|
write("SET VARIABLE ATUAL_DB $SENHA_DB");
|
|
|
|
read();
|
|
|
|
}
|
|
|
|
|
|
|
|
// clean up file handlers etc.
|
|
|
|
fclose($in);
|
|
|
|
fclose($stdlog);
|
|
|
|
?>
|