Author Topic: firedangerWD  (Read 149 times)

0 Members and 1 Guest are viewing this topic.

Offline mldenison

  • Senior Member
  • **
  • Posts: 90
    • York, PA Weather
firedangerWD
« on: June 15, 2020, 12:25:50 PM »
My fire danger graphic on my web page no longer displays.  I'm not sure when it broke.  Perhaps when I went to the latest version of server php.

I saw a post via search that states that it may be related to the ajaxWDwx.js file as having issues with the latest php server version.

I'm not sure where to find the error being thrown.

Both the firedangerWD.php and the ajaxWDwx.js are some years old and I can't find any updated versions.

Can anyone help?

Windows 7 x64
Weather PC: Intel NUC
Davis Vantage Pro 2
Weather Underground: KPAYORK30
York, PA Weather (Saratoga)
York, PA Weather (Leuven)
York, PA PWS Station

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 7908
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: firedangerWD
« Reply #1 on: June 15, 2020, 12:54:27 PM »
A PHP version update wouldn't have an effect on ajaxWDwx.js at all-- that is a JavaScript and runs in your browser.  It hasn't needed a change for quite sometime and the current version is Version 2.25 - 30-Sep-2017.  But... your site is not running that script .. you're running the Leuven ajax.js script instead.

The firedangerWD.php script on your page at https://www.m82a1.us/weather28/firedanger/testit.php?fwtemp=69.1&fwhum=46&lang=en&fwuom=c seems to be working ok.
Since you're running a Leuven template, I think Wim will need to address the firedanger script .. it's not a part of the Saratoga templates.

As a side note, I've had some issues with using the GD library with TrueType fonts and PHP 7.4 -- it seems that the GD library can't find the font file using relative addressing, but needs a realpath() to locate the font file.
« Last Edit: June 15, 2020, 12:57:26 PM by saratogaWX »
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Boltek-PCI/NexStorm, microSferics ToA, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge/hub
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline wvdkuil

  • Wim van der kuil
  • Forecaster
  • *****
  • Posts: 1627
    • My PWS at Leuven Belgium Europe
Re: firedangerWD
« Reply #2 on: June 15, 2020, 01:32:51 PM »
I think you are refer to this script https://www.gwwilkins.org/firedangerWD.php?sce=view
This version does not use clientraw, see topic here https://www.wxforum.net/index.php?topic=38716.0

In your case it would be helpful to add the link  to which website (Leuven / Saratoga /PWS_Dashboard) you want support.  [tup]

Wim
Support for Leuven-Template & Scripts  at this forum
Script sponsors support.leuven-template.eu/userlistScripts.php
Template sponsors support.leuven-template.eu/userlist.php

Support for the PWS_Dashboard  pwsdashboard.com

Offline mldenison

  • Senior Member
  • **
  • Posts: 90
    • York, PA Weather
Re: firedangerWD
« Reply #3 on: June 15, 2020, 02:11:14 PM »
Sorry folks, look at the bottom of this page:

https://www.m82a1.us/index.php

I tried just https://www.m82a1.us/firedangerWD.php in my Pale Moon browser and results in a message saying 'The image can't be displayed because it contains errors'.  Not helpful to me for getting to the cause.

Someone else set up both the Saratoga and Leuven websites for me initially and didn't add the fire danger display in the Leuven template for display.  I didn't know it was even there.  I just looked at both php scripts and they're pretty different.

Here's the one that runs on my Saratoga website:

Code: [Select]
<?php

// Based on firedanger script by SLOweather.com, modified to use Weather
// Display clientraw.txt data file. Release 08/25/07 by W7RSW 
// Initial release 070625 (YYMMDD) by SLOweather.com
// This script uses temperature in F and relative Humidity to 
// calculate the Chandler Burning index and then select the 
// appropriate graphic to display. It also selects the proper
// adjective for the current conditions, but this feature is not
// currently used for anything.

// As written, it requires an image pack of 5 graphics for each of
// the 5 danger levels, in the same directory as the script.

// Based on data from Anole's stickertags.txt file.
// For more information on the Chandler Burning Index:
// http://www.fs.fed.us/psw/topics/fire_science/fire_weather/mfwf/MFWFDesc.shtml
// For the Adjective Fire Danger text for each CBI level
// http://famweb.nwcg.gov/pocketcards/adjective.htm

// DATA FILE: defines the path to the data file. 
// The path can be absolute or relative or a URL)!!

$data_file_path  'clientraw.txt'
// get the data file
$dataraw file_get_contents($data_file_path); 


