GunBound Patch Server Script

Zilch

Administrator
Staff member
A very simple script created by me to emulate the GunBound patch server API. This script is very old, talking late 2000s, so definitely no mysqli at this time...

This is the exact script used for GunBound Retro, and also includes an IP ban checker (which deliberately breaks the client from patching for whoever is IP banned. It's easy to get around it if you know what you're doing, but for those who don't know how computers work, they are screwed).

AppId should match what's in client, and directory should look like this:

Code:
/AppId/Version/File.xfs
So example...
Code:
fetch.gunbound.ca/701/2/07092021_root.xfs
...That would be on AppID = 701, version 2, and the name of the file (which my naming convention was typically based on date-createdso 07092021 means I created the file on July 9th, 2021, but his naming convention is not necessary.)

PHP:
<?php

header("Content-type: text/css; charset=UTF-8");
include("functions/config.php");

$chk_ip_sql = mysql_query("SELECT COUNT(*) FROM `BanLog` WHERE `Id`='".$_SERVER["REMOTE_ADDR"]."' AND `Reason`='IPBAN'") or die(mysql_error());
$chk_ip_sqlly = mysql_fetch_row($chk_ip_sql);

if($chk_ip_sqlly[0] > 0){
    die("Syntax Error");
} else {
$pos = strpos($_SERVER[QUERY_STRING],"&");
$app = trim(substr($_SERVER[QUERY_STRING],0,$pos)); //GET APP VERSION
$version = substr($_SERVER[QUERY_STRING], $pos + 1); //GET VERSION OF CLIENT
if (!is_numeric($version) || !is_numeric($app)) { //VERSION OF APP AND CLIENT
echo "Syntax Error";
die();
}

$noticeURL = "http://gunbound.ca/notice/";
$fileURL = "http://fetch.gunbound.ca/".$app."/";

//At this point, we have a valid URL to work with.

$query = mysql_query("SELECT * FROM `ApplicationSetting` WHERE `ApplicationId` = '$app'") or die(mysql_error());
$row = mysql_fetch_array($query);
if ($version >= $row["VersionLimit"]) { //No Updates -> Enter
echo "+".$noticeURL."\n";
echo "=".$fileURL."\n";
die();
} else if ($version <= $row["VersionLimit"]) { //Update -> Update
    echo "+".$noticeURL."\n";
    echo "=".$fileURL."\n";
$query = mysql_query("SELECT COUNT(*) AS `Files`, SUM(`FileSize`) AS `Size` FROM `FileInfo` WHERE `FileVersion`>$version") or die(mysql_error());
$row2 = mysql_fetch_array($query);
echo "~$row2[Files];$row2[Size];$row[VersionLimit]\n";
$query = mysql_query("SELECT * FROM FileInfo WHERE FileVersion>$version order by FileVersion ASC");
while ($row3 = mysql_fetch_array($query)) {
echo "$row3[Verb];$row3[LocalFileOrDir];$row3[RemoteFile];$row3[FileVersion];$row3[FileSize]\n";
}
} else { //Stay out.
echo "Syntax Error";
}
}
?>
 
Back
Top