<?php
include "includes/config.php";
include "includes/session.php";
include_once("includes/functions.php");

/*function call to restrict unauthorized file download*/

checkDownloadAuthorize();
	
	if($_GET['download_code'] != '')
	{
		
		$select_file_name = "SELECT vdigital_product_name FROM ".$tableprefix."digital_product 
							 WHERE vdigital_product_code = ".GetSQLValueString($_GET['download_code'],"text");
										 
							 
		$result_file_name = mysql_query($select_file_name) or die(mysql_error());
		$file_name_row = mysql_fetch_assoc($result_file_name);
		$filename = $file_name_row['vdigital_product_name'];
					

		// We'll be outputting the file
		header('Content-type: application/zip');
		
		// It will be called the file to download file
		header("Content-Disposition: attachment; filename=".$filename);
		
		// The source file
		readfile(SITE_URL."/digital_product/".$filename);
		
		//$update_download_count = "UPDATE ".$tableprefix."digital_product SET ndownload_count = ndownload_count + 1
								 // WHERE vdigital_product_code = ".GetSQLValueString($_GET['download_code'],"text");
		//mysql_query($update_download_count) or die(mysql_error());
 			
	}
		
		
		













?>