home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Freeware / Programare / groupoffice-com-2.01 / modules / filesystem / download.php < prev    next >
PHP Script  |  2004-03-08  |  2KB  |  53 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. $GO_SECURITY->authenticate();
  16. $GO_MODULES->authenticate('filesystem');
  17.  
  18. require($GO_CONFIG->class_path.'filetypes.class.inc');
  19. require_once($GO_CONFIG->class_path.'filesystem.class.inc');
  20. $fs = new filesystem();
  21. $filetypes = new filetypes();
  22. $path = smartstrip($_REQUEST['path']);
  23. if ($fs->has_read_permission($GO_SECURITY->user_id, $path))
  24. {
  25.     $filename = basename($path);
  26.     $extension = get_extension($filename);
  27.  
  28.     $type = $filetypes->get_type($extension);
  29.  
  30.     $browser = detect_browser();
  31.  
  32.     header('Content-Type: '.$type['mime']);
  33.     header('Content-Length: '.filesize($path));
  34.     header('Expires: '.gmdate('D, d M Y H:i:s') . ' GMT');
  35.     if ($browser['name'] == 'MSIE')
  36.     {
  37.         header('Content-Disposition: attachment; filename='.$filename);
  38.         header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  39.         header('Pragma: public');
  40.     }else
  41.     {
  42.         header('Pragma: no-cache');
  43.         header('Content-Disposition: attachment; filename='.$filename);
  44.     }
  45.     header('Content-Transfer-Encoding: binary');
  46.     readfile($path);
  47. }else
  48. {
  49.     header('Location: '.$GO_CONFIG->host.'error_docs/401.php');
  50.     exit();
  51. }
  52. ?>
  53.