File size: 1.62Kb
<?
if (!defined('SECURED'))
{
die("Unknown Error!");
}
$id=intval($_GET['id']);
$file=mysql_fetch_array(mysql_query("select * from files where id='".$id."';"));
if(mysql_affected_rows()==0)
{
head();
title('Ошибка!');
div('Ошибка!','b');
echo'Файл не существует либо был удален модератором!';
footer();
exit;
}
$filename=basename($file['filename']);
$ext=pathinfo($file['filename'],PATHINFO_EXTENSION);
if($ext=='jar')
{
if(isset($_GET['jar']))
{
$location = 'http://'.$config['fs_path'].'/'.$file['filename'];
} else
{
$location = 'http://'.$config['fs_path'].'/'.$file['jad'];
}
} else
{
$location = 'http://'.$config['fs_path'].'/'.$file['filename'];
}
header("Location: $location");
$file_id=':'.$id.':';
$filelist=explode('|',$user['dwl_filelist']);
if(count($filelist)>1000)
{
for($i=900;$i<1000;++$i)
{
$new_filelist[]=$filelist[$i];
}
$filelist=$new_filelist;
$user['dwl_filelist']=implode('|',$filelist);
}
if(!in_array($file_id, $filelist))
{
if(!empty($user['dwl_filelist']))
{
mysql_query("update `users` set `dwl_filelist`='".$user['dwl_filelist']."|$file_id' where id='".$user['id']."';");
} else
{
mysql_query("update `users` set `dwl_filelist`='$file_id' where id='".$user['id']."';");
}
mysql_query("update `users` set `dwl_files` = `dwl_files` + 1, `dwl_files_size` = `dwl_files_size` + ".filesize($file['filename'])." where `id`='".$user['id']."';");
mysql_query("update `files` set `downloads` = `downloads` + 1, `last_download` = '".time()."' where `id`='$id';");
}
exit;
?>