Page 15 of 54

Re: Now available: AJAX/PHP multilingual website templates

Posted: Tue 15 Mar 2011 4:12 pm
by kinder
limitation of strotime.Handle dates with / in m/d/y format.probably thats the reason.

Re: Now available: AJAX/PHP multilingual website templates

Posted: Tue 15 Mar 2011 4:17 pm
by kinder
yeah nice all in one page.If u want to share that with us it would be nice.

Re: Now available: AJAX/PHP multilingual website templates

Posted: Tue 15 Mar 2011 6:48 pm
by n9mfk
hi Ken im tring to learn
what did i miss on this url
aa.usno.navy.mil,cgi-bin/aa_pap.pl/FFX=2&ID=AA&xxy=2011&xxm=3&xxd=15&place=Springfield%2C+IL%2C+USA&xx0=-1&xx1=89&xx2=37&yy0=1&yy1=39&yy2=42&zz1=5&zz0=-1&ZZZ=END
thanks Beau

Re: Now available: AJAX/PHP multilingual website templates

Posted: Tue 15 Mar 2011 7:21 pm
by kinder
gemini06720 wrote:
kinder wrote:Any guess why the next update time shows always next update at 2:01?
Just noticed that on my main page... :roll:

I checked the value of the variable '$timeofnextupdate' - it seems to always give me 16:10, no matter what time the next update should be.

I then checked how the the variable '$timeofnextupdate' was calculated/created (in the 'CU-defs.php' script):

Code: Select all

$timeofnextupdate  = date('H:i',strtotime($date.' '.$time)+$WX['interval']*60);
It first converts (parse) the current date and the current time into a Unix timestamp and then adds the time interval (in minutes, as setup in Cumulus) multiplied by 60 (so the time interval is really in seconds).

But, for some reasons, the PHP function 'strtotime' refuses to convert (parse) the date in this format '15/03/2011' !

So, what I have done to eliminate the error (or lack of proper data) was to add the following line directly into my 'ajax-dashboard.php' script, just before the start of the display of the weather data:

Code: Select all

$timeofnextupdate  = date('H:i',strtotime($time)+$WX['interval']*60);
I do not know why it is happening ... Ken is probably the only one that will be able to provide an explanation...
Confirmed it works.
Probably Ken should add that in next version to ensure that strtotime works in every case as it should be.

Re: Problem in Thermometer

Posted: Tue 15 Mar 2011 10:46 pm
by JESUS HEREDERO
Good evening, my name is Jesus
I have a small problem, I do not get the image of the thermometer on the screen, I've tried various ways and tried changing "WD" and "CU". I use Cumulus "realtime.txt", referring to the IE 8 thermometer.php I get these errors -----



Warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration in /homepages/12/d328477654/htdocs/tiempo/thermometer.php on line 156

