PHP Scripts Camel Shopping Cart E-Commerce

Camel Shopping Cart is a fully customizable shopping cart system created in php with mysql database. It includes also a backend to manage the store. E-Commerce.

 

 

<?php
include('variables.php');

$connect = mysql_connect($host,$username,$password);
if (!$connect) {
 die('Could not connect: ' . mysql_error());
}
@mysql_select_db($database) or die( "Unable to select database");

$q = $_GET[q];
if (!$q)
{
$q = "0";
}

$query = "SELECT * FROM links WHERE link = '$q'";
$result = mysql_query($query);

$nums = mysql_num_rows($result);
 if($nums < 1)

 {
 echo "Unknown Product. Please contact <a href=\"mailto:$paypalemail\">$paypalemail</a>";
 }
 else
{

$row=mysql_fetch_assoc($result);

$filepath = $row["getfilename"];
$dltimes = $row["dltimes"];
$minusone = $dltimes-1;

if ($dltimes>0)
{

$location = 'myfiles/'. $filepath;

$changequery = "UPDATE links SET dltimes = '$minusone' WHERE link = '$q'";
$changeresult = mysql_query($changequery);

 $filename = 'dummy.zip';
 $filename = realpath($location);

 $file_extension = strtolower(substr(strrchr($filename,"."),1));

 switch ($file_extension) {
 case "pdf": $ctype="application/pdf"; break;
 case "exe": $ctype="application/octet-stream"; break;
 case "zip": $ctype="application/zip"; break;
 case "rar": $ctype="application/x-rar-compressed"; break;
 case "doc": $ctype="application/msword"; break;
 case "xls": $ctype="application/vnd.ms-excel"; break;
 case "ppt": $ctype="application/vnd.ms-powerpoint"; break;
 case "gif": $ctype="image/gif"; break;
 case "png": $ctype="image/png"; break;
 case "jpe": case "jpeg":
 case "jpg": $ctype="image/jpg"; break;
 default: $ctype="application/octet-stream";
 }

 if (!file_exists($filename)) {
 die("NO FILE HERE");
 }

 header("Pragma: public");
 header("Expires: 0");
 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
 header("Cache-Control: private",false);
 header("Content-Type: $ctype");


 header("Content-Disposition: attachment; filename=\"".$filepath. "\";");

 header("Content-Transfer-Encoding: binary");
 header("Content-Length: ".@filesize($filename));
 set_time_limit(0);
 @readfile("$filename") or die("File not found.");

}
else
{
echo "No more downloads";
}
}


?>

&amp;nbsp;

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>