Author Topic: Old Anole AQI Script & PHP8  (Read 373 times)

0 Members and 1 Guest are viewing this topic.

Offline tmabell

  • Forecaster
  • *****
  • Posts: 338
Old Anole AQI Script & PHP8
« on: February 19, 2021, 09:16:21 PM »
I'm still using the old Larry Boyd (anole) AQI Air Quality Index script and while it threw a number of warnings in php 7.x, it did work.  I discovered however that under php 8 it no longer works at all.  Hopefully someone here might have an idea how to get it going again.  Here are the log entries from my server:

Warning: Undefined variable $urlActionDay in C:\www\wxaqirss.php on line 74
Fatal error: Uncaught ValueError: DOMDocument::load(): Argument #1 ($filename) must not be empty in C:\www\wxaqirss.php:243 Stack trace: #0 C:\www\wxaqirss.php(243): DOMDocument->load('') #1 C:\www\wxaqirss.php(74): getAQIdata(NULL, 'actionday') #2 {main} thrown in C:\www\wxaqirss.php on line 243


Obviously the fatal error is what's killing it.

Offline the beteljuice

  • the beteljuice
  • Senior Contributor
  • ****
  • Posts: 293
    • test site
Re: Old Anole AQI Script & PHP8
« Reply #1 on: February 19, 2021, 10:26:21 PM »
Try changing $urlActionDay in C:\www\wxaqirss.php on line 74 to

getAQIdata($urlActionday, "actionday");
Imagine what you will KNOW tomorrow !

Offline tmabell

  • Forecaster
  • *****
  • Posts: 338
Re: Old Anole AQI Script & PHP8
« Reply #2 on: February 20, 2021, 08:01:08 AM »
Unfortunately, that didn't work.  I may be missing something but that line appears exactly the same as the original?  Maybe I need more coffee  :???:

Offline the beteljuice

  • the beteljuice
  • Senior Contributor
  • ****
  • Posts: 293
    • test site
Re: Old Anole AQI Script & PHP8
« Reply #3 on: February 20, 2021, 10:30:40 AM »
Did you change it ????

Definitely was wrong ...

Line #34
$urlActionday = "https://feeds.enviroflash.info/rss/actionday/140.xml";  //South Bend, IN

Line #74
getAQIdata($urlActionDay, "actionday");

... and all the error messages are an escalation of the 'missing' url
Imagine what you will KNOW tomorrow !

Offline tmabell

  • Forecaster
  • *****
  • Posts: 338
Re: Old Anole AQI Script & PHP8
« Reply #4 on: February 20, 2021, 10:50:20 AM »
I had changed it but no change was noted so I changed line 74 to
Code: [Select]
getAQIdata($urlActionday, "actionday"); and now there is a change, but still not right:

https://mymishawakaweather.com/wxaqirss.php

I'm attaching the edited copy.  I really appreciate the help!

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 8356
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Old Anole AQI Script & PHP8
« Reply #5 on: February 20, 2021, 11:45:47 AM »
A couple more code glitches fixed in the attached.

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 tmabell

  • Forecaster
  • *****
  • Posts: 338
Re: Old Anole AQI Script & PHP8
« Reply #6 on: February 20, 2021, 12:18:38 PM »
Thanks to The Beteljuice and to Ken for jumping in.  According to the server logs, there is one more issue on line 337 which is preventing the rest of the page from populating.

This is the logged error:

"[Sat Feb 20 12:17:09.784868 2021] [php:error] [pid 87692:tid 828] [client 192.168.10.1:55906] PHP Fatal error:  Uncaught Error: Undefined constant "imagesDir" in C:\\www\\wxaqirss.php:337\nStack trace:\n#0 C:\\www\\AQI.php(224): include()\n#1 {main}\n  thrown in C:\\www\\wxaqirss.php on line 337"


This is line 337: <td colspan="2" align="center"><img src="<?php print${imagesDir}?>aqi.gif" width="221" height="102" alt="" /><br /><br /></td>


Offline the beteljuice

  • the beteljuice
  • Senior Contributor
  • ****
  • Posts: 293
    • test site
Re: Old Anole AQI Script & PHP8
« Reply #7 on: February 20, 2021, 12:32:03 PM »
Cross posting ...

Just do the first one (line 334 now is 337)

O.K.

First of all ....

Code: [Select]
// line #334 (produces fatal error)
<td colspan="2" align="center"><img src="<?php print${imagesDir}?>aqi.gif" width="221" height="102" alt="" /><br /><br /></td>

// should be
<td colspan="2" align="center"><img src="<?php print $imagesDir?>aqi.gif" width="221" height="102" alt="" /><br /><br /></td>

#line #220
//$adtext = '';

// should be
$adtext = '';

// now we need to add a non-existant 'flag' ($real2)
// code block starting line #121
   // search for two AQI types
   if(preg_match('|<br /><br />\n(.*) - (.*) AQI - (.*)<br />(.*) - (.*) AQI - (.*)</div>|Uis', $realtime[0]["desc"])) {
      preg_match('|<br /><br />\n(.*) - (.*) AQI - (.*)<br />(.*) - (.*) AQI - (.*)</div>|Uis', $realtime[0]["desc"], $r3);
      $realIndex2 = trim(strip_tags($r3[4]));
      $realValue2 = trim(strip_tags($r3[5]));
      $realMeasure2 = trim(strip_tags($r3[6]));
   }

// needs to be
   // search for two AQI types
   $real2 = false;
   if(preg_match('|<br /><br />\n(.*) - (.*) AQI - (.*)<br />(.*) - (.*) AQI - (.*)</div>|Uis', $realtime[0]["desc"])) {
      preg_match('|<br /><br />\n(.*) - (.*) AQI - (.*)<br />(.*) - (.*) AQI - (.*)</div>|Uis', $realtime[0]["desc"], $r3);
      $realIndex2 = trim(strip_tags($r3[4]));
      $realValue2 = trim(strip_tags($r3[5]));
      $realMeasure2 = trim(strip_tags($r3[6]));
  $real2 = true;
   }

I think that will fix everything that's being complained about ...
... unless you tell me different

Imagine what you will KNOW tomorrow !

Offline tmabell

  • Forecaster
  • *****
  • Posts: 338
Re: Old Anole AQI Script & PHP8
« Reply #8 on: February 20, 2021, 12:45:17 PM »
That fixed everything!  Thank you for sticking with this and helping me along.  Your kindness and generosity are much appreciated.

 

anything