I am tring to create a version indicator for my php script. But I'm not sure how to do it. This is how I invision it happening.
The php script would go to a website and download a small XML file (http://www.com/ver.xml). It would then take the one line which would be something like "The current version is 1.22" and display it on the page.
Any one know what code I would need to do this? thx.
Need help creating ver. indicator
Moderator: General Moderators
-
TheNinthPlayer
- Forum Newbie
- Posts: 2
- Joined: Mon Dec 01, 2003 3:53 pm
- mrvanjohnson
- Forum Contributor
- Posts: 137
- Joined: Wed May 28, 2003 11:38 am
- Location: San Diego, CA
You can even make it easier than that.
Create a simple text file on a web server somewhere that contains the current version (i.e. The current version is 1.22)
Then in you application create a currentVersion function that simply uses the [php_man]file command[/php_man] and echo the result something like
I think that would work, haven't tested it.
Then if you wanted to get fancy you could manipulate the array to check the version of the application the user is running and compare it to the current version and if there is a difference you can send it into another routine to help the user update.
Create a simple text file on a web server somewhere that contains the current version (i.e. The current version is 1.22)
Then in you application create a currentVersion function that simply uses the [php_man]file command[/php_man] and echo the result something like
Code: Select all
<?php
$version_array = file ('http://www.example.com/version.txt');
$version = implode ("", $version_array);
print $version;
?>Then if you wanted to get fancy you could manipulate the array to check the version of the application the user is running and compare it to the current version and if there is a difference you can send it into another routine to help the user update.
-
TheNinthPlayer
- Forum Newbie
- Posts: 2
- Joined: Mon Dec 01, 2003 3:53 pm
Thx. That worked but this brings a new problem that I probaly should have seen comming.
This script I write is sometimes used by people while offline (They have the nesscary php tools setup though). And if they are offline they cant access the file. As a result they would recieve the following statement
Can I use some kind of IF statment to have the script say something like "Can't Access this file right now" instead of having the user recieve and error message?
This script I write is sometimes used by people while offline (They have the nesscary php tools setup though). And if they are offline they cant access the file. As a result they would recieve the following statement
Code: Select all
Warning: file("http://www.com/ver.txt") - Success in /home/.bacci/run.inc on line 999
Warning: Bad arguments to implode() in /home/.bacci/run.inc on line 1000Comment on php.net in documentation of [php_man]file_exists[/php_man]
The @ will means that the function will not report an error regardless whether it worked correctly or not.If you are trying to check whether a remote file (or url) exists, you can open it and close it in the same statement.Code: Select all
<?php if (@fclose(@fopen("http://www.example.com", "r"))) { print("File exists."); } else { print("File does not exist."); } ?>