Hi there Brad,
thanks very much for that. I'm having a probelm implementing it though.
moved it to a functions page, just to keep the admin index as clean as I can. The function seems to be operating ok, and I'm able to enable/disable it through the config settings ok, but when it's enabled, it tells me that the site is down.
1) The version script that it is supposed to check for is on the same server as what the script is running on.
2)Function:
/* This function checks the parent site for the latest version of the script
If it is enabled in the configuration settings. */
function update_check() {
global $prefix;
$query = "SELECT ver_current,ver_new,ver_check FROM ".$prefix."config";
$result = mysql_query($query) or die('MySQL error: ' . mysql_error() . '<hr/>' . $query);
while ($row = mysql_fetch_assoc($result)) {
$ver_current = $row['ver_current'];
$ver_new = $row['ver_new'];
$ver_check = $row['ver_check'];
}
echo("You are currently running Automonial version: (<b>$ver_current</b>). ");
if($ver_check == 1) {
$address = "www.roughingthesuspect.com/scripts/versions/automonial_version.php";
$fp = @fsockopen($address, 80, $errno, $errstr, 5);
if ($fp) {
$version = '';
$out = "GET / HTTP/1.1\r\n";
$out .= "Host: $address\r\n";
$out .= "Connection: Close\r\n\r\n";
fwrite($fp, $out);
while(!feof($fp)) {
$tmp = fgets($fp, 1024);
if(strpos($tmp, 'version') !== FALSE) {
$version = trim(substr($tmp, 9));
break;
}
}
fclose($fp);
if($version != $ver_current) {
echo("A new version has been released (v." . $version . ").
(<a href='http://www.roughingthesuspect.com/showtopic.php?id=4)' target='_blank'>download</a>)");
} else {
echo("You are running the latest version (v." . $ver_current . ").");
}
} else {
echo("The update site is currently down.");
}
}else{
echo("You have disabled the update check in your settings.");
}
}
When I run it, it simply tells me that the site is currently down.
I've tried both with and without "http://" at the front of the url.
I've tested the URL, and it echo's the version number correctly.
See anything that I've done wrong?
thanks,
json