function AddDownLoad($id){
$connect_id=mysql_connect($GLOBALS["mysql_host"],$GLOBALS["mysql_username"],
$GLOBALS["mysql_password"])or die("Íå ìîãó ïîäêëþ÷èòüñÿ ê õîñòó");
mysql_select_db($GLOBALS["mysql_dbname"],$connect_id)or die("Íå ìîãó ïîäêëþ÷èòüñÿ ê ÁÄ");
$query="SELECT downloads_today,today_dl,downloads_week,downloads_month,downloads FROM programs WHERE id=$id";
$result=mysql_query($query,$connect_id);
$result=mysql_fetch_row($result);
$downloads=$result[4];
$downloads_today=$result[0];
$downloads_week=$result[2];
$downloads_month=$result[3];
$today=$result[1];
$time=time();
if($today==0){$today=$time;}
$downloads++;
if((int)date("Y",$today)==(int)date("Y",$time)&&(int)date("n",$today)==(int)date("n",$time)&&
(int)date("j",$today)==(int)date("j",$time)){$downloads_today++;}else{$downloads_today=1;}
if((int)date("Y",$today)==(int)date("Y",$time)&&(int)date("W",$today)==(int)date("W",$time))
{$downloads_week++;}else{$downloads_week=1;}
if((int)date("Y",$today)==(int)date("Y",$time)&&(int)date("n",$today)==(int)date("n",$time))
{$downloads_month++;}else{$downloads_month=1;}
$query="UPDATE programs SET downloads=$downloads,downloads_today=$downloads_today,today_dl=$time,
downloads_week=$downloads_week,downloads_month=$downloads_month WHERE id=$id";
mysql_query($query,$connect_id);
mysql_close($connect_id);
}
function AddPreview($id){
$connect_id=mysql_connect($GLOBALS["mysql_host"],$GLOBALS["mysql_username"],
$GLOBALS["mysql_password"])or die("Íå ìîãó ïîäêëþ÷èòüñÿ ê õîñòó");
mysql_select_db($GLOBALS["mysql_dbname"],$connect_id)or die("Íå ìîãó ïîäêëþ÷èòüñÿ ê ÁÄ");
$query="SELECT preview_today,today_pr,preview_week,preview_month,preview FROM programs WHERE id=$id";
$result=mysql_query($query,$connect_id);
$result=mysql_fetch_row($result);
$preview=$result[4];
$preview_today=$result[0];
$preview_week=$result[2];
$preview_month=$result[3];
$today=$result[1];
$time=time();
if($today==0){$today=$time;}
$preview++;
if((int)date("Y",$today)==(int)date("Y",$time)&&(int)date("n",$today)==(int)date("n",$time)&&
(int)date("j",$today)==(int)date("j",$time)){$preview_today++;}else{$preview_today=1;}
if((int)date("Y",$today)==(int)date("Y",$time)&&(int)date("W",$today)==(int)date("W",$time))
{$preview_week++;}else{$preview_week=1;}
if((int)date("Y",$today)==(int)date("Y",$time)&&(int)date("n",$today)==(int)date("n",$time))
{$preview_month++;}else{$preview_month=1;}
$query="UPDATE programs SET preview=$preview,preview_today=$preview_today,today_pr=$time,
preview_week=$preview_week,preview_month=$preview_month WHERE id=$id";
mysql_query($query,$connect_id);
mysql_close($connect_id);
}