home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Freeware / Programare / groupoffice-com-2.01 / modules / email / attachment.php < prev    next >
Encoding:
PHP Script  |  2004-03-08  |  1.8 KB  |  56 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. $GO_SECURITY->authenticate();
  15. $GO_MODULES->authenticate('email');
  16.  
  17. require($GO_CONFIG->class_path."imap.class.inc");
  18. require($GO_CONFIG->class_path."email.class.inc");
  19. require($GO_CONFIG->class_path.'filetypes.class.inc');
  20. $filetypes = new filetypes();
  21. $mail = new imap();
  22. $email = new email();
  23.  
  24. $account = $email->get_account($_REQUEST['account_id']);
  25.  
  26. if ($mail->open($account['host'], $account['type'],$account['port'],$account['username'],$GO_CRYPTO->decrypt($account['password']), $_REQUEST['mailbox']))
  27. {
  28.     $file = $mail->view_part($_REQUEST['uid'], $_REQUEST['part'], $_REQUEST['transfer'], $_REQUEST['mime']);
  29.     $mail->close();
  30.  
  31.     $filename = smartstrip($_REQUEST['filename']);
  32.     $extension = get_extension($filename);
  33.     $type = $filetypes->get_type($extension);
  34.     $browser = detect_browser();
  35.  
  36.     header('Content-Type: '.$type['mime']);
  37.     //header('Content-Length: '.strlen($file));
  38.     header('Expires: '.gmdate('D, d M Y H:i:s') . ' GMT');
  39.     if ($browser['name'] == 'MSIE')
  40.     {
  41.         header('Content-Disposition: inline; filename='.$filename);
  42.         header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  43.         header('Pragma: public');
  44.     }else
  45.     {
  46.         header('Pragma: no-cache');
  47.         header('Content-Disposition: attachment; filename='.$filename);
  48.     }
  49.     header('Content-Transfer-Encoding: binary');
  50.     echo ($file);
  51. }else
  52. {
  53.     echo $strDataError;
  54. }
  55. ?>
  56.