Sample Configuration - nosoop/SM-DownloadPrefs GitHub Wiki
tl;dr Redirect a virtual directory structure containing a SteamID3 (account ID) and a file path to a PHP script, which then sends back a 307 Redirect or a 403 Forbidden to allow / prevent a client from downloading a file.
For this example, we'll assume the following:
sm_dprefs_downloadurl
is set tohttp://server.fastdl/dprefs/tf/$STEAMID
.- The game's base directory is
/path/to/game
. - The PHP script would be reachable via
http://server.fastdl/dprefs.php
on redirect. - The actual fastdownload files are located at
http://server.fastdl/tf
(subdirectories beingsound
,maps
, &c.). - An SQLite database holds the download preferences.
In SourceMod's databases.cfg
- Add a new database as follows:
"downloadprefs"
{
"driver" "sqlite"
"database" "downloadprefs"
}
In dprefs.conf.php:
- Set
$downloadDir
tohttp://server.fastdl/tf
. - Ensure the following lines are in the file so that the download filter is using SQLite:
$dbFile = dirname(__FILE__) . '/downloadprefs.sq3';
require_once(dirname(__FILE__) . '/dprefs_sq3.php');
$prefsFilter = new SQLiteDownloadFilter($dbFile);
If using lighttpd:
- Add this to
lighttpd.conf
:url.rewrite-once += ( "^/dprefs/tf/(\d+)/(.*)" => "/dprefs.php?steamid=$1&file=$2" )
- Force reload the server configuration.
If using nginx:
- Add something along the lines of the following.
nginx
has a lot more variation in how PHP can be handled, so I'll only cover the rewrite aspect of it here.
location /dprefs/tf {
rewrite ^/dprefs/tf/(\d+)/(.*)$ /dprefs.php?steamid=$1&file=$2;
# User-dependent PHP handling here...
}