View file upload/download.php

File size: 1.08Kb
<?php
include 'includes/functions.inc';
include 'includes/mysql.inc';

$id = intval($_GET['id']);

$query = @mysql_query("SELECT `type`, `url` FROM `files` WHERE `id` = '$id';");
if(@mysql_affected_rows() > 0)
{
	$array = @mysql_fetch_array($query);
	
	$name = substr($array['url'], 10, strlen($array['url']));
	
	$file = @fopen('all.dat', 'r');
	$all = intval(@fgets($file));
	@fclose($file);
	
	$file = @fopen('all.dat', 'w');
	@fwrite($file, $all + @filesize('files/'.$array['type'].'/'.$array['url']));
	@fclose($file);	

	@mysql_query("UPDATE `files` SET `clicks` = `clicks` + 1, `ltime` = '".time()."' WHERE `id` = '$id';");
		
	header('Content-type: '.$array['type'].'/*');
	header('Content-Length: '.@filesize('files/'.$array['type'].'/'.$array['url']));
	header('Content-Disposition: attachment; filename="'.$name.'";');
	readfile('files/'.$array['type'].'/'.$array['url']);
}
else
{
	?>
	Файла не существует;<br/>
	<br/>
	<img src='images/link.png' alt='&#187;'/> <a href='.'>На главную</a><br/>
	<?
	include 'includes/footer.inc';
}
?>