last update: Mon, 05 Sep 2011 17:17:24 +0000
  1. <?
  2. require_once("mysql_cfg.php");
  3. $id = intval($_GET['id']);
  4. $query = 'SELECT * FROM mapping_files WHERE `id` = "'.$id.'";';
  5. $data = mysql_query($query, $mysqlconnection);
  6. $row = mysql_fetch_array($data);
  7. $datei = $row['file'];
  8. $filetype = $row['filetype'];
  9. $dotpos = strrpos($datei,".");
  10. $data_type = strtolower(substr($datei,$dotpos,strlen($datei)));
  11. $images = array(".jpg", ".png", ".gif", ".bmp", ".jpeg");
  12. //heades:
  13. if (in_array($data_type,$images))
  14. {
  15. //image
  16. //echo $_SERVER['HTTP_USER_AGENT'];
  17. if (!preg_match("/firefox/i",$_SERVER['HTTP_USER_AGENT']))
  18. {
  19. //echo "no firefox";
  20. header( 'Content-disposition: atachment;filename='.urlencode($row['name']));
  21. }
  22. else
  23. {
  24. header( 'filename='.$row['name']);
  25. }
  26. }
  27. else
  28. {
  29. //no image
  30. header( 'Content-disposition: atachment;filename='.($row['name']));
  31. }
  32. //header( 'Content-disposition: atachment');
  33. header( 'Content-Length: ' . filesize( $datei ) );
  34. header( 'Connection: close');
  35. header( 'Content-Type: '.$filetype);
  36. //header("Content-Disposition: attachment; filename=".basename(@$datei));
  37. echo file_get_contents($datei);
  38. $query = 'UPDATE mapping_files SET downloads = downloads + 1 WHERE `id` = "'.$id.'";';
  39. $data = mysql_query($query, $mysqlconnection);
  40. ?>

goto line:
Compare with:
text copy window edit this code post new code