<html>
<head>
<style>
P
{
margin:0px;
padding:0px
}
body
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body><div style="text-align: left;">Hello,<br>I am new to asterisk but i have vbeen scriptinh PHP SQL and webLanguages for a long time.<br>I can Give you a solution but using php AGI:<br>extensions.con-----> AGI(connect.agi);<br><br>/var/lib/asterisk/agi-bin/connect.agi :<br>#!/usr/bin/php -q<br><br><?php<br>set_time_limit(0);<br>ob_implicit_flush();<br>error_reporting(0);<br>//Initialisation des entrée-sortie<br>function init() {<br>#create file handles if needed<br>if(!defined('STDIN'))<br>{<br> define('STDIN',fopen('php://stdin','r'));<br>}<br>if(!defined('STDOUT'))<br>{<br> define('STDOUT',fopen('php://stdout','w'));<br>}<br>if(!defined('STDERR'))<br>{<br> define('STDERR',fopen('php://stderr','w'));<br>}<br>#retrieve all AGI variables from Asterisk<br>while(!feof(STDIN))<br>{<br> $temp=trim(fgets(STDIN,4096));<br> if(($temp=="")||($temp=="\n"))<br> {<br> break;<br> }<br> $s=split(":",$temp);<br> $name=str_replace("agi_","",$s[0]);<br> $agi[$name]=trim($s[1]);<br>}<br>return $agi;<br>}<br></div><br>function checkresult($res)<br>{<br> trim($res);<br> if(preg_match('/^200/',$res))<br> {<br> if(!preg_match('/result=(-?\d+)/',$res,$matches))<br> {<br> fwrite(STDERR,"FAIL ($res)\n");<br> fflush(STDERR);<br> return0;<br> } else {<br> fwrite(STDERR,"PASS (".$matches[1].")\n");<br> fflush(STDERR);<br> return $matches[1];<br> }<br> } else {<br> fwrite(STDERR,"FAIL (unexpected result '$res')\n");<br> fflush(STDERR);<br> return -1;<br> }<br>}<br><br>$agivar = init();<br>$hostname= 'xxxx';
<br>$database= 'xxxxx';
<br>$username= 'xxxxx';
<br>$password= 'xxxx';
<br>$dbprotect = mysql_pconnect($hostname, $username, $password) or trigger_error(mysql_error(),E_USER_ERROR);
<br>mysql_select_db($database, $dbprotect);<br>$result = mysql_query("SELECT * FROM user_table WHERE user_age>12");<br>while($entry = mysql_fetch_array($result)) {<br>fwrite(STERR, "Name : $entry['name'], Age: $entry['age'] \n");<br>fflush(STDOUT);<br>$result = trim(fgets(STDIN,4096));<br>checkresult($result);<br>}<br>?><br><br>It will return things on the asterisk CLI.... You can adapt this example for you<br>I don't know if it help but it shows a way to do...<br><br>Kheraud<br><hr id="stopSpelling">> From: jp@speakplease.com<br>> To: asterisk-users@lists.digium.com<br>> Date: Fri, 24 Aug 2007 12:56:55 +0300<br>> Subject: [asterisk-users] MYSQL problem and configuration<br>> <br>> Greetings everyone<br>> <br>> I've set up a call recording system on debian 4.0 with asterisk and mysql db<br>> for handling user information (accessible over the net for users). My<br>> asterisk is running on one machine and the mysql on another. The connection<br>> is over lan. Now I have a problem and a question.<br>> <br>> My problem is:<br>> When mysql_real_connect doesn't get connection to the mysql server asterisk<br>> pretty much freezes and doesn't let any info go in or out, even the CLI<br>> freezes. I've seen a bug report on this but no solution(?)<br>> Although this might be a bug with asterisk when I have the connection set to<br>> a hosted mysql server (company that hosts our website during the testing<br>> period) the connection works fine so I've come to conclusion that the<br>> problem might be the mysql and/or debian configuration I have. SO...<br>> <br>> My question is:<br>> How should I configure mysql (and debian box) for asterisk connections?<br>> <br>> Best regards<br>> Jari-Pekka Lehtinen<br>> <br>> <br>> _______________________________________________<br>> --Bandwidth and Colocation Provided by http://www.api-digital.com--<br>> <br>> asterisk-users mailing list<br>> To UNSUBSCRIBE or update options visit:<br>> http://lists.digium.com/mailman/listinfo/asterisk-users<br><br /><hr />Besoin d'un e-mail ? Créez gratuitement un compte Windows Live Hotmail et importez tous vos contacts Outlook en quelques clics ! <a href='http://www.windowslive.fr/hotmail/default.asp' target='_new'>Windows Live Hotmail</a></body>
</html>