For testing I called the php from from from-internal-custom
[from-internal-custom]
exten => 311,1,Wait(1)
exten => 311,n,AGI(PrayerTime.php)
Code from here------------------------------------------------------------
#!/usr/bin/php -q
set_time_limit(30);
require('/var/lib/asterisk/agi-bin/phpagi.php');
error_reporting(E_ALL);
$agi = new AGI();
$agi->answer();
// get todays date in array format and printing the resulting array
$today = getdate();
// this is for testing to specify a date
//$today = getdate(mktime(0,0,0,10,30,2008));
$agi->verbose($today);
// open database
if (!$link = mysql_connect('localhost', 'user', 'password')) {
$agi->verbose('Could not connect to mysql');
exit;
}
if (!mysql_select_db('MyTest', $link)) {
$agi->verbose('Could not select database');
exit;
}
// query table for todays date
$sql = "SELECT Fajr,Maghrb,Dhahr FROM TestTable WHERE Day =
{$today['mday']} AND Month = {$today['mon']}";
$result = mysql_query($sql, $link);
if (!$result) {
$agi->verbose("DB Error, could not query the database\n");
$agi->verbose('MySQL Error: ' . mysql_error());
exit;
}
// get todays prayer row
while ($row = mysql_fetch_assoc($result)) {
$agi->verbose($row['Fajr']);
$agi->verbose($row['Dhahr']);
$agi->verbose($row['Maghrb']);
$Fajr=$row['Fajr'];
$Dhahr=$row['Dhahr'];
$Maghrb=$row['Maghrb'];
}
mysql_free_result($result);
mysql_close($link);
// Say todays date
$outtext = "Prayyar time for today {$today['weekday']} the
{$today['mday']} {$today['month']} {$today['year']}";
$agi->text2wav($outtext);
// Say todays Fajr Prayer Time
$outtext = "Fajeer prayer is at";
$agi->text2wav($outtext);
$t = mktime (intval(Substr($Fajr,0,2)),intval(Substr($Fajr,3,2)));
$agi->verbose($t);
$agi->say_time ($t);
// Say todays Dhahr Prayer Time
$outtext = "Zohar prayer is at";
$agi->text2wav($outtext);
$t = mktime (intval(Substr($Dhahr,0,2)),intval(Substr($Dhahr,3,2)));
$agi->verbose($t);
$agi->say_time ($t);
// Say todays Dhahr Prayer Time
$outtext = "Magaarrab prayer is at";
$agi->text2wav($outtext);
$t = mktime (intval(Substr($Maghrb,0,2))+12,intval(Substr($Maghrb,3,2)));
$agi->verbose($t);
$agi->say_time ($t);
$agi->text2wav('Goodbye');
$agi->hangup();
?>
Subscribe to:
Post Comments (Atom)
there is something wrong with php code where you open < ? the php code ??!!!
ReplyDelete