PageRenderTime 29ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 0ms

/bxpress/trunk/files.php

http://bitcero-modules.googlecode.com/
PHP | 47 lines | 30 code | 6 blank | 11 comment | 3 complexity | 053fe3c3decf59e03a695336d764d7a0 MD5 | raw file
Possible License(s): LGPL-2.1
  1. <?php
  2. // $Id: files.php 819 2011-12-08 23:43:13Z i.bitcero $
  3. // --------------------------------------------------------------
  4. // bXpress Forums
  5. // An simple forums module for XOOPS and Common Utilities
  6. // Author: Eduardo Cort?Šs <i.bitcero@gmail.com>
  7. // Email: i.bitcero@gmail.com
  8. // License: GPL 2.0
  9. // --------------------------------------------------------------
  10. /**
  11. * @desc Archivo para procesar la entrega de archivos adjuntos
  12. */
  13. define('BB_LOCATION','files');
  14. include '../../mainfile.php';
  15. $id = rmc_server_var($_GET, 'id', 0);
  16. $topic = rmc_server_var($_GET, 'topic', 0);
  17. if ($id<=0){
  18. redirect_header('topic.php?id='.$topic, 2, __('No topic has been specified!','bxpress'));
  19. die();
  20. }
  21. $attach = new bXAttachment($id);
  22. if ($attach->isNew()){
  23. redirect_header('topic.php?id='.$topic, 2, __('Specified file does not exists!','bxpress'));
  24. die();
  25. }
  26. if (!file_exists(XOOPS_UPLOAD_PATH.'/bxpress/'.$attach->file())){
  27. redirect_header('topics.php', 2, __('Specified file does not exists!','bxpress'));
  28. die();
  29. }
  30. $ext = substr($attach->file(), strrpos($attach->file(), '.'));
  31. header('Content-type: '.$attach->mime());
  32. header('Cache-control: no-store');
  33. header('Expires: 0');
  34. header('Content-disposition: attachment; filename='.urlencode($attach->name().$ext));
  35. header('Content-Transfer-Encoding: binary');
  36. header('Content-Lenght: '.filesize(XOOPS_UPLOAD_PATH.'/bxpress/'.$attach->file()));
  37. header('Last-Modified: '.gmdate("D, d M Y H:i:s",filemtime(XOOPS_UPLOAD_PATH.'/bxpress/'.$attach->file())).'GMT');
  38. ob_clean();
  39. flush();
  40. readfile(XOOPS_UPLOAD_PATH.'/bxpress/'.$attach->file());
  41. exit();