Changeset 808856
- Timestamp:
- 11/22/2013 01:41:55 PM (12 years ago)
- Location:
- daily-zman-widget
- Files:
-
- 4 added
- 1 deleted
- 2 edited
-
tags/1.1 (added)
-
tags/1.1/license.txt (added)
-
tags/1.1/readme.txt (added)
-
tags/1.1/zmandaily.php (added)
-
trunk/Daily_Zman (deleted)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/zmandaily.php (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
daily-zman-widget/trunk/readme.txt
r787938 r808856 4 4 Tags: Prayer Times, Davening times, davening, Zman, zmanim 5 5 Requires at least: 3.3 6 Tested up to: 3. 67 Stable tag: 1. 06 Tested up to: 3.7.1 7 Stable tag: 1.1 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 76 76 77 77 == Changelog == 78 78 79 = 1.0 = 79 80 * 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 80 90 81 91 -
daily-zman-widget/trunk/zmandaily.php
r787938 r808856 6 6 * Uses the inimitable Hebcal.com site for parsha and other information, 7 7 * as well as Google Maps API for geographic and sunrise/sunset information. 8 * Version: 1. 08 * Version: 1.1 9 9 * Author: Leon Adato 10 10 * Author URI: http://www.adatosystems.com/ … … 12 12 * *********************************** 13 13 * 2013- - initial creation 14 * 2013-11-22 - matched to updates in Shabbat Zman widget 14 15 * 15 16 * … … 67 68 $yom = strtotime("now"); 68 69 $yom_txt = date("M d, Y", $yom); 70 $yom_ymd = date("Y-m-d", $yom); 69 71 70 72 // Get Hebrew Date from HebCal … … 80 82 } 81 83 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."×tamp=".$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); 91 125 $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; 101 133 102 134 // Calculate Plag haMincha 103 135 if($instance['showplag']) { 104 $sunrisesec = $suninfo['sunrise']+$offset;105 $sunsetsec = $suninfo['sunset']+$offset;106 136 if($instance['plagmethod'] == "gra") { 107 137 $halachichour = ($sunsetsec - $sunrisesec)/12; … … 121 151 // Calculate Shema 122 152 if($instance['showshema']) { 123 $sunrisesec = $suninfo['sunrise']+$offset;124 $sunsetsec = $suninfo['sunset']+$offset;125 153 if($instance['shemamethod'] == "gra") { 126 154 $halachichour = ($sunsetsec - $sunrisesec)/12; … … 140 168 // Calculate Earliest Mincha 141 169 if($instance['showmincha']) { 142 $sunrisesec = $suninfo['sunrise']+$offset;143 $sunsetsec = $suninfo['sunset']+$offset;144 170 if($instance['shemamethod'] == "gra") { 145 171 $halachichour = ($sunsetsec - $sunrisesec)/12; … … 164 190 if($instance['showlocation'] ) {echo $address.'<br />'; } 165 191 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 />';} 167 193 if($instance['showshema'] ) {echo $shematext.'<br />'; } 168 194 if($instance['showmincha'] ) {echo $minchatext.'<br />'; } 169 195 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 />';} 171 197 if($instance['love'] ) {echo $lovetext.'<br />'; } 172 198 173 199 if($instance['debug'] ) { 174 200 echo 'Current PHP version: ' . phpversion().'<br />'; 201 echo 'Latlong URL is '.$latlongurl.'<br />'; 175 202 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 />'; 177 205 echo 'Date timestamp: '.$yom.' and Date text is '.$yom_txt.' <br />'; 178 echo 'Sunset: '.$ sunset.' <br />';206 echo 'Sunset: '.$yomsunsetdatetime.' <br />'; 179 207 echo 'Hebcal jewish date URL: '.$hebcaljd['link'].'<br />'; 180 208 echo 'Weekday number: '.date('N').'<br />'; … … 193 221 $instance['title'] = strip_tags($new_instance['title']); 194 222 $instance['zip'] = strip_tags($new_instance['zip']); 223 $instance['userlat'] = strip_tags($new_instance['userlat']); 224 $instance['userlong'] = strip_tags($new_instance['userlong']); 195 225 $instance['ashki'] = $new_instance['ashki']; 196 226 $instance['showlocation'] = $new_instance['showlocation']; … … 232 262 <label for="<?php echo $this->get_field_id('zip'); ?>">Zip code:</label> 233 263 <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" /> 234 269 </p> 235 270
Note: See TracChangeset
for help on using the changeset viewer.