-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathgetdemo.php
45 lines (36 loc) · 1.39 KB
/
getdemo.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
/**
* =============================================================================
* Fetch file demo file by demoid
*
* @author SteamFriends Development Team
* @version 1.0.0
* @copyright SourceBans (C)2007 SteamFriends.com. All rights reserved.
* @package SourceBans
* @link http://www.sourcebans.net
*
* @version $Id: getdemo.php 24 2007-11-06 18:17:05Z olly $
* =============================================================================
*/
require_once("init.php");
if(!isset($_GET['id']) || !isset($_GET['type']))
die('No id or type parameter.');
if(strcasecmp($_GET['type'], "B") != 0 && strcasecmp($_GET['type'], "S") != 0)
die('Bad type');
$id = (int)$_GET['id'];
$demo = $GLOBALS['db']->GetRow("SELECT filename, origname FROM `".DB_PREFIX."_demos` WHERE demtype=? AND demid=?;", array($_GET['type'], $id));
if(!$demo)
{
die('Demo not found.');
}
$demo['filename'] = basename($demo['filename']);
if(!in_array($demo['filename'], scandir(SB_DEMOS)) || !file_exists(SB_DEMOS . "/" . $demo['filename']))
{
die('File not found.');
}
header('Content-type: application/force-download');
header('Content-Transfer-Encoding: Binary');
header('Content-disposition: attachment; filename="' . $demo['origname'] . '"');
header("Content-Length: " . filesize(SB_DEMOS . "/" . $demo['filename']));
readfile(SB_DEMOS . "/" . $demo['filename']);
?>