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 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.
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.
[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?
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.
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.";
}
?>
The PHP side is fine, the whole site is PHP.
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?
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.
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.
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: