[Asterisk-Users] AGI and PHP

Luciano Ramos lramos at telviso.com.ar
Thu Jan 8 16:39:39 MST 2004


This is an AGI script we are using, sorry for the spanish:

#!/usr/local/bin/php -q
<?

set_time_limit(0);

milog("INIT", 0);

leer();
$conn=mysql_connect("IP", "USER" , "PASSWORD") or die(milog("ERROR
CONECTANDO CON LA DB"));

milog("Variables leidas $ani ", 0);

$stdin = fopen("php://stdin", 'r');
$stdout = fopen("php://stdout", "w");

milog("atendiendo", 0);
fputs($stdout, "ANSWER\n");
$lin = fgets($stdin);
milog($lin, 0);
milog("atendido", 0);


milog("obteniendo variable", 0);
fputs($stdout, "GET VARIABLE CALLFILENAME\n");
$lin = fgets($stdin);
milog($lin, 0);

list($v1, $v2, $filename)=split(" ", $lin, 3);
$filename=trim($filename);
$filename=ereg_replace('\(', "", $filename);
$filename=ereg_replace('\)', "", $filename);
milog("Valor Obtenido FILENAME=$filename ", 0);


$fechadir="/var/spool/asterisk/monitor/" . substr($filename, 0, 8);

if(!is_dir($fechadir)) mkdir($fechadir);

milog("obteniendo variable DATETIME", 0);
fputs($stdout, "GET VARIABLE FECHA\n");
$lin = fgets($stdin);
milog($lin, 0);
$datetime=$lin;
milog("Valor Obtenido FECHA=$datetime ", 0);

if(substr($ani, 0, 1) == "0")
        $ani=substr($ani, 1);


$sql="INSERT INTO telviso.CallCenter (Ani, FechaReclamo, Solucionado,
WAVGrabacion, astuniqid) ";
$sql.="VALUES ('$ani', NOW(), 0, '$filename', '$uniqid') ";
$q=mysql_query($sql, $conn);

mysql_close($conn);

/********** FIN ****************/
fputs($stdout, "HANGUP\n");
$lin = fgets($stdin);
milog($lin, 0);
/********** FIN ****************/

?>

-----Mensaje original-----
De: asterisk-users-admin at lists.digium.com
[mailto:asterisk-users-admin at lists.digium.com]En nombre de John Skinger
Enviado el: Jueves 8 de Enero del 2004 18:25
Para: asterisk-users at lists.digium.com
Asunto: [Asterisk-Users] AGI and PHP


I'm looking at using php and mysql to store some useful information that i
would normally use dbput and get to retrieve but since the db's need to be
accessed from 2 machines I think agi is the way to go. so what I am looking
for is some examples of some php agi scripts. I've seen the sample, but I
would be appreciative if anyone could show me some more examples.
thanks
john



_______________________________________________
Asterisk-Users mailing list
Asterisk-Users at lists.digium.com
http://lists.digium.com/mailman/listinfo/asterisk-users
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users




More information about the asterisk-users mailing list