Skip to content

Instantly share code, notes, and snippets.

@imjacobclark
Created May 12, 2012 23:57
Show Gist options
  • Save imjacobclark/2669769 to your computer and use it in GitHub Desktop.
Save imjacobclark/2669769 to your computer and use it in GitHub Desktop.
PHP Script Update Checker
<?php
/* Checks for updates using a remote CSV file
* The CSV must be like this
* versionnumber,versiondescription,type,downloadlink
* For the type, critical is 1 none critical is 0
* http://www.fusionstrike.com
*/
$version = "1"; //Version of the script, to check against CSV
$critical = FALSE; //Set Critical Variable to False
$update = FALSE; //Set None Critical to Fasle too
$url = "http://yourserver.com/version.csv"; //Link to your external CSV to check against
$fp = @fopen ($url, 'r') or print ('UPDATE SERVER OFFLINE'); //If the server is unreachable
$read = fgetcsv ($fp); //PHP fgetcsv
fclose ($fp); // Closes the connection
if ($read[0] > $version && $read[2] == "1") { $critical = TRUE; } // If its 1, set ciritcal to true
if ($read[0] > $version) { $update = TRUE; } // Anything other than 1 set update to true
if ($critical) {
print '<font color="red">There is a critical update available!</font><br/>You can get it at <a href="'.$read[3].'">'.$read[3].'</a> (Version: '.$read[1].') <br/><br/>';
}else if ($update){
print '<font color="green">There is a none critical update available!</font><br/>You can get it at <a href="'.$read[3].'">'.$read[3].'</a> (Version: '.$read[1].') <br/><br/>';
}
?>
2 Beta 0 http://fusionstrike.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment