[Half-Life AMXX] / content_server / content_server.php Repository:
ViewVC logotype

View of /content_server/content_server.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 45 - (download) (annotate)
Sat Oct 16 23:55:40 2010 UTC (13 years, 6 months ago) by ian
File size: 1058 byte(s)
Fixed content_server.sma to work on first map load.
Added content_server.php and .htaccess files to be used in combination with content_server.sma
<?php
$file_chmod = 0666;
$res_dir = '../content/';

//requested resource
$res = $_GET['res'];
//current game server map
$map = $_GET['map'];
//auth hash
$key = $_GET['key'];
//auth hash time stamp
$time = $_GET['time'];
//server id
$sid = $_GET['sid'];

$res = ltrim( $res, '\\/' );
$f_name = basename( $res );
$res = $res_dir . $res;

if( file_exists( $res ) && !preg_match( '/.php$/', $res ) )
{
	//echo 'File ' . $res . ' . ' exists.';
	
	header( 'Content-type: application/octet-stream' );
	$f_size = filesize( $res );
	header( 'Content-Length: ' . $f_size );
	header( 'Content-Disposition: attachment; filename="' . $f_name . '"' );
	readfile( $res );
}
else
{
	header( 'HTTP/1.0 404 Not Found' );
	echo '<html><head><title>Not Found [404]</title></head><body><h1>Not Found</h1>The requested URL was not found on this server.</body></html>';
	
	$p_log = fopen( 'content_server.log', 'a+' );
	fwrite ( $p_log, "$map\t$res\t\t\t$sid\n" );
	//echo 'File ' . $res . ' does not exist.';
	chmod( 'content_server.log', $file_chmod );
	fclose( $p_log );
}

?>

Contact
ViewVC Help
Powered by ViewVC 1.0.4