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.
31 lines
1.0 KiB
31 lines
1.0 KiB
#!/usr/bin/php -q |
|
<?php |
|
include("bd.php"); |
|
include("util/util.php"); |
|
$debug = 1; |
|
$TBL_AGENTES = "pbx_supervisor_agentes"; |
|
$path = "/var/log/asterisk/log_erro_pabx.log"; |
|
$p1 = trim($argv[1]); |
|
$p2 = trim($argv[2]); |
|
$log = ''; |
|
$result = null; |
|
try { |
|
if (!$p1 || !$p2) { |
|
GeraExcept("Parametros de entrada invalidos, Arg1:$p1 Arg2: $p2"); |
|
} |
|
|
|
$query = "insert into $TBL_AGENTES (status,matricula,tempo_login,logado, media) values ('$p1','$p2',now(),now(),'99')"; |
|
if (!$result = pg_query($dbcon, $query)) { |
|
RaiseExcept("Erro ao atualizar Base de dados: Cmd:[{$query}]"); |
|
} |
|
|
|
if (!pg_affected_rows($result)) { |
|
RaiseExcept("Cmd insert nao foi efetivado: Cmd:[{$query}]"); |
|
} |
|
|
|
$log .= sprintf("Script: %s Exec: OK Data: %s %s\n", $argv[0], (date("Y-m-d H:m:i") . '.' . microtime(true)), ($debug ? "Cmd: {$query}" : "")); |
|
WriteLog($log, $path); |
|
} catch (Exception $ex) { |
|
$log .= sprintf("Script: %s Data: %s Cmd: %s\n", $argv[0], date("Y-m-d H:m:i") . '.' . microtime(true), $query); |
|
WriteLog($log, $path); |
|
}
|
|
|