Jump to content

Update Script Help


brandon88

Recommended Posts

I plan to be releasing some scripts and will update the version of the script on my website.

 

Users will be able to download the script and run it on there website. The latest version will be checked by checking my website and compared with the version of the user's script to see if its out of date.

 

I can't get it to work correctly.

 

On http://www.phpfusionmods.com/updates/check.php I have the latest version set to 1.4.

 

In the script the version is set at 1.3 so its obviously out of date. However, its showing that its up to date.

 

Please offer your support. My script is below.

 

<?php
$version = "1.3";
function new_version()
{
    $url = "http://www.phpfusionmods.com/updates/check.php";
    $url_p = @parse_url($url);
    $host = $url_p['host'];
    $port = isset($url_p['port']) ? $url_p['port'] : 80;
    $fp = @fsockopen($url_p['host'], $port, $errno, $errstr, 5);
    if (!$fp) return false;
    @fputs($fp, 'GET ' . $url_p['path'] . ' HTTP/1.1' . chr(10));
    @fputs($fp, 'HOST: ' . $url_p['host'] . chr(10));
    @fputs($fp, 'Connection: close' . chr(10) . chr(10));
    $response = @fgets($fp, 1024);
    $content = @fread($fp, 1024);
    $content = preg_replace("#(.*?)text/plain(.*?)$#is", "$2", $content);
    @fclose($fp);
    if (preg_match("#404#", $response)) return "Timeout";
    else  return trim(str_replace("X-Pad: avoid browser bug", "", $content));
}
$newversion = str_replace("X-Pad: avoid browser bug", "", new_version());
$new_version = $newversion != "Timeout" && intval(str_replace(".", "", $newversion)) >
    intval(str_replace(".", "", $version)) ? true : false;
if ($new_version)
{
    echo "Download the latest version <a href='http://www.phpfusionmods.com/' target='_blank'>here</a>. <b>v" .
        str_replace("X-Pad: avoid browser bug", "", $newversion) . "</b>";
} elseif ($newversion == "Timeout")
{
    echo "PHPFusionMods.com has timed out. Check for updates <a href='http://www.phpfusionmods.com/' target='_blank'>here</a>.";
} else
{
    echo ("You have the latest version");
}
?>

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.