home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Freeware / Programare / groupoffice-com-2.01 / modules / cms / download.php < prev    next >
PHP Script  |  2004-03-08  |  2KB  |  54 lines

  1. <?php
  2. /*
  3. Copyright Intermesh 2003
  4. Author: Merijn Schering <mschering@intermesh.nl>
  5. Version: 1.0 Release date: 08 July 2003
  6.  
  7. This program is free software; you can redistribute it and/or modify it
  8. under the terms of the GNU General Public License as published by the
  9. Free Software Foundation; either version 2 of the License, or (at your
  10. option) any later version.
  11. */
  12.  
  13. require("../../Group-Office.php");
  14. //load file management class
  15.  
  16. require($GO_CONFIG->class_path.'filetypes.class.inc');
  17. require($GO_CONFIG->class_path.'cms.class.inc');
  18. $cms = new cms();
  19. $filetypes = new filetypes();
  20.  
  21. $site = $cms->get_site($_REQUEST['site_id']);
  22. if ($site['acl_read'] > 0)
  23. {
  24.     $GO_SECURITY->authenticate();
  25. }
  26.  
  27. if ($site['acl_read'] == 0 || $GO_SECURITY->has_permission($GO_SECURITY->user_id, $site['acl_read']) || $GO_SECURITY->has_permission($GO_SECURITY->user_id, $site['acl_write']))
  28. {
  29.     if ($file = $cms->get_file($_REQUEST['file_id']))
  30.     {
  31.         $browser = detect_browser();
  32.  
  33.         header('Content-Type: '.$file['content_type']);
  34.         //header('Content-Length: '.$file['size']);
  35.         header('Expires: '.gmdate('D, d M Y H:i:s') . ' GMT');
  36.         if ($browser['name'] == 'MSIE')
  37.         {
  38.             header('Content-Disposition: inline; filename='.$file['name']);
  39.             header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  40.             header('Pragma: public');
  41.         }else
  42.         {
  43.             header('Pragma: no-cache');
  44.             header('Content-Disposition: attachment; filename='.$file['name']);
  45.         }
  46.         header('Content-Transfer-Encoding: binary');
  47.         echo $file['content'];
  48.     }
  49. }else
  50. {
  51.     header('Location: '.$GO_CONFIG->host.'error_docs/401.php');
  52.     exit();
  53. }
  54. ?>