Forum Moderators: coopster

Message Too Old, No Replies

checking for remote updates

download remote check status

         

TDarksword

7:41 am on May 11, 2004 (gmt 0)

10+ Year Member



What I want to do is create a script that checks if there is an update to some data on a remote site. If there is then it needs to run a script to download it. I already have the script to download it so its just the checking script i need.

The process I want to run through is as follows:-

(pseudo code)

Check last updated time (stored in Unix timestamp format in a file lastupdated.txt)
if current time - last updated time > 1hour (the remote server is updated about once an hour) or lastupdated.txt does not exist.
check if an updating file exists (this file is created when the next part of the script runs to make sure multiple people dont start the script off)
if yes
display updating.gif
else
check if theres an update to download on remote server (compare local status.txt with remote status.txt found at [example.com...]
if no
echo "Data last updated at (time from lastupdate.txt)"
else if yes
create updating.txt
d/l update
d/l status.txt
do data transformations
update lastupdate.txt
delete updating.txt
else if error with remote file
echo "error updating data. remote server unavailable"
echo "Data last updated at (time from lastupdate.txt)"
endif
endif
else
echo "Data last updated at (time from lastupdate.txt)"
endif
else
echo "Data last updated at (time from lastupdate.txt)"
endif

NOTE. The script section in red needs to be run as an uniterruptable script (ie closing the webpage doesnt stop the script). I'm not sure if this can be done without doing it to the whole script.
(damned indent loss:/)

[edited by: jatar_k at 3:58 pm (utc) on May 11, 2004]
[edit reason] generalized url [/edit]

Timotheos

3:38 pm on May 11, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There's an example in the user notes for filemtime [php.net] that shows how to check a remote file's modified time.

TDarksword

8:30 pm on May 11, 2004 (gmt 0)

10+ Year Member



ahh thankyou:) heh thought there would be a simple function to do this somewhere but couldnt find it:)