DiamondDogHamm: Problem mit downloads großer Dateien (header)

Beitrag lesen

Ich poste euch mal den gesamten Code damit ihr auch seht was in Zeile 47 steht:

  
<?php  
require_once dirname(__FILE__) . "/db_config.php";  
  
$db_tabell = 'downloads_user';  // db table  
$db_tabel2 = 'downloads';  // db table  
  
$md5 = $_GET['id'];  
  
$db = mysql_connect($db_host,$db_user,$db_pass);  
mysql_select_db($db_name);  
  
$result = mysql_query("SELECT * FROM ".$db_tabell." WHERE  mail = '".$md5."'");  
  
$check = mysql_query("SELECT * FROM ".$db_tabell);  
while($check_row = mysql_fetch_array($check)){  
 if($check_row['date'] < time()) mysql_query("DELETE FROM ".$db_tabell." WHERE `mail`='".$check_row['mail']."'");  
}  
  
$found = mysql_query("SELECT count(*) FROM ".$db_tabell." WHERE  mail = '".$md5."'");  
if(mysql_result($found,0)==0){  
  die("Der aufgerufene Eintrag existiert leider nicht, oder die Gültigkeit ist abgelaufen!");  
}  
  
  
  
while($row = mysql_fetch_array($result)){  
  $date = $row['date'];  
  $download_id = $row['download_id'];  
}  
  
if($date < time()){  
  mysql_query("DELETE FROM ".$db_tabell." WHERE `mail`='".$md5."'");  
  
  echo "Der Downloadlink ist leider abgelaufen!";	  
}else{  
  mysql_query("UPDATE ".$db_tabell2." SET downloads=downloads+1 WHERE id = '".$download_id."'");  
  $result = mysql_query("SELECT * FROM ".$db_tabel2." WHERE  id = '".$download_id."'");  
	  
  while($row = mysql_fetch_array($result)){  
    $file = $row['rarname'];  
  }  
  
  $pfad = "downloads/files/";  
  
  //Download starten  
  if(file_exists($pfad.$file)){  
    ini_set('memory_limit','1024M');  
	  
    	  
    header('Pragma: public');  
    header('Expires: 0');  
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');  
    header('Content-Transfer-Encoding: binary');  
    header('Content-Disposition: attachment; filename="'.$file.'"');  
  
    header('Content-Type: application/zip');  
    header('Content-Length: '. filesize($pfad.$file));  
  
    readfile("http://".$_SERVER['HTTP_HOST']."/".$pfad.$file);  
	  
    $file = fopen($pfad.$file, "r");  
  
    while(!feof($file) and (connection_status()==0)) {  
      print(fread($file, 1024*8));  
      flush();  
    }  
    fclose($file);  
  
    die();  
  }else{  
    die("Die Datei ($file) konnte nicht gefunden werden!");  
  }  
  
}  
  
mysql_close($db);  
?>