ccrevcypsys Posted August 9, 2007 Share Posted August 9, 2007 <?php ob_start(); include_once("includes/ini.inc.php"); include_once("includes/global.inc.php"); // initiate db class include_once("classes/db.inc.php"); $db = new db(); include_once("includes/functions.inc.php"); $config = fetchDbConfig("config"); $query = "SELECT * FROM ".$glob['dbprefix']."CubeCart_Downloads INNER JOIN ".$glob['dbprefix']."CubeCart_inventory ON ".$glob['dbprefix']."CubeCart_Downloads.productId = ".$glob['dbprefix']."CubeCart_inventory.productId WHERE cart_order_id = ".$db->mySQLSafe(base64_decode($_GET['oid']))." AND ".$glob['dbprefix']."CubeCart_Downloads.productId = ".$db->mySQLSafe($_GET['pid'])." AND accessKey = ".$db->mySQLSafe($_GET['ak'])." AND noDownloads<".$config['dnLoadTimes']." AND expire>".time(); $download = $db->select($query); if($download == TRUE){ if(eregi("ftp://",$download[0]['digitalDir']) || eregi("http://",$download[0]['digitalDir']) || eregi("https://",$download[0]['digitalDir'])){ $record['noDownloads'] = "noDownloads + 1"; $where = "cart_order_id = ".$db->mySQLSafe(base64_decode($_GET['oid']))." AND productId = ".$db->mySQLSafe($_GET['pid'])." AND accessKey = ".$db->mySQLSafe($_GET['ak']); $update = $db->update($glob['dbprefix']."CubeCart_Downloads", $record, $where); header("Location: ".$download[0]['digitalDir']); exit; } else { $record['noDownloads'] = "noDownloads + 1"; $where = "cart_order_id = ".$db->mySQLSafe(base64_decode($_GET['oid']))." AND ".$glob['dbprefix']."CubeCart_Downloads.productId = ".$db->mySQLSafe($_GET['pid'])." AND accessKey = ".$db->mySQLSafe($_GET['ak']); $update = $db->update($glob['dbprefix']."CubeCart_Downloads", $record, $where); if( $download[0]['type']=='Album'){ $query = "SELECT * FROM ".$glob['dbprefix']."album_files where albumId='".$_GET['pid']."' ORDER BY title ASC"; $results = $db->select($query); $files=''; if($results==TRUE) { for($i=0; $i<count($results); $i++){ $files.=$results[$i]['path']." "; } } $rand=rand(1,1000000); $comm="tar -cvf tmp/album".$rand.".tgz ".$files; $return=system($comm); if("tmp/album".$rand.".tgz") $download[0]['digitalDir']="tmp/album".$rand.".tgz"; ob_clean(); header("location:"."tmp/album".$rand.".tgz"); } header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: application/octet-stream"); header("Content-Length: " . filesize($download[0]['digitalDir'])); $filename = explode("/",$download[0]['digitalDir']); $parts = count($filename); header("Content-Disposition: attachment; filename=".$filename[$parts-1]); function readfile_chunked ($filename) { $chunksize = 1*(1024*1024); // how many bytes per chunk $buffer = ''; $handle = fopen($filename, 'rb'); if ($handle === false) { return false; } while (!feof($handle)) { $buffer = fread($handle, $chunksize); print $buffer; } return fclose($handle); } readfile_chunked($download[0]['digitalDir']); exit; } } else { header("Location: index.php?act=dnExpire"); exit; } ?> Here is the code. Now what I need to know is why it is not downloading the file. And its only downloading a .php file with nothing in it. WTF. somone please help its urgent. Link to comment https://forums.phpfreaks.com/topic/64110-help-with-downloadphp-plz/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.