Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 74 lines (66 sloc) 2.024 kB
f0dca68 @ahmedre forgot to check in some files
ahmedre authored
1 <?php
a44a80c @ahmedre critical bugfix causing locations with special characters in their na…
ahmedre authored
2 header('Content-type: text/html; charset=utf-8');
d436d03 @ahmedre fix rss under safari, more mvc related cleanups
ahmedre authored
3 if (isset($_GET['about'])){
4 include 'views/about.inc';
5 return;
6 }
7
f0dca68 @ahmedre forgot to check in some files
ahmedre authored
8 // $_GET['ajax'] should be set by the javascript in an ajax call.
9 $ajax = isset($ajax)? true : (isset($_GET['ajax'])? true : false);
408c35e @ahmedre added initial json output
ahmedre authored
10 $format = (isset($_GET['rss'])? 'rss' :
11 (isset($_GET['json'])? 'json' : 'html'));
f0dca68 @ahmedre forgot to check in some files
ahmedre authored
12
13 $q = "";
14 $data = null;
15 if (isset($_GET['q'])){
16 include 'prayertimes.inc';
f00acf4 @ahmedre added ff3.5 geolocation support
ahmedre authored
17 $q = $_GET['q'];
18 if (strlen($q) > 0){
a35e40e @ahmedre gmt related bugfixes. method now exposed via method parameter (1-7).…
ahmedre authored
19 $method = 4;
20 if (isset($_GET['method'])){
21 $meth = $_GET['method'];
22 if ((is_numeric($meth)) && ($meth > 0) && ($meth < 8))
23 $method = $meth;
24 }
25 $data = PrayerTimes::getPrayerTimes($q, $method);
67a2035 @ahmedre checkin to do a little bit of fail safety testing for geoname api
ahmedre authored
26 if ($data['type']=='error'){
27 print $data['msg'];
28 $data = null;
29 }
f00acf4 @ahmedre added ff3.5 geolocation support
ahmedre authored
30 }
f0dca68 @ahmedre forgot to check in some files
ahmedre authored
31 }
32
33 if (!is_null($data)){
34 if ($data['type']=='search_results'){
35 $search_results = $data['data'];
36 if ($ajax) include 'views/locsearch.inc';
37 else include 'views/main.inc';
ea96f5f @ahmedre added a please wait while calculating, and some small fixes to the re…
ahmedre authored
38 }
a17ae0d @ahmedre new ui thanks to @somaiagabr. expose method in ui.
ahmedre authored
39 else showSalatTimes($data['location'], $data['data'],
40 $format, $method, $ajax);
f0dca68 @ahmedre forgot to check in some files
ahmedre authored
41 return;
42 }
43 else if ($ajax) return;
44 else include 'views/main.inc';
45
a17ae0d @ahmedre new ui thanks to @somaiagabr. expose method in ui.
ahmedre authored
46 function showSalatTimes($location, $pt, $format, $method, $ajax = true){
f0dca68 @ahmedre forgot to check in some files
ahmedre authored
47 global $q; // don't like this, but...
48
49 $data = array();
50 $times = array(0 => "Fajr", 1 => "Shurooq", 2 => "Dhuhr",
51 3 => "'Asr", 4 => "Maghrib", 5 => "'Isha");
52 foreach ($times as $key => $val){
53 $min = $pt[$key]['minute'];
54 $hour = $pt[$key]['hour'];
55 $time_of_day = 'am';
56 if ($hour >= 12) {
57 $time_of_day = 'pm';
58 if ($hour > 12) $hour -= 12;
ea96f5f @ahmedre added a please wait while calculating, and some small fixes to the re…
ahmedre authored
59 }
f0dca68 @ahmedre forgot to check in some files
ahmedre authored
60
61 if ($min < 10) $min = "0$min";
62 $time = $hour . ":" . $min . " $time_of_day";
63 $data[$val] = $time;
7fc2851 @ahmedre added waqt.org code to github
ahmedre authored
64 }
65
f0dca68 @ahmedre forgot to check in some files
ahmedre authored
66 if ($format == 'rss')
67 include 'views/salatrss.inc';
408c35e @ahmedre added initial json output
ahmedre authored
68 else if ($format == 'json')
69 include 'views/salatjson.inc';
f0dca68 @ahmedre forgot to check in some files
ahmedre authored
70 else if (!$ajax) include 'views/main.inc';
71 else include 'views/salatimes.inc';
72 }
67a2035 @ahmedre checkin to do a little bit of fail safety testing for geoname api
ahmedre authored
73 ?>
Something went wrong with that request. Please try again.