Php webtags: Difference between revisions

847 bytes added ,  12:00, 20 April 2020
m
Line 69: Line 69:


=== Based on original by David Jamieson and Ray Beriau ===
=== Based on original by David Jamieson and Ray Beriau ===
These all work with Cumulus 1. They all contain PHP variables for all the web tags available in Cumulus 1. For the files marked as for MX versions, the PHP variables that relate to web tags not available in  MX have been given arbitrary fixed values, not nulls. For recent history tags the PHP variables are set to report only the values for one day and one minute ago. Otherwise, apart from a few web tags that report dates where alternative formats are added (as shown below) using output parameters and new variable names, most php variable names match the corresponding web tags name, there are no alternatives for the time-stamps and date-stamps in any weather derivatives. You will notice the USA style month first bias of the original authors in some of the date formats below.
These all work with Cumulus 1. They all contain PHP variables for all the web tags available in Cumulus 1. For the files marked as for MX versions, the PHP variables that relate to web tags not available in  MX have been given arbitrary fixed values, not nulls, so only really work for the system of the person who last updated the file. For recent history tags the PHP variables are set to report only the values for one day and one minute ago. These are used on a "Now" type page that compares the current values to the values at the closest time yesterday. The extra minute has to be added to the output parameters to cover the delay in retrieving the old values compared to the speed in updating of current values.
Otherwise, apart from a few web tags that report dates where alternative formats are added (as shown below) using output parameters and new variable names, most php variable names match the corresponding web tags name, there are no alternatives for the time-stamps and date-stamps in any weather derivatives. You will notice the USA style month first bias of the original authors in some of the date formats below.
'''Note there is an error in these files''' - they contain a "?>" at the end, that should not be used in pure PHP files - see PHP manual instruction.  Should white-space or new lines being added after the PHP closing tag, even accidentally,  there may be unwanted effects because PHP will start output buffering when there is no intention from the programmer to send any output at that point in the script. That applies even if the extra is after the include/require in the script using this file.
<pre>$date2          = strtotime(str_replace('/','-',"<#date>"));  //  current date (example format: 1346569200)
<pre>$date2          = strtotime(str_replace('/','-',"<#date>"));  //  current date (example format: 1346569200)
$dateU              = strtotime(str_replace('/','-',"<#date>"));  //  current date (Unix datestamp format)
$dateU              = strtotime(str_replace('/','-',"<#date>"));  //  current date (Unix datestamp format)
5,838

edits