-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7fc2851
Showing
10 changed files
with
421 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# In the name of Allah, Most Gracious, Most Merciful | ||
__ | ||
_ _____ ____ _/ /_ | ||
| |/|/ / _ `/ _ `/ __/ | ||
|__,__/\_,_/\_, /\__/ | ||
/_/ a muslim prayertimes calculator (http://waqt.org) | ||
|
||
this is the sourcecode to waqt.org, a muslim prayertimes calculation website. it relies on open source tools and apis to do it's calculations. | ||
|
||
dependencies: | ||
- itl php extension - http://svn.arabeyes.org/viewvc/projects/itl/ports/php/ | ||
- yahoo geocoding api - http://developer.yahoo.com/maps/rest/V1/geocode.html | ||
- geonames api - http://www.geonames.org/ | ||
|
||
requirements: | ||
- setup and install libitl, which can be found at arabeyes.org or on sourceforge https://sourceforge.net/projects/arabeyes/files/ITL itools/. | ||
- setup and install the php extension (phpize, configure, make, make install). | ||
- make a settings.inc file. the contents of this file should be: | ||
<?php | ||
$appid = ''; // put your yahoo app id here | ||
|
||
i am providing this code to help those muslims who want to put prayertimes on their websites. the source code is currently not very clean because it was quickly hacked together from an older version of the code that didn't rely on apis. the hope is that i will clean it up as i get some time insha'Allah :) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<head> | ||
<title>waqt.org - muslim prayertimes</title> | ||
<link rel="stylesheet" type="text/css" href="style.css"> | ||
</head> | ||
|
||
<div class="toplinks"> | ||
About | <a href="http://github.com/ahmedre/waqt.org">Github</a> | ||
</div> | ||
|
||
<center> | ||
<a href="index.php"><img src="imgs/waqt.png" border="0"></a><br> | ||
based on the <a href="http://www.arabeyes.org">arabeyes</a> <a href="http://www.arabeyes.org/project.php?proj=ITL">itl library</a>. the prayer times are calculated using the <a href="http://svn.arabeyes.org/viewvc/projects/itl/ports/php/">itl php extension</a>. | ||
<br> | ||
logo made using the <a href="http://creatr.cc/creatr">web2.0 logo creatr</a>. | ||
<hr> | ||
If you have any questions, comments, or suggestions, please feel free to email us at: <a href='mailto:mus%6Cimadmi%6E@gmail.com'>muslimadmin@gmail.com</a> | ||
</center> | ||
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
<?php | ||
include 'settings.inc'; | ||
$url = "http://local.yahooapis.com/MapsService/V1/geocode" . | ||
"?appid=$appid&location="; | ||
$q = urlencode($_GET['q']); | ||
$format = isset($_GET['rss'])? 1 : 0; | ||
|
||
$baseurl = "http://waqt.org"; | ||
$url = $url . $q . "&output=php"; | ||
|
||
if (strlen($q) == 0) return; | ||
$ch = curl_init(); | ||
curl_setopt($ch, CURLOPT_URL, $url); | ||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | ||
$res = curl_exec($ch); | ||
curl_close($ch); | ||
$locations = unserialize($res); | ||
|
||
if (isset($locations['ResultSet']['Result'][1])) | ||
return showSearchResults($locations['ResultSet']['Result']); | ||
|
||
$res = $locations['ResultSet']['Result']; | ||
$lat = $res['Latitude']; | ||
$long = $res['Longitude']; | ||
$addr = calc_addr($res); | ||
|
||
$url = "http://ws.geonames.org/timezoneJSON?lat=$lat&lng=$long"; | ||
$ch = curl_init(); | ||
curl_setopt($ch, CURLOPT_URL, $url); | ||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | ||
$res = curl_exec($ch); | ||
curl_close($ch); | ||
$tz_data = json_decode($res, true); | ||
$gmt_offset = $tz_data['gmtOffset']; | ||
$dst_offset = $tz_data['dstOffset']; | ||
$dst = ($gmt_offset != $dst_offset); | ||
|
||
/* methods | ||
|| 1 || Egyptian General Authority of Survey || | ||
|| 2 || University of Islamic Sciences, Karachi (Shaf'i) || | ||
|| 3 || University of Islamic Sciences, Karachi (Hanafi) || | ||
|| 4 || Islamic Society of North America || | ||
|| 5 || Muslim World League (MWL) || | ||
|| 6 || Umm Al-Qurra (Saudi Arabia || | ||
|| 7 || Fixed Isha Interval (always 90) || | ||
*/ | ||
$method = 4; | ||
$prayers = itl_get_prayer_times($long, $lat, $gmt_offset, $method, | ||
date('j'), date('n'), date('Y'), $dst); | ||
|
||
return showSalatTimes($addr, $prayers); | ||
|
||
function calc_addr($res){ | ||
$city = $res['City']; | ||
$state = $res['State']; | ||
$zip = $res['Zip']; | ||
$country = $res['Country']; | ||
|
||
$loc = ''; | ||
if (!empty($city)) $loc = $city; | ||
if (!empty($state)) $loc .= (empty($loc)? $state : ", $state"); | ||
if (!empty($zip)) $loc .= (empty($loc)? $zip : " $zip"); | ||
return $loc; | ||
} | ||
|
||
function showSalatTimes($location, $pt){ | ||
global $format; | ||
$result = array(); | ||
$times = array(0 => "Fajr", 1 => "Shurooq", 2 => "Dhuhr", | ||
3 => "3asr", 4 => "Maghrib", 5 => "3isha"); | ||
foreach ($times as $key => $val){ | ||
$min = $pt[$key]['minute']; | ||
$hour = $pt[$key]['hour']; | ||
$time_of_day = 'am'; | ||
if ($hour >= 12) { | ||
$time_of_day = 'pm'; | ||
if ($hour > 12) $hour -= 12; | ||
} | ||
|
||
if ($min < 10) $min = "0$min"; | ||
$time = $hour . ":" . $min . " $time_of_day"; | ||
$result[$val] = $time; | ||
} | ||
|
||
if ($format == 1) | ||
showRssSalatTimes($location, $result); | ||
else showHtmlSalatTimes($location, $result); | ||
|
||
} | ||
|
||
function showHtmlSalatTimes($location, $data){ | ||
global $baseurl; | ||
$param = "q=$location"; | ||
|
||
print <<<SALATHTML_HEADER | ||
<span class="times-header">Prayer times for: $location | ||
<a href="$baseurl/calculate.php?$param&rss"> | ||
<img src="imgs/feedicon.png"></a> | ||
</span><br> | ||
SALATHTML_HEADER; | ||
|
||
foreach ($data as $val => $time){ | ||
print "<span class=\"salat-name\">$val: </span> " . | ||
"<span class=\"salat-time\">$time</span><br>\n"; | ||
} | ||
} | ||
|
||
function showRssSalatTimes($location, $data){ | ||
global $baseurl; | ||
header("Content-Type: text/xml"); | ||
print <<<RSSHEADER | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<rss version="2.0" | ||
xmlns:content="http://purl.org/rss/1.0/modules/content/" | ||
xmlns:wfw="http://wellformedweb.org/CommentAPI/" | ||
xmlns:dc="http://purl.org/dc/elements/1.1/" | ||
> | ||
<channel> | ||
<title>PrayerTimes for $location</title> | ||
<link>$baseurl</link> | ||
<description>prayertime feeds for the whole world, provided | ||
by waqt.org</description> | ||
<language>en-us</language> | ||
RSSHEADER; | ||
|
||
$i=0; | ||
foreach ($data as $val => $time){ | ||
$i++; | ||
print <<<RSSDATA | ||
<item> | ||
<guid isPermaLink="false">$baseurl/$i</guid> | ||
<title>$val</title> | ||
<description>$time</description> | ||
</item> | ||
RSSDATA; | ||
} | ||
print "</channel></rss>"; | ||
} | ||
|
||
function showSearchResults($results){ | ||
global $format; | ||
if ($format == 0) | ||
showSearchResultsHtml($results); | ||
} | ||
|
||
function showSearchResultsHtml($results){ | ||
print "<span class=\"search-header\">multiple locations " . | ||
"matched your query...</span><br>\n"; | ||
foreach ($results as $r){ | ||
$addr = calc_addr($r); | ||
print "<span class=\"search-result\"><a href=\"javascript" . | ||
":manualLocation('" . $addr . "');\">" . $addr . "</a>" . | ||
"</span><br>\n"; | ||
} | ||
} | ||
|
||
?> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<head> | ||
<title>waqt.org - muslim prayertimes</title> | ||
|
||
<script type="text/javascript" src="prototype.lite.js"></script> | ||
<script type="text/javascript" src="moo.ajax.js"></script> | ||
<link rel="stylesheet" type="text/css" href="style.css"> | ||
</head> | ||
|
||
<script type="text/javascript"> | ||
<!-- | ||
function handleSubmit(){ | ||
var input = document.ptform.location.value; | ||
if (input.length==0) return false; | ||
new ajax('calculate.php?q=' + input, | ||
{ update: $('prayertimes'), method: 'get' }); | ||
} | ||
function manualLocation(loc){ | ||
document.ptform.location.value = loc; | ||
handleSubmit(); | ||
} | ||
--> | ||
</script> | ||
|
||
<body onload="javascript:$('location').focus();"> | ||
|
||
<div class="toplinks"> | ||
<a href="about.php">About</a> | <a href="http://github.com/ahmedre/waqt.org">Github</a> | ||
</div> | ||
|
||
<center> | ||
<img src="imgs/waqt.png"> | ||
<div id="all"> | ||
<form name="ptform" action="javascript:void(0);" | ||
onsubmit="javascript:handleSubmit();"> | ||
<input type="text" id="location"> | ||
</form> | ||
<div id="prayertimes"></div> | ||
</div> | ||
</center> | ||
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
//based on prototype's ajax class | ||
//to be used with prototype.lite, moofx.mad4milk.net. | ||
|
||
ajax = Class.create(); | ||
ajax.prototype = { | ||
initialize: function(url, options){ | ||
this.transport = this.getTransport(); | ||
this.postBody = options.postBody || ''; | ||
this.method = options.method || 'post'; | ||
this.onComplete = options.onComplete || null; | ||
this.update = $(options.update) || null; | ||
this.request(url); | ||
}, | ||
|
||
request: function(url){ | ||
this.transport.open(this.method, url, true); | ||
this.transport.onreadystatechange = this.onStateChange.bind(this); | ||
if (this.method == 'post') { | ||
this.transport.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); | ||
if (this.transport.overrideMimeType) this.transport.setRequestHeader('Connection', 'close'); | ||
} | ||
this.transport.send(this.postBody); | ||
}, | ||
|
||
onStateChange: function(){ | ||
if (this.transport.readyState == 4 && this.transport.status == 200) { | ||
if (this.onComplete) | ||
setTimeout(function(){this.onComplete(this.transport);}.bind(this), 10); | ||
if (this.update) | ||
setTimeout(function(){this.update.innerHTML = this.transport.responseText;}.bind(this), 10); | ||
this.transport.onreadystatechange = function(){}; | ||
} | ||
}, | ||
|
||
getTransport: function() { | ||
if (window.ActiveXObject) return new ActiveXObject('Microsoft.XMLHTTP'); | ||
else if (window.XMLHttpRequest) return new XMLHttpRequest(); | ||
else return false; | ||
} | ||
}; |
Oops, something went wrong.