// see if the data file is a WD clientraw.txt file and set
// the WD flag for those specific routines to be executed.
if (preg_match('|clientraw.txt|'$data_file_path)){
   
$use_wd_clientraw '1';
//end if

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

// if we're using the WD clientraw.txt we have a lot of work to do to make it
// pretty. So here we go:

// put the clientraw.txt data into an array and define the data points
if ($use_wd_clientraw == '1') {
   
$data explode(" "$dataraw);
   
// clean up and define
   
   
   
(float)$cTemp "$data[4]";
   (float)
$rh "$data[5]";
   
   function 
tempToFahrenheit ($cTemp$prec=0)
// Given a temperature in degrees Fahrenheit, convert it 
// to Celsius and return the value.  Use an integer for 
// precision ($prec) to round the converted value.
// Returns FALSE on error.
{
  if (!isset(
$cTemp)) {
    return 
false;
  }
  
$prec = (integer)$prec;
  
$fTemp = (float)(1.8 $cTemp) + 32;
  return 
round($fTemp$prec);
}

$ftemp tempToFahrenheit ($cTemp);

  
// Start Index Calcs

// Chandler Index
$cbi = (((110 1.373 $rh) - 0.54 * (10.20 $cTemp)) * (124 pow(10,(-0.0142*"$rh"))))/60;
// CBI = (((110 - 1.373*RH) - 0.54 * (10.20 - T)) * (124 * 10**(-0.0142*RH)))/60

//Sort out the Chandler Index


if ($cbi "97.5") {
    
$cbitxt "EXTREME";
    
$cbiimg"fdl_extreme.gif";

} elseif (
$cbi >="90") {
    
$cbitxt "VERY HIGH";
    
$cbiimg"fdl_vhigh.gif";

} elseif (
$cbi >= "75") {
    
$cbitxt "HIGH";
    
$cbiimg"fdl_high.gif";

} elseif (
$cbi >= "50") {
    
$cbitxt "MODERATE";
    
$cbiimg"fdl_moderate.gif";

} else

if (
$cbi "50") {
    
$cbitxt="LOW";
    
$cbiimg"fdl_low.gif";

}


$img imagecreatefromgif($cbiimg);
// additions by Saratoga-Weather.org
  
$degree_units 'F';
  
$color_red imagecolorallocate($img,255,0,0);      // RED
  
$color_green imagecolorallocate($img,0,128,0);      // GREEN
  
// If Celsius units desired, use
// $ntemp = round($cTemp,1);
  
$ntemp round($ftemp,1);
  
$nrh round($rh,0);
  
$ncbi round($cbi,0);
 
  
imagestring($img290116"$ntemp$degree_units"$color_green);
  
imagestring($img2130116"$nrh%"$color_green);
  
imagestring($img298127"CBI: $ncbi"$color_red);

// ---------------------------------
header("Content-type: image/gif"); 
imageGIF($img);
imagedestroy($img);
}

?>

Sorry for confusion.

Windows 7 x64
Weather PC: Intel NUC
Davis Vantage Pro 2
Weather Underground: KPAYORK30
York, PA Weather (Saratoga)
York, PA Weather (Leuven)
York, PA PWS Station

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 7908
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: firedangerWD
« Reply #4 on: June 15, 2020, 02:37:14 PM »
You may be missing the fdl_*.gif images in the same directory as the firedangerWD.php script.

Check the error_log for your site.. it will show what the problem with the script is.  When you get 'unable to display' errata with
and image generation script, it's usually caused by text PHP Warning/Notice errors that have to be fixed for the image to display.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Boltek-PCI/NexStorm, microSferics ToA, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge/hub
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline gwwilk

  • Southeast Lincoln Weather
  • Forecaster
  • *****
  • Posts: 2306
    • SouthEast Lincoln, NE Weather
Re: firedangerWD
« Reply #5 on: June 15, 2020, 02:43:08 PM »
Here is my version of FiredangerWD.php and it displays correctly.  I've rewritten ajaxWDwx3.js so this graphic on my alternate dashboard updates in real time.

Attached are the base images found in my root directory as well as the modified ajaxWDwx3.js file in minified and uncompressed formats.

The firedangerWD.php script is available here.
Regards, Jerry Wilkins
gwwilk@gmail.com

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 7908
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: firedangerWD
« Reply #6 on: June 15, 2020, 02:50:37 PM »
Thanks Jerry!
« Last Edit: June 15, 2020, 04:22:47 PM by saratogaWX »
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Boltek-PCI/NexStorm, microSferics ToA, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge/hub
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline mldenison

  • Senior Member
  • **
  • Posts: 90
    • York, PA Weather
Re: firedangerWD
« Reply #7 on: June 15, 2020, 02:54:06 PM »
Thanks, Ken.  The images were not there.  I had them on a backup and copied them back and it's now working.  I appreciate it.  I hope I remember about the error_log which told me the images were gone.  I appreciate your help.

Thanks for the update files, Jerry.  I'll incorporate them later today.  Nice web page you have!

Mort

Windows 7 x64
Weather PC: Intel NUC
Davis Vantage Pro 2
Weather Underground: KPAYORK30
York, PA Weather (Saratoga)
York, PA Weather (Leuven)
York, PA PWS Station

 

anything