CrimsonGT
04-09-2010, 05:32
I do not take credit for this, I found it on srcds.com forums and was impressed so I decided to post it here. Full credit for the work goes to gussy over at srcds forums. It basically allows you to run a php script that will let you use different fast download URLs for different files. It was posted 2 years ago, but despite my endless hours of forum browsing I had never seen it.
Original thread can be found here...
http://forums.srcds.com/viewtopic/4464
<?php
/*
############################################# ################################### #
-gµssy sv_downloadurl multi server hack script
-version 1.0a
-this is not a hack in the bad sense, its a hack in that it makes srcds do things it doesnt normally want to.
-this is really only a proof of concept ATM. That said i've given it a quick test run and it seemed to work okay
-if you don't have experience with sv_downloadurl, dont even ATTEMPT to get this to run, familiarse yourself with srcds first.
-in order to use this, place this file in the directory below your files (or even in your base file directory, it shouldnt matter) and call it whatever you want.
-next point your sv_downloadurl variable in your server.cfg to <path><filename>.php?dl=
-that last bit is vitally important
-this essentially works, for those interested in PHP jediness, by accepting the file that srcdsis looking for as a GET argument, and then forwarding the page, via headers, to the file in questions. this allows files to be defined for different servers so that you arent stuck with a single sv_downloadurl location
-READ ALL NOTES, they are useful and contain some important information
-send any feedback (ie IF IT DONT WORK) via the srcds forums, or at angus dot moore at internode dot on dot net
*/
####################################
/* SERVER DEFINITIONS. SHOULD BE IN THE SAME FORMAT AS SV_DOWNLOADURL WOULD BE*/
####################################
//you can have as many different servers as you like
//this must be the default server. Any file on this server does not need its own file definition.
$location[1]="http://www.example.com/hl2mp";
//other server numbers.
$location[2]="http://www.example2.net/files";
$location[3]="http://www.example3.net/wtfeva";
####################################
/* FILE DEFINITIONS. ANY FILE THAT IS NOT ON THE DEFAULT SERVER MUST BE DEFINED HERE AS TO WHICH SERVER IT IS ON */
####################################
//these files must be in the form that srcds will search for them, ie /maps/map_name.bsp.bz2 orthe like
//VERY IMPORTANT - you MUST use bz2 for these files, as srcds will search for these first, and im pretty sure this script will break if you dont use bz2.
//that said im sure you could set it up to not use bz2, but why wouldnt you want to use bz2. its quicker.
//this is in the form $files["<file name and path>"]=<server number>
$files["/maps/aim_arena_b7.bsp.bz2"]=2;
$files["/sounds/quake/headshot.mp3.bz2"]=3;
//etc. you get the idea
###################################
//actual code - dont alter this unless you know what your doing
###################################
if($_GET['dl']) {
if(!isset($files[$_GET['dl']])) {
//defualt it to the main server
header("Location: " . $location[1] . $_GET['dl']);
} else {
//send it the new place
header("Location: " . $location[$files[$_GET['dl']]] . $_GET['dl']);
}
} else {
//feel free to alter the below code to whatever. this is just what i use if someone gets there by accident.
echo "<html>
<head>
<title>gµssy sv_downloadurl hack</title>
</head>
<body>
This is our file server. You shouldn't probably be here. Try <A href=\"http://www.mysite.com\">here</a> instead.<br><br>
Have a nice day!
</body>
</html>";
}
?>
Original thread can be found here...
http://forums.srcds.com/viewtopic/4464
<?php
/*
############################################# ################################### #
-gµssy sv_downloadurl multi server hack script
-version 1.0a
-this is not a hack in the bad sense, its a hack in that it makes srcds do things it doesnt normally want to.
-this is really only a proof of concept ATM. That said i've given it a quick test run and it seemed to work okay
-if you don't have experience with sv_downloadurl, dont even ATTEMPT to get this to run, familiarse yourself with srcds first.
-in order to use this, place this file in the directory below your files (or even in your base file directory, it shouldnt matter) and call it whatever you want.
-next point your sv_downloadurl variable in your server.cfg to <path><filename>.php?dl=
-that last bit is vitally important
-this essentially works, for those interested in PHP jediness, by accepting the file that srcdsis looking for as a GET argument, and then forwarding the page, via headers, to the file in questions. this allows files to be defined for different servers so that you arent stuck with a single sv_downloadurl location
-READ ALL NOTES, they are useful and contain some important information
-send any feedback (ie IF IT DONT WORK) via the srcds forums, or at angus dot moore at internode dot on dot net
*/
####################################
/* SERVER DEFINITIONS. SHOULD BE IN THE SAME FORMAT AS SV_DOWNLOADURL WOULD BE*/
####################################
//you can have as many different servers as you like
//this must be the default server. Any file on this server does not need its own file definition.
$location[1]="http://www.example.com/hl2mp";
//other server numbers.
$location[2]="http://www.example2.net/files";
$location[3]="http://www.example3.net/wtfeva";
####################################
/* FILE DEFINITIONS. ANY FILE THAT IS NOT ON THE DEFAULT SERVER MUST BE DEFINED HERE AS TO WHICH SERVER IT IS ON */
####################################
//these files must be in the form that srcds will search for them, ie /maps/map_name.bsp.bz2 orthe like
//VERY IMPORTANT - you MUST use bz2 for these files, as srcds will search for these first, and im pretty sure this script will break if you dont use bz2.
//that said im sure you could set it up to not use bz2, but why wouldnt you want to use bz2. its quicker.
//this is in the form $files["<file name and path>"]=<server number>
$files["/maps/aim_arena_b7.bsp.bz2"]=2;
$files["/sounds/quake/headshot.mp3.bz2"]=3;
//etc. you get the idea
###################################
//actual code - dont alter this unless you know what your doing
###################################
if($_GET['dl']) {
if(!isset($files[$_GET['dl']])) {
//defualt it to the main server
header("Location: " . $location[1] . $_GET['dl']);
} else {
//send it the new place
header("Location: " . $location[$files[$_GET['dl']]] . $_GET['dl']);
}
} else {
//feel free to alter the below code to whatever. this is just what i use if someone gets there by accident.
echo "<html>
<head>
<title>gµssy sv_downloadurl hack</title>
</head>
<body>
This is our file server. You shouldn't probably be here. Try <A href=\"http://www.mysite.com\">here</a> instead.<br><br>
Have a nice day!
</body>
</html>";
}
?>