Hi I am looking for the best way to get my script to "call home" and check for the current available version & if necessary tell the user that they need to update. I can do the rest if some clever person could point me in the direction of getting the variable from my server in some way. Thanks Rory
Have a file on your server that contains the version number. $version = file_get_contents("http://www.website.com/version.txt"); Then check if $version is newer than the current version. You could store each version with the same name, so you automatically have the filename you need to download. Then to update to a new version simply update version.txt. Make the client check on a cron job or everytime the script opens.
cURL and AJAX could be options but cURlL library may not always be installed and with JavaScript, there can be some cross-domain issues(I think). fopen() and file_get_contents() may be restricted and not allowed to open remote files! So what I suggest is that you include a small JavaScript on the client's system that gets its content from your server. 1.JavaScript on your clients server Look at the client's version that I have appended to the 'src' attribute <script type="text/javascript" src="remote_file_on_ur_server.php?client_version=1.5.15"></script> Code (javascript): 2. Remote file on your server "remote_file_on_ur_server.php" <?php $client_version=$_GET['client_version']; $latest_version='1.5.20';//edit this value when a new version is available if($client_version!=$latest_version) { echo 'alert(\'Dear Client, Please upgrade\')'; // or echo the javascript that you need } ?> PHP:
Okay, that looks good to me. Is it only echo I can use within the 'if' body? Or could I call a function in the local script with it somehow? How would $_SESSION variables work with this scenario, sounds difficult just asking about it :s
I doubt if you can call functions or other variables on your client's server because you don't have any access to their server memory.
Okay then, I can probably work with what you gave me - thanks a lot Just one more thing, all of that would work with SSL encryption, correct?