Updating PHP scripts

Hello,

If you recall I am not a programmer so php stuff can be a little overwhelming for me - but i am trying :slight_smile:

I ran the check version script and I appear to be way out of date: Saratoga-weather.org Template Test Utility

When Iā€™m in the page that says to enter a date, assuming I need to put the date of the latest update on my page based on the link above, which in my case would be 09-08-2022 - correct?

I know some are just replace so I can do that.

For the ones that need updates, how do I know what line needs to be updated?

Oh one other note, looks like my hosting site updated PHP from version 5 to 8, will that be an issue?

Thanks all for helping someone who doesnā€™t do much PHP work

Assuming 09-08-2022 was the last update, i downloaded the zip file. There are two readme files. One is for sunposa.txt: when I look at that:

./cache/ has two files (jpsun.png and jpmoon.png that need to be uploaded)
- I have that folder and those two files so I just need to replace
./jpgraph-4.4.2-src-only/ needs to be uploaded with the subdirectory src/*.php
- I have a folder called ā€œjpgraphā€ but not the one with 4-4.2-src-only - Do I simple create this folder? OR replace the old JP graph folder?
./moonimg/ directory has *.gif files needed ā€¦ upload the entire directory with files.
- This appears new, where in the folder structure does this go? Right under PHP_Public? or something else?

Not sure what to do with this:
The sunposa.php script is Saratoga template aware and will use your Settings.php entries to automatically configure.

Additional optional utilities are available at GitHub - ktrue/SunMoon-graph: Create PNG image of Sun/Moon azimuth/elevation rise/set times in case youā€™d like to
tweak the legends for a particular language. The langtrans/ directory on GitHub contains the utilities.

NOTE: Do NOT edit the sunposa-lang.php file directly ā€¦ it is created by a langtrans/gen-sunposa-lang.php
utility and the instructions on how to do updates to the translations are included in that directory.

Actually, the check-fetch-times.php?show=versions has at the bottom of the page:

To update your template set to current script version(s), use the updates tool page with a query set for 27-Dec-2022 for Base-USA, WD-plugin

If you use that 27-Dec-2022 date for the query, it will return ALL the files needed in the .zip (including the JPgraph files needed for the new sunpos display on the astronomy page.

All files should be posted to your document root and any subdirectories w/files below that directory ā€“ Be sure to check the recommendations for each file. The vast majority can simply replace your existing files (or uploaded as new files). SOME will be marked with copy settings from old file to update file, then upload.

You likely wonā€™t be customizing the sunposa-lang.php file, so you donā€™t need the additional utilities from the GitHub distribution.

1 Like

Thanks Ken

What should I do with these?

./jpgraph-4.4.2-src-only/ needs to be uploaded with the subdirectory src/*.php
I have a folder called ā€œjpgraphā€ but not the one with 4-4.2-src-only - Do I simple create this folder? OR replace the old JP graph folder?

./moonimg/ directory has *.gif files needed ā€¦ upload the entire directory with files.
This appears new, where in the folder structure does this go? Right under PHP_Public? or something else?

I found the moonimg stuff:

/public_html/ajax-images/SH-moon27.gif

So I will just replace those.

Upload the entire ./jpgraph-4.4.2-src-only directory from the update .zip to your site.
It doesnā€™t need to ā€˜replaceā€™ your existing JP graph folder. It is only used by the sunposa.php script so it wonā€™t interfere with your existing JP graph using pages.

Upload the entire ./moonimg/ directory from the update .zip.

Both of the uploads need do be as subdirectories of your document root of the Saratoga template website. It, too, is used by sunposa.php

Goodā€¦ just replace all the NH-moon*.gif and SH-moon*.gif files in ajax-images/ directory from the update .zip file.

Okā€¦ progress

I copied all the impacted files from my hosting site to its own folder just in case i need them.

There were 5 files that needed customization:
ajaxMBwx.js ->Cannot figure out where and what to customize
flyout-menu.xml ->Cannot figure out where and what to customize
nws-alerts-config.php - Was able to customize
Settings-weather.php - Was able to customize
wxindex.php ->Cannot figure out where and what to customize
wxnwsradar.php ->Cannot figure out where and what to customize

Is there any documentation on what to change in each of these? If not that would really help someone like me moving forward.

Thanks

I found a tool that compares files.

For ajaxMBwx.js I only see one change, but not sure if that is code or customization (screenshot)

flyout-menu.xml I see lots of changes, specifically all the items on the left side of the main page are gone (i.e. buoy data etc). Will I lose all these features when I update (screenshot)

wxnwsradar.php I only see one change and not sure if code or something I have to change (screenshot)

wxindex.php I only see what looks to be code changes so not sure if I should customize that (screenshot)

ThANKS

You can leave ajaxMBwx.js as-is ā€¦ the tooltip setting is for debugging.

Keep your existing flyout-menu.xml if you like.

Use the new wxnwsradar.php script to replace your old one. It uses a newer version of jQuery script.

The wxindex.php script (new) removes the deprecated atom-top-warning script in favor of the nws-alerts version. You should use the new advisory code in your existing wxindex.php script.

Thanks Kenā€¦ Sorry to be a pain. Iā€™m almost there

Flyout: You said itā€™s ok to use mine. What happens if I used the new one, does all those links on the left side go away?

Wxindex: Not sure what you meant by ā€œuse the new advisory codeā€

Happy New Year !!!

If you use the new flyout-menu.xml, then youā€™ll lose all your customizations to the existing flyout-menu.xml ā€“ so, just keep your existing one if you donā€™t want to merge your mods to the new flyout-menu.xml

The new advisory code is

<div id="main-copy">
    
<?php // insert desired warning box at top of page

  if(isset($SITE['NWSalertsCodes']) and count($SITE['NWSalertsCodes']) > 0) {
	// Add nws-alerts alert box cache file
	include_once("nws-alerts-config.php");
	include($cacheFileDir.$aboxFileName);
	// Insert nws-alerts alert box
	echo $alertBox;
	?>
<script type="text/javascript" src="nws-alertmap.js"></script>
<?php
  }
?>
<div class="column-dark">

it would replace your code in your current wxindex.php of

<div id="main-copy">
    
<?php // insert desired warning box at top of page

  if(isset($SITE['NWSalertsCodes']) and count($SITE['NWSalertsCodes']) > 0) {
	// Add nws-alerts alert box cache file
	include_once("nws-alerts-config.php");
	include($cacheFileDir.$aboxFileName);
	// Insert nws-alerts alert box
	echo $alertBox;
	?>
<script type="text/javascript" src="nws-alertmap.js"></script>
<?php
	  
  } else { // use atom scripts of choice
	if ($useTopWarning) {
	  include_once("atom-top-warning.php");
	} else {
	 print "      <div class=\"advisoryBox\">\n";
	 $_REQUEST['inc'] = 'y';
	 $_REQUEST['summary'] = 'Y';
	 include_once("atom-advisory.php");
	 print "      </div>\n";
	}
  }
?>
<div class="column-dark">

Be sure to upload check-fetch-times.php now to get the best results from a check-fetch-times.php?show=versions (and add additional diagnostic capabilities)

Ken,

I completed this to the best of my knowledge. I only customized:

news-alerts-config.php and Settings-weather.php. Oh the Windex.php file I (hopefully) made the changes you gave correctly.

The rest I copied from the zip file

Now my webpage doesnā€™t launch at all - totally blank:

Screenshot of my directory to confirm I put the JPC and mooning in the right place

Any thoughts on how to proceed?

I guess I could put all the files back and confirm it comes up then load parts of the files.

OH and here is a copy of the new check status page

in your index.php, just delete

  } else { // use atom scripts of choice
    if ($useTopWarning) {
      include_once("atom-top-warning.php");
    } else {
     print "      <div class=\"advisoryBox\">\n";
     $_REQUEST['inc'] = 'y';
     $_REQUEST['summary'] = 'Y';
     include_once("atom-advisory.php");
     print "      </div>\n";
    }

and you should be fine.

However, you may have a syntax error in nws-alerts-config.php that is preventing your site from loading.

Ken, I carefully deleted what you suggested, still same thing

Tried to attach index and windex, but it wont let me. If you want I can email

for the news file I only changed 2 lines - location and tz

Wait I changed this line too: - should i have left this alone
// location info for map pin (V1.05)
$myLat = ā€˜33.810249ā€™; // overridden by $SITE[ā€˜latitudeā€™] in Saratoga template
$myLon = '-84.348663; // overridden by $SITE[ā€˜longitudeā€™] in Saratoga template
$myLoc = ā€˜Atlantaā€™; // overridden by $SITE[ā€˜citynameā€™] in Saratoga template

You donā€™t have to change nws-alerts-config.php at allā€¦ the Settings.php entries override the ones you changed. I suggest replacing your nws-alerts-config.php with the distributed version and see if your site comes back up.

Or replace

$myLon = '-84.348663; // overridden by $SITE[ā€˜longitudeā€™] in Saratoga template

with a correct syntax entry of

$myLon = '-84.348663'; // overridden by $SITE[ā€˜longitudeā€™] in Saratoga template

That missing single-quote is causing the PHP error in nws-alerts-config.php

Ken, I swear I took that single quote out and it still doesnā€™t work.

$myZC = array(
ā€œAtlanta|GAZ045|GAC089ā€,
// ā€œSanta Cruz Mtns|CAZ512|CAC081|CAC085|CAC087ā€,
ā€œAtlanta|GAZ045|GAC089ā€,
// ā€œMonterey|CAZ530|CAC053ā€,
// ā€œSouth/East Bay|CAZ508|CAC081ā€,
// ā€œSan Mateo Coast|CAZ509|CAC081ā€,
// ā€œSan Francisco|CAZ006|CAC075ā€
);

Btw the only reason im modifying it because the readme file said to do so

Iā€™m SORRY to be a pain

You were supposed to add one, between 3 and ;