Page 1 of 1

Mandatory Update

Posted: Sat Aug 12, 2006 5:21 pm
by SidewinderX
I'm going to be releasing a script soon, and if i release an update I would like to make it mandatory. (but of course if the user knows php he can disable it, but it wouldnt be in his best interest)

My idea was to include this in the header file

Code: Select all

if($update == "YES"){
echo "You must upgrade to the latest version";
exit;
}
if $update is set to yes the script wouldnt run, only display "You must upgrade to the latest version." However my problem is how to set $update remotley. I tried something like this (lol) :oops:

Code: Select all

include("http://www.extreme-hq.com/include.php");
and have include.php had this

Code: Select all

<?php
$update = "NO"; //or YES
?>
but that didnt work. I suppose I could create a remote database connection, but im sure that introduces security issues. Is there any other way to do this?

Posted: Sat Aug 12, 2006 5:25 pm
by feyd
Requesting a remote php file will return the executed php only. The script you tested would output nothing for php to use. I wouldn't even go that sort of road.

What I would suggest is an Ajax-like query in the administrative pages (if you have any.)

Posted: Sat Aug 12, 2006 5:26 pm
by Benjamin
You could echo a yes or no in your remote script and call it using curl or include, but keep in mind not all servers allow remote includes or have curl installed.

Posted: Sat Aug 12, 2006 7:00 pm
by SidewinderX
what about reading from a remote text file?

Posted: Sat Aug 12, 2006 7:19 pm
by feyd
pretty much the same situation as astions has said.

Posted: Sat Aug 12, 2006 9:40 pm
by Ambush Commander
Just remember that you shouldn't perform the check on every page-request.

Posted: Sat Aug 12, 2006 9:55 pm
by Todd_Z
Also keep in mind that you need to have a version control system. It's not going to be easy as having a boolean.

Have some sort of system where the admin panel sends a query to the central server with a variable of the version.

http://example.com/needs_update.php?v=1.2.34

Where the 1.2.34 is the version of the script that wants to check whether it is the newest version or not.

Posted: Sun Aug 13, 2006 12:23 pm
by Tom420
I would do this way:

1) Have a text file available on the remote server containing just the file version of the new file.

A text file as the advantage that (as astions mentionned) it will work even if remote includes are disabled. The file could be generated from a PHP script if needed.

2) The local script would get the remote version file number at startup, but only once in a while. For exemple, once per day or once per week. That is because if the script checks for updates at every hit, it will 1) slow down the script a lot 2) overload the remote server if your script is popular.

On the oppsite to Todd_Z, I prefer the idea of the script deciding itself, from the version number received, if it needs to receive an update or not, instead of the remote server deciding if the script has to update or not. No particular reason beside I find that simpler, on first sight.

Hope this helps,
Tom :)