Plugin Directory

Changeset 808856


Ignore:
Timestamp:
11/22/2013 01:41:55 PM (12 years ago)
Author:
adatosystems
Message:

1.1 update

Location:
daily-zman-widget
Files:
4 added
1 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • daily-zman-widget/trunk/readme.txt

    r787938 r808856  
    44Tags: Prayer Times, Davening times, davening, Zman, zmanim
    55Requires at least: 3.3
    6 Tested up to: 3.6
    7 Stable tag: 1.0
     6Tested up to: 3.7.1
     7Stable tag: 1.1
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    7676
    7777== Changelog ==
     78
    7879= 1.0 =
    7980* Initial Release
     81
     82= 1.1 =
     83* Really just matched this to the way things are done in the Shabbat Zman widget
     84* Added options for Latitude/Longitude for those locations where the postal code doesn't work.
     85* If using Lat/Long, returns location name in that location's language (if possible)
     86* Using sunrise/sunset (instead of calculating it within the code) because of mis-matches in DST (daylight savings time) calculations.
     87* changed from using Google Maps API to GeoNames.org for lat/long and timezone data due to overload of Google's 2500 hit per day per IP, which was blocking sites hosted by NetworkSolutions and other larger providers.
     88* Changed URL calls to use a more secure cURL routine
     89* Added additional debugging for php version, plus an alternate method of determining Friday's date
    8090
    8191
  • daily-zman-widget/trunk/zmandaily.php

    r787938 r808856  
    66 *   Uses the inimitable Hebcal.com site for parsha and other information,
    77 *   as well as Google Maps API for geographic and sunrise/sunset information.
    8  * Version: 1.0
     8 * Version: 1.1
    99 * Author: Leon Adato
    1010 * Author URI: http://www.adatosystems.com/
     
    1212 * ***********************************
    1313 * 2013- - initial creation
     14 * 2013-11-22 - matched to updates in Shabbat Zman widget
    1415 *
    1516 *
     
    6768        $yom = strtotime("now");
    6869        $yom_txt = date("M d, Y", $yom);
     70        $yom_ymd = date("Y-m-d", $yom);
    6971
    7072        // Get Hebrew Date from HebCal
     
    8082        }
    8183
    82                 /* JSON get lat/long from zip using maps.googleapis.com */
    83         $du = file_get_contents("http://maps.googleapis.com/maps/api/geocode/json?address=".$instance['zip']."&sensor=false");
    84         $djd = json_decode(utf8_encode($du),true);
    85         $long = $djd['results'][0]['geometry']['location']['lng'];
    86         $lat = $djd['results'][0]['geometry']['location']['lat'];
    87         $address = $djd['results'][0]['formatted_address'];
    88 
    89         /* Get time offset for timzezone and DST using  maps.googleapis.com */
    90         $tz = file_get_contents("https://maps.googleapis.com/maps/api/timezone/json?location=".$lat.",".$long."&timestamp=".$yom."&sensor=false");
     84        /* JSON get lat/long from zip */
     85        if(!$instance['userlat']) {
     86            $latlongurl = "http://api.geonames.org/postalCodeLookupJSON?formatted=true&postalcode=".$instance['zip']."&country=US&date=".$yom."&username=adatosystems&style=full";
     87            $ch = curl_init();
     88                curl_setopt($ch, CURLOPT_URL, $latlongurl);
     89                curl_setopt($ch, CURLOPT_HEADER, false);
     90                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     91                $du = curl_exec($ch);
     92                curl_close($ch);
     93            $djd = json_decode(utf8_encode($du),true);
     94            $long = $djd['postalcodes'][0]['lng'];
     95            $lat = $djd['postalcodes'][0]['lat'];
     96            $city = $djd['postalcodes'][0]['placeName'];
     97            $state = $djd['postalcodes'][0]['adminCode1'];
     98            $country = $djd['postalcodes'][0]['countryCode'];
     99            $address = "$city, $state $country";
     100        } else {
     101        $lat = $instance['userlat'];
     102        $long = $instance['userlong'];
     103        $latlongurl = "http://open.mapquestapi.com/nominatim/v1/reverse.php?format=json&lat=".$lat."&lon=".$long;
     104        $ch = curl_init();
     105                curl_setopt($ch, CURLOPT_URL, $latlongurl);
     106                curl_setopt($ch, CURLOPT_HEADER, false);
     107                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     108                $du = curl_exec($ch);
     109                curl_close($ch);
     110            $djd = json_decode(utf8_encode($du),true);
     111            $city = $djd['address']['city'];
     112            $state = $djd['address']['state'];
     113            $country = $djd['address']['country_code'];
     114            $address = "$city, $state $country";
     115        }
     116
     117        /* Get time offset for timzezone and DST */
     118        $tzurl = "http://api.geonames.org/timezoneJSON?lat=".$lat."&lng=".$long."&date=".$yom_ymd."&username=adatosystems";
     119        $ch = curl_init();
     120            curl_setopt($ch, CURLOPT_URL, $tzurl);
     121            curl_setopt($ch, CURLOPT_HEADER, false);
     122            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     123            $tz = curl_exec($ch);
     124            curl_close($ch);
    91125        $tzjd = json_decode(utf8_encode($tz),true);
    92         $tzoffset = $tzjd['rawOffset'];
    93         $dstoffset = $tzjd['dstOffset'];
    94         $offset = $dstoffset+$tzoffset;
    95         $tzname = $tzjd['timeZoneName'];
    96 
    97         /* calculate sunrise and suset time */
    98         $suninfo = date_sun_info($yom, $lat, $long);
    99         $sunrise = date($timedisplay, $suninfo['sunrise']+$offset);
    100         $sunset = date($timedisplay, $suninfo['sunset']+$offset);
     126        $tzname = $tzjd['timezoneId'];
     127        $yomsunrise = $tzjd['dates'][0]['sunrise'];
     128        $yomsunset = $tzjd['dates'][0]['sunset'];
     129        $yomsunrisedatetime = strtotime($yomsunrise);
     130        $yomsunsetdatetime = strtotime($yomsunset);
     131        $sunrisesec = $yomsunrisedatetime+$offset;
     132        $sunsetsec = $yomsunsetdatetime+$offset;
    101133
    102134        // Calculate Plag haMincha
    103135        if($instance['showplag']) {
    104             $sunrisesec = $suninfo['sunrise']+$offset;
    105             $sunsetsec = $suninfo['sunset']+$offset;
    106136            if($instance['plagmethod'] == "gra") {
    107137                $halachichour = ($sunsetsec - $sunrisesec)/12;
     
    121151        // Calculate Shema
    122152        if($instance['showshema']) {
    123             $sunrisesec = $suninfo['sunrise']+$offset;
    124             $sunsetsec = $suninfo['sunset']+$offset;
    125153            if($instance['shemamethod'] == "gra") {
    126154                $halachichour = ($sunsetsec - $sunrisesec)/12;
     
    140168        // Calculate Earliest Mincha
    141169        if($instance['showmincha']) {
    142             $sunrisesec = $suninfo['sunrise']+$offset;
    143             $sunsetsec = $suninfo['sunset']+$offset;
    144170            if($instance['shemamethod'] == "gra") {
    145171                $halachichour = ($sunsetsec - $sunrisesec)/12;
     
    164190        if($instance['showlocation'] ) {echo $address.'<br />'; }
    165191        if($instance['hebdatetxt']) {echo $hebrewdate.'<br />';}
    166         if($instance['showsunrise'] ) {echo '<span id="zmantitle">Sunrise: </span>'.$sunrise.'<br /> ';}
     192        if($instance['showsunrise'] ) {echo '<span id="zmantitle">Sunrise: </span>'.date($timedisplay,$yomsunrisedatetime).'<br />';}
    167193        if($instance['showshema'] ) {echo $shematext.'<br />'; }
    168194        if($instance['showmincha'] ) {echo $minchatext.'<br />'; }
    169195        if($instance['showplag'] ) {echo $plagtext.'<br />'; }
    170         if($instance['showsunset'] ) {echo '<span id="zmantitle">Sunset: </span>'.$sunset.'<br />';}
     196        if($instance['showsunset'] ) {echo '<span id="zmantitle">Sunset: </span>'.date($timedisplay,$yomsunsetdatetime).'<br />';}
    171197        if($instance['love'] ) {echo $lovetext.'<br />'; }
    172198
    173199        if($instance['debug'] ) {
    174200            echo 'Current PHP version: ' . phpversion().'<br />';
     201            echo 'Latlong URL is '.$latlongurl.'<br />';
    175202            echo 'Lat and Long is: '.$lat.' and '.$long.'<br />';
    176             echo 'Time zone is '.$tzname.', tzoffset is '.$tzoffset.', dstoffset is '.$dstoffset.' and offset is '.$offset.'<br />';
     203            echo 'Timzezone URL is '.$tzurl.'<br />';
     204            echo 'Time zone is '.$tzname.'<br />';
    177205            echo 'Date timestamp: '.$yom.' and Date text is '.$yom_txt.' <br />';
    178             echo 'Sunset: '.$sunset.' <br />';
     206            echo 'Sunset: '.$yomsunsetdatetime.' <br />';
    179207            echo 'Hebcal jewish date URL: '.$hebcaljd['link'].'<br />';
    180208            echo 'Weekday number: '.date('N').'<br />';
     
    193221        $instance['title'] = strip_tags($new_instance['title']);
    194222        $instance['zip'] = strip_tags($new_instance['zip']);
     223        $instance['userlat'] = strip_tags($new_instance['userlat']);
     224        $instance['userlong'] = strip_tags($new_instance['userlong']);
    195225        $instance['ashki'] = $new_instance['ashki'];
    196226        $instance['showlocation'] = $new_instance['showlocation'];
     
    232262        <label for="<?php echo $this->get_field_id('zip'); ?>">Zip code:</label>
    233263        <input id="<?php echo $this->get_field_id('zip'); ?>" name="<?php echo $this->get_field_name('zip'); ?>" value="<?php echo $instance['zip']; ?>" size="5" maxlength="5" />
     264                Or provide the latitude/Longitude<br />
     265        <label for="<?php echo $this->get_field_id('userlat'); ?>">Latitude:</label>
     266        <input id="<?php echo $this->get_field_id('userlat'); ?>" name="<?php echo $this->get_field_name('userlat'); ?>" value="<?php echo $instance['userlat']; ?>" size="15" maxlength="15" /><br />
     267        <label for="<?php echo $this->get_field_id('userlong'); ?>">Longitude:</label>
     268        <input id="<?php echo $this->get_field_id('userlong'); ?>" name="<?php echo $this->get_field_name('userlong'); ?>" value="<?php echo $instance['userlong']; ?>" size="15" maxlength="15" />
    234269        </p>
    235270
Note: See TracChangeset for help on using the changeset viewer.