Tides Processor Script

Updated 19 October 2008 v2.01
I’ve just released a tide processor php script. It’s designed to work with the tideprediction.html file that WD uploads to your site. This script will separate each day and it’s tides, so that you can place them on any page of your site and lay them out how ever you like.

[center]For example - laid out in cells…


[/center]

The script also gives the tides a more aesthetically pleasing date format, and includes moon phase icons. Even if you don’t have WD uploading a tide file to your site, you could use this script to fetch a WD tide file from another site on another server, but obviously with the permission of the site owner of course!

Given the last feature, I’m thinking of possibly developing an exchange system where WD users can exchange their tide info, and display other local tides via a drop down list, and maybe a search feature, so you can search by port. That’s just an idea, so if you might be interested in that please let me know.

Update:12 Oct 08 version 1.03 now includes the following extra features…
Will work with dates that have years in them as well as those that don’t
Will work with tides that do not include sun rise/set and moon rise/set as well as those that do
Will work with rising and falling tide format as well as standard high and low
Option to convert rising & falling format to standard high & low format
Days, months, high tide, low tide, rising & falling can all be translated to another language

The tides processor script is simple to install and use. You can get this, and other scripts, tips and stuff from [b]my site here[/b].

Hi

thx for a great script. I 've tried and It works ok at my site www.strandvejr.dj/wxtest1.php
and yet: If you take a look at the original tide file www.strandvejr.dk/tideprediction.html you will see that some data is missing.

The php script prints :

Thu 09 October
High Tide: 0200 0.1
Falling: 0408 -0.0
Low Tide: 0752 -0.2
Rising: 1057 0.0

and from the original file this data is missing

High Tide: 1415 0.1 Falling: 1704 -0.0 Low Tide: 2047 -0.2

How can I remove the data on falling and rise of tide - a replace it with high and low tide…

another thing:

If I want to do a translation from english to danish - any ideas how to do that.

The translation will be of Dayname - monthname - High tide - Low tide.

best

strandvejr

Hi strandvejr,
The script was designed for high tide and low tide only (UK format), because that’s what I’m used to. However, I can change it to suite other formats. I’ll update it to work with “rising & falling” format if that’s a common format - I’ve never seen that before. Or are you saying that you don’t want “rising & falling”, just high and low? I am going to develop the script more, and add more options to it, so your feedback is useful!

As far as translations go, I will build that in as an option too. So that you can add your own translations for the words. I hadn’t thought of that! So thanks.

Hi

Great - looking forward to updates of the script…

Yes - I dont want the rise and falling datas - just the high and low tide datas.

Thanks for your work - much appreciated.

best

strandvejr

Great script. Thank you.
I needed to tweak the script a bit to get it to work for me because I generate my tideprediction.txt outside WD[1] and the format is a little different - but it was easy enough to understand your logic and adapt it.

The result is at http://www.isleofskyeweather.org.uk/24elgol/wxtides.php

[1] When set for auto, WD likes to calculate the page at a time when my computer isn’t usually on, otherwise I’d be more than happy to use the WD facility.

I’ve run into a wee problem.
I’ve uploaded the files, set the PHP code on the page and all I’ve getting is the “Tide data is being updated. Please refresh the page.”

I know I can’t go that far wrong so here are my settings:

//   Set the server path to your tideprediction.html file                       //
$tidefile = "/html/hebrides-photos.com/weather";                                //
//                                                                              //
//   Set the URL to the moon icons - no trailing slash                          //
$moonimg = "/tides_processor/icons";    

The server settings for the tideprediction.html file are correct, according to my server, and the tideprediction.html file is on the server here.
Oh, and here’s the page I’m trying to get it to work on.
Any ideas as to what I could try?

Cheers,

Martin.

I've uploaded the files, set the PHP code on the page and all I've getting is the "Tide data is being updated. Please refresh the page."

I’m getting the same message on my site. Looks like it will be a great script though, I like how your data looks!

Regards,

Jack

