View file download.php

File size: 884B
<?php
include 'inc/db.php';
$id=intval($_GET['id']);
$file=mysql_fetch_assoc(mysql_query("SELECT `name`, `ras`, `ds` FROM `obmen` WHERE `id` = '$id'"));
$hhost=str_ireplace('.', '_', $_SERVER['HTTP_HOST']);
$name=str_ireplace('.', '_', str_ireplace(',', '_', htmlspecialchars($file['name']))).'_('.$hhost.')';
$ras=htmlspecialchars($file['ras']);
if (!$_GET['id'])header('Location: /obmen.php');
header('Content-Type: '.$file['type']);
if (($ras=='jpg') || ($ras=='png') || ($ras=='gif') || ($ras=='bmp') || ($ras=='tif'))header('Content-Disposition: filename='.$name.$ras);
else
header('Content-Disposition: attachment; filename='.$name.$ras);
header('Accept-Ranges: bytes');
header("Content-length: ".filesize("obmen/$id.file"));
echo @file_get_contents("obmen/".$id.".file");
$q=($file['ds']+1);
mysql_query("UPDATE `obmen` SET `ds` = '$q' WHERE `id` = '$id'");
?>