Warning: file_get_contents(http://meteoestremera.es/meteoestremera ... altime.txt) [function.file-get-contents]: failed to open stream: no suitable wrapper could be found in /homepages/12/d328477654/htdocs/tiempo/thermometer.php on line 156






And so here is my problem the rest works pretty well, although there are still some things to add extension.
This is the piece of program which gives me the error:

if ($wxSoftware == 'WD') { // Get the Weather-Display clientraw.txt data file

$dataraw = file_get_contents($clientrawfile);

// clean up any blank lines
$dataraw = trim($dataraw);
$dataraw = preg_replace("/[\r\n]+[\s\t]*[\r\n]+/","\n",$dataraw);
$data = explode(" ", $dataraw);

$curtemp = CtoF($data[4],1);
$mintemp = CtoF($data[47],1);
$maxtemp = CtoF($data[46],1);
} // end Weather Display data

if ($wxSoftware == 'VWS') { // Get the VWS Weather Flash data files

$filename = "${wflashDir}wflash.txt";
$file = file($filename);
$file = implode('',$file);
$data = explode(",",$file);;

$curtemp = FtoC($data[9],1);

$filename = "${wflashDir}wflash2.txt";
$file = file($filename);
$file = implode('',$file);
$data = explode(",",$file);;

$mintemp = FtoC($data[92],1);
$maxtemp = FtoC($data[36],1);
}
// ERROR ?
if ($wxSoftware == 'CU') { // Get the Cumulus realtime.txt file
$dataraw = file_get_contents($realtimefile);
// clean up any blank lines
$dataraw = trim($dataraw);
$dataraw = preg_replace("/[\r\n]+[\s\t]*[\r\n]+/","\n",$dataraw);
$data = explode(" ", $dataraw);
$inUOM = $data[14];
if ($inUOM == 'F' and $UOM == 'C') {
$curtemp = FtoC($data[2],1);
$mintemp = FtoC($data[28],1);
$maxtemp = FtoC($data[26],1);
} elseif ($inUOM == 'C' and $UOM == 'F') {
$curtemp = CtoF($data[2],1);
$mintemp = CtoF($data[28],1);
$maxtemp = CtoF($data[26],1);
} else {
$curtemp = $data[2];
$mintemp = $data[28];
$maxtemp = $data[26];
$UOM = $inUOM;
}
}

if ($wxSoftware == 'WL') { // Process WeatherLink
if(!isset($WLrealtime)) { // get from WLtags.php
if (file_exists($SITE['WXtags'])) {global $WX; include_once($SITE['WXtags']); }
$inUOM = 'F';
$curtemp = 70;
$mintemp = 60;
$maxtemp = 80;

if(preg_match("|C|i",$WX['tempUnit'])) {
$inUOM = 'C';
} else {
$inUOM = 'F';
}
if ($inUOM == 'F' and $UOM == 'C') {
$curtemp = FtoC($WX['outsideTemp'],1);
$mintemp = FtoC($WX['lowOutsideTemp'],1);
$maxtemp = FtoC($WX['hiOutsideTemp'],1);
} elseif ($inUOM == 'C' and $UOM == 'F') {
$curtemp = CtoF($WX['outsideTemp'],1);
$mintemp = CtoF($WX['lowOutsideTemp'],1);
$maxtemp = CtoF($WX['hiOutsideTemp'],1);
} elseif (isset($WX['outsideTemp'])) {
$curtemp = $WX['outsideTemp'];
$mintemp = $WX['lowOutsideTemp'];
$maxtemp = $WX['hiOutsideTemp'];
$UOM = $inUOM;
}


} else { // fetch it from the $WLrealtime

$dataraw = file_get_contents($WLrealtime);

// clean up any blank lines
$dataraw = trim($dataraw);
$dataraw = preg_replace("/[\r\n]+/",'',$dataraw);
$data = explode("|", $dataraw);
if(preg_match("|C|i",$data[148])) {
$inUOM = 'C';
} else {
$inUOM = 'F';
}
if ($inUOM == 'F' and $UOM == 'C') {
$curtemp = FtoC($data[10],1);
$mintemp = FtoC($data[12],1);
$maxtemp = FtoC($data[11],1);
} elseif ($inUOM == 'C' and $UOM == 'F') {
$curtemp = CtoF($data[10],1);
$mintemp = CtoF($data[12],1);
$maxtemp = CtoF($data[11],1);
} else {
$curtemp = $data[10];
$mintemp = $data[12];
$maxtemp = $data[11];
$UOM = $inUOM;
}

} // end fetch it from $WLrealtime
}



My Weather Station is Estremera
my website URL. http://meteoestremera.es/tiempo/wxindex.php and other files in that directory to leaf through
Thanks for the help

Re: Now available: AJAX/PHP multilingual website templates

Posted: Tue 15 Mar 2011 11:12 pm
by saratogaWX
Hi Jesus,

In your Settings-weather.php you have

Code: Select all

$SITE['realtimefile'] = 'http://meteoestremera.es/meteoestremera/meteo/realtime.txt';
and it should read

Code: Select all

$SITE['realtimefile'] = '../meteoestremera/meteo/realtime.txt';
Since your weather website is located in the URL path of /tiempo/ and your realtime.txt is in the URL path of
/meteoestremera/meteo/, you need to use relative file addressing for the realtime.txt, not an URL.

Best regards,
Ken

Re: Now available: AJAX/PHP multilingual website templates

Posted: Tue 15 Mar 2011 11:24 pm
by saratogaWX
kinder wrote:
gemini06720 wrote:
kinder wrote:Any guess why the next update time shows always next update at 2:01?
Just noticed that on my main page... :roll:

I checked the value of the variable '$timeofnextupdate' - it seems to always give me 16:10, no matter what time the next update should be.

I then checked how the the variable '$timeofnextupdate' was calculated/created (in the 'CU-defs.php' script):

Code: Select all

$timeofnextupdate  = date('H:i',strtotime($date.' '.$time)+$WX['interval']*60);
It first converts (parse) the current date and the current time into a Unix timestamp and then adds the time interval (in minutes, as setup in Cumulus) multiplied by 60 (so the time interval is really in seconds).

But, for some reasons, the PHP function 'strtotime' refuses to convert (parse) the date in this format '15/03/2011' !

So, what I have done to eliminate the error (or lack of proper data) was to add the following line directly into my 'ajax-dashboard.php' script, just before the start of the display of the weather data:

Code: Select all

$timeofnextupdate  = date('H:i',strtotime($time)+$WX['interval']*60);
I do not know why it is happening ... Ken is probably the only one that will be able to provide an explanation...
Confirmed it works.
Probably Ken should add that in next version to ensure that strtotime works in every case as it should be.
Ah, yes... it's that 'PHP is confused by European-style-dates' issue. The default for PHP is to use mm/dd/yyyy format if no Locale setting is done. I'd not done any setlocale() calls to force the PHP into handling the issue directly (dd/mm/yyyy) since the various setlocale() strings are quite varied across platforms. For example, to set Dutch format, I'd had to use something like

Code: Select all

	$locale = setlocale(LC_TIME,'nl_NL.ISO8859-1', 'nld_nld', 'nl_NL','nl_NLD',"nld","NLD", "dutch", "holland", "netherlands");
hoping that one of the strings would be the magic word to change the time format into Dutch. It was just a real pain with no common standardization on what to use for a given platform (Linux, Windows, etc).

I think the

Code: Select all

$timeofnextupdate  = date('H:i',strtotime($time)+$WX['interval']*60);
is a good idea (avoids the issue) and will work it in to an update.
Also, check your Settings.php entry for

Code: Select all

$SITE['WDdateMDY'] = false;
that instructs the date functions to process the dates from Cumulus as M/D/Y (for =true) or as D/M/Y (for =false) .. if it's set incorrectly, all bets are off :)

Best regards,
Ken

Re: Now available: AJAX/PHP multilingual website templates

Posted: Wed 16 Mar 2011 1:53 am
by kinder
I think the

Code: Select all

$timeofnextupdate  = date('H:i',strtotime($time)+$WX['interval']*60);
is a good idea (avoids the issue) and will work it in to an update.
Also, check your Settings.php entry for

Code: Select all

$SITE['WDdateMDY'] = false;
that instructs the date functions to process the dates from Cumulus as M/D/Y (for =true) or as D/M/Y (for =false) .. if it's set incorrectly, all bets are off :)

Best regards,
Ken
Well the WDdateMDY = false because cumulus running on a pc with greek locale and also reports dates and times in euro format.Is it wrong?

Re: Now available: AJAX/PHP multilingual website templates

Posted: Wed 16 Mar 2011 2:44 am
by saratogaWX
Mike Challis noted that the USA NWS ATOM/CAP feed URL has changed:

Old URL: (just died today, 404 not found)
http://www.weather.gov/alerts-beta/wwaatmget.php

New URL:
http://alerts.weather.gov/cap/wwaatmget.php

I've updated the distribution sources with the new URL

atom-advisory/atom-top-warning (standalone+V2 template) http://saratoga-weather.org/scripts-ato ... omadvisory

Base-USA V3 template http://saratoga-weather.org/wxtemplates/updates.php

Best regards,
Ken

Re: Now available: AJAX/PHP multilingual website templates

Posted: Wed 16 Mar 2011 7:32 am
by JESUS HEREDERO
Thanks Ken


OK, that was it, had marked the complete URL
And works well

Re: Now available: AJAX/PHP multilingual website templates

Posted: Wed 16 Mar 2011 12:10 pm
by gemini06720
kinder wrote:limitation of strotime.Handle dates with / in m/d/y format.probably thats the reason.
The 'strtotime' function is supposed to (as written in the documentation) "...parse about any English textual datetime description into a Unix time...".

I guess having the date in the 'dd/mm/yyyy' format (as '16/03/2011') is not one of the formats accepted by the function... :x

Re: Now available: AJAX/PHP multilingual website templates

Posted: Wed 16 Mar 2011 12:21 pm
by gemini06720
saratogaWX wrote:Also, check your Settings.php entry for

Code: Select all

$SITE['WDdateMDY'] = false;
that instructs the date functions to process the dates from Cumulus as M/D/Y (for =true) or as D/M/Y (for =false) .. if it's set incorrectly, all bets are off :)
Ken, just to be sure I understand clearly the purposes/results of the '$SITE['WDdateMDY']' variable:
  • true=dates are in the 'month/day/year' format
    false=dates are in the 'day/month/year' format
You also mentioned
saratogaWX wrote:...Ah, yes... it's that 'PHP is confused by European-style-dates' issue...
Is PHP not a global project with people from almost every countries of the world participating - why would one PHP function not be able to handle the European-style date formats without having to go through additional setups... :?

Re: Now available: AJAX/PHP multilingual website templates

Posted: Wed 16 Mar 2011 12:37 pm
by gemini06720
Manuel and kinder find attached my 'Weather Data' PHP template.

Also included in the ZIP file is the 'wxcudata_language-en.txt' file which contains all the english terms (words/phrases) contained in the template. I have made the file external so the terms (words/phrases) can be easily translated - once translation is completed, the file must be merge with the language file you use with the templates - for example, my french language file is called 'language-fr.txt', thus, once I had the terms (words/phrases) translated to french, I merged the file 'wxcudata_language-en.txt' with the file 'language-fr.txt'.

Re: Now available: AJAX/PHP multilingual website templates

Posted: Wed 16 Mar 2011 2:11 pm
by beteljuice
Note:

Dates in the m/d/y or d-m-y formats are disambiguated by looking at the separator between the various components: if the separator is a slash (/), then the American m/d/y is assumed; whereas if the separator is a dash (-) or a dot (.), then the European d-m-y format is assumed.

To avoid potential ambiguity, it's best to use ISO 8601 (YYYY-MM-DD) dates or DateTime::createFromFormat() when possible.
Link: strtotime() function

Re: Now available: AJAX/PHP multilingual website templates

Posted: Wed 16 Mar 2011 2:42 pm
by Gina
I use m/d/yy notation generally when slashes are allowed. But for filenames or data text files I tend to use yyyy-mm-dd.