Martin, you need to enter the full server path to your tide file, including the name of the tide file which is normally tideprediction.html. The full server path will normally start with /home/ eg.

/home/username/public_html/.......
or
/home/username/www/......

Basically you get that message if the tide file can not be found at the location you specified.

If you copy and paste the following code into a file, save it as path.php, and upload it to the same directory where your tide file is, it should give you the full server path.

<?php echo dirname(__FILE__);?>

then adding /tideprediction.html on the end will be what the script is asking for.

I had the same problem, initially.
Rather than use the full internal server path, I used a relative path

$tidefile = "./tideprediction.txt";

i.e. telling the script to look in the same folder that it is in.

N.B. My file is called tideprediction.txt rather than the usual tideprediction.html, but I’m sure you spotted that!

Thanks guys,
I tried both ways and get the same result, a blank page.
When I look at the source it doesn’t seem to have parsed anything.

I have the tidegraph.gif image at the top of the html page, could at be causing a problem?

The tide image should make no difference. I did notice in your original setup;

$tidefile = "/html/hebrides-photos.com/weather";

you did not have the tide file at the end i.e …/weather/tideprediction.html

If you have the script and tideprediction.html in your weather directory then as skyewright said, you can use a relative path, which would be;

"./tideprediction.html"

Note the “.” before the “/”

Budgie, also, if you are completely sure you have got the path right, and it’s still not working, we’ll make sure php is setup on your server to support the method of getting the file contents.

Copy the following code, and past it in a file. Name the file test.php, upload it, and open it in your browser.


<?php
if (ini_get('allow_url_fopen') == "1")
{
echo "Test passed ok!";
}else{
echo "Test failed. PHP is not setup to support this on your server.";
}
?>

Let me know the result.

Hi Guys,

Tried all the suggestions above with no luck also. The test.php worked OK but I still get a blank page.

Regards,

Jack

The PHP side is fine, the whole site is PHP. :wink:
Which PHP version has this been written for? I’m using PHP4 on my server at the moment so it maybe that I need PHP5?
I’ve used both the full server address, including the file name, and the relative path and as nothing is showing on the page when the correct path is put in then I’m assuming that the script is seeing the html file but can’t parse it for some reason.

Jack, which version of PHP are you using on your server?

Jack, which version of PHP are you using on your server?

Using 4 also Martin.

Jack

We may have to take the plunge into PHP5 and hope all the older code works. :smiley:

It’s not the version of php which may not support the feature (this script should work on php 4 and 5), but the way php is setup on the server via the php ini. Your host may have php setup differently which has some features enabled, and some disabled etc.

As you are getting a blank page, and not the message saying to refresh the page, that would suggest that your path is correct, and as you say, for some reason the script isn’t reading your tide file.

I’m tinkering with the script at the moment, and I’ll put a backup method in for reading the file, in case the current method fails. The reason why I used the current method of getting the file is that it can read the file from an external server too, which I thought was more useful, but only if php is setup to support that method on your server, and as you are getting a blank page, I guess it’s not on yours.

Don’t worry, I will get it working for you!

In my case I had to tweak the script to handle a different date format because of not using the WD based file - but (as you’ve undoubtedly done) I’ve just taken a look at Martin’s tideprediction.html and it look ‘plain vanilla’.

While working out what was going on I found it handy to add a few ‘debug’ echos to the script, such as an one to show the string that is being used to search for the relevant day, e.g.

echo "<p>DEBUG data: ".date("l m-d", $time+(86400*$numb))."</p>";

then double checking that that string is the one expected and that it really does exist in tideprediction.html.

PS. While testing I also left the ‘old’ simple include of tideprediction.html in place so I had something handy to compare against and to check.

Yep, it’s plain Jane alright :lol:, I just put in an iframe on the page.
I didn’t mean to cause you extra work 35mm but thanks for doing it all the same. :thumbright:

No problem Budgie! If it’s broke it needs fixing. I will try to fix it today if I get time, and will need you to test it.