<?php
	// include configuration, language and functions
	@include("./indexfiles/config.php");
	@include($langdir.$lang_file);
	@include($incdir."functions.php");
	
	// save new access to log file
	if ($LOG_TRAFFIC) {
		store_file_acc_info(gethostbyaddr($_SERVER['REMOTE_ADDR']), date("D d M Y H:i:s"), $_GET['fname']);
	}

	// We'll be outputting a binary file
	header("Content-type: application/octet-stream");
	// It will be called ....
	$filename = basename($_GET['fname']);
	header("Content-Disposition: attachment; filename=".$filename);


	$not_to_be_dloaded = array(".htm", ".html", ".shtml", ".dhtml", ".php");
	$extensie = strrchr($_GET['fname'], ".");

	if (!in_array(substr($extensie, 1), $not_to_be_dloaded)) {
		// the source file is output
		readfile($_GET['fname']);
	} else {
		// message when downloading a forbidden file
		echo "$msg_not_allowed";
	}

?>
