Location: PHPKode > scripts > Download Tracker > kbdownload/kbdownload/index.php
<?php
include "config.php";
?>
<html>
<head>
  <title>KB Download PHP Script!</title>

</head>
<body>
<h1>Demo Download Script</h1>
<p>The demo here shows the downloading for files, and counts how many downloads has taken place in 
total, today, yesterday.</p>

<!--Table for the Download List-->	
<table width="100%" border="1">           
             
<tr>
<td>
<?php
$dtetdy= date("Y-m-d" , time());  
$montdy= date("m" , time());
$daytdy= date("d" , time());
$dteystdy= date("Y-m-d" , mktime(0,0,0,$montdy,$daytdy-1));
$weekdaytdy= date("w" , time());
$dteweek= date("Y-m-d" , mktime(0,0,0,$montdy,$daytdy-$weekdaytdy));
$dtemonth= date("Y-m-d" , mktime(0,0,0,$montdy,1));

$qrydownload="SELECT * FROM scrdownload";
$rsldownload=mysql_query($qrydownload);
$ndownload = mysql_num_rows($rsldownload);

for ($i=0; $i<$ndownload; $i++)
	{
$arrdownload =  mysql_fetch_row($rsldownload);
$downloaddte= date('Y-m-d',strtotime($arrdownload[2]));

$downloadtoday="0";	//Intialising
$downloadyesterday="0";	//Intialising
$downloadweek="0";	//Intialising
$downloadmonth="0"; //Intialising

//Code for Today
if($downloaddte!=$dtetdy)
{
$downloadtoday="0";
$downloadtdyupd = mysql_query ("UPDATE scrdownload SET 
downloadtdy='$downloadtoday' WHERE downloadid='$arrdownload[0]' ");

//Code for Yesterday
if($downloaddte==$dteystdy && $arrdownload[4]!='0')
{
$downloadyesterday=$arrdownload[4];
$downloadystdyupd = mysql_query ("UPDATE scrdownload SET 
downloadystdy='$downloadyesterday' WHERE downloadid='$arrdownload[0]' ");
}
elseif($downloaddte<$dteystdy)
{
$downloadyesterday="0";
$downloadystdyupd = mysql_query ("UPDATE scrdownload SET 
downloadystdy='$downloadyesterday' WHERE downloadid='$arrdownload[0]' ");
}
else
{
$downloadyesterday="$arrdownload[5]";
}

//Code for Week
if($downloaddte<$dteweek)
{
$downloadweek="0";
$downloadweekupd = mysql_query ("UPDATE scrdownload SET 
downloadweek='$downloadweek' WHERE downloadid='$arrdownload[0]' ");
}
else
{
$downloadweek="$arrdownload[6]";
}

//Code for Month
if($downloaddte<$dtemonth)
{
$downloadmonth="0";
$downloadmonthupd = mysql_query ("UPDATE scrdownload SET 
downloadmonth='$downloadmonth' WHERE downloadid='$arrdownload[0]' ");
}
else
{
$downloadmonth="$arrdownload[7]";
}

	
}
else
{
$downloadtoday=$arrdownload[4];	//Code for Today
$downloadyesterday="$arrdownload[5]"; //Code for Yesterday
$downloadweek="$arrdownload[6]"; //Code for Week
$downloadmonth="$arrdownload[7]"; //Code for Month
}

$downloadfilepath="files/$arrdownload[8]$arrdownload[9]";



		echo "Download <a href='download.php?downloadid=$arrdownload[0]'>$arrdownload[1]</a>
		($arrdownload[9]) ".filesize($downloadfilepath)." bytes<br>
		(Downloads - Total $arrdownload[3] | Today $downloadtoday 
		| Yesterday $downloadyesterday | This Week $downloadweek | This Month $downloadmonth)<br>";
	}

?>
&nbsp;</td>
</tr>           
</table>



</body>
</html>
Return current item: Download Tracker