<?php session_start(); ?>
<?
include ("var.php");
?>
<?
include("stop.php");
?>
<?php
include('config.php');

$id = $_GET['id'];
$sql = mysql_query("SELECT * FROM fisiere where id = $id ");
$row = mysql_fetch_array($sql);
$file = $row['file'];
$ftype = $row['ftype'];
$dir = "../uploads/$ftype";
$dload = $row['download'] + 1;
$sz = $row["size"];
$upname = $row["user"];

if(isset($_SESSION['nume'])) {
      	$username = ''.$_SESSION['nume'].'';
$stare = "Download $file";

$profil="SELECT * from utilizatori where nume='$username'";
$profil2=mysql_query($profil) or die("Could not get users");
while($profil3=mysql_fetch_array($profil2))
{
$down = $profil3["download"]+$sz;  
$cpts = $profil3["ptdown"];
$ptdown = $ctps+2;

if(!$act){mysql_query("UPDATE utilizatori SET ptdown='$ptdown' WHERE nume='$upname'");} 
if(!$act){mysql_query("UPDATE utilizatori SET stare='$stare' WHERE nume='$username'");}
if(!$act){mysql_query("UPDATE utilizatori SET download='$down' WHERE nume='$username'");}
}}
$time = date("d.m.Y, H:i:s");
mysql_query("UPDATE fisiere SET lastaccess='$time' WHERE id='$id'");
mysql_query("UPDATE fisiere SET download = $dload WHERE id = $id ");
header("Location: $dir/$file");

?>