Example #1
0
// GET YOUR OWN KEY
include 'PrayTime.php';
error_reporting(0);
$lat = $_GET['lat'];
$long = $_GET['long'];
$units = $_GET['units'];
$tzone = $_GET['tzone'];
if ($lat == '' || $long == '' || $units == '') {
    $lat = "50.72471";
    $long = "-3.50782";
    $units = "c";
    $tzone = 5;
}
$prayTime = new PrayTime();
$prayTime->setCalcMethod($prayTime->Karachi);
$prayTime->setAsrMethod($prayTime->Hanafi);
$times = $prayTime->getPrayerTimes(time(), $lat, $long, $tzone);
$fajr = (int) str_replace(':', '', $times[0]);
$sunrise = (int) str_replace(':', '', $times[1]);
$dhuhur = (int) str_replace(':', '', $times[2]);
$asr = (int) str_replace(':', '', $times[3]);
$sunset = (int) str_replace(':', '', $times[4]);
$maghrib = (int) str_replace(':', '', $times[5]);
$isha = (int) str_replace(':', '', $times[6]);
$prayers = $times;
$flickrResponse = get_data('https://api.flickr.com/services/rest/?method=flickr.places.findByLatLon&format=json&api_key=' . FLICKR_KEY . '&lat=' . $lat . '&lon=' . $long);
$flickrResponse = json_decode(substr($flickrResponse, 14, strlen($flickrResponse) - 15), true);
$woeid = $flickrResponse['places']['place'][0]['woeid'];
$woename = $flickrResponse['places']['place'][0]['woe_name'];
if ($woeid) {
    $xml = simplexml_load_file('http://weather.yahooapis.com/forecastrss?w=' . $woeid . '&u=' . $units);
    {
        return $d * M_PI / 180.0;
    }
    // radian to degree
    function rtd($r)
    {
        return $r * 180.0 / M_PI;
    }
    // range reduce angle in degrees.
    function fixangle($a)
    {
        $a = $a - 360.0 * floor($a / 360.0);
        $a = $a < 0 ? $a + 360.0 : $a;
        return $a;
    }
    // range reduce hours to 0..23
    function fixhour($a)
    {
        $a = $a - 24.0 * floor($a / 24.0);
        $a = $a < 0 ? $a + 24.0 : $a;
        return $a;
    }
}
//---------------------- prayTime Object -----------------------
parse_str(implode('&', array_slice($argv, 1)), $_GET);
$prayTime = new PrayTime($_GET['calc_method']);
// $prayTime->setCalcMethod ($_GET['calc_method']);
$prayTime->setAsrMethod($_GET['asr_method']);
echo implode(",", $prayTime->timeNames);
echo "\n";
echo implode(",", $prayTime->getPrayerTimes(time(), $_GET['lat'], $_GET['lon'], $_GET['tz']));