[ Index ]
 

Code source de vtiger CRM 5.0.2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/modules/Emails/ -> gotodownload.php (source)

   1  <?php
   2  /*********************************************************************************
   3  ** The contents of this file are subject to the vtiger CRM Public License Version 1.0
   4   * ("License"); You may not use this file except in compliance with the License
   5   * The Original Code is:  vtiger CRM Open Source
   6   * The Initial Developer of the Original Code is vtiger.
   7   * Portions created by vtiger are Copyright (C) vtiger.
   8   * All Rights Reserved.
   9   ********************************************************************************/
  10  
  11  $msgno = $_REQUEST['msgno'];
  12  $download = $_REQUEST['download'];
  13  $file = $_REQUEST['file'];
  14  
  15  $ServerName = "{localhost/imap:143/notls}INBOX"; // For a IMAP connection    (PORT 143)
  16  $UserName = "user";
  17  $PassWord = "password";
  18  $mbox = imap_open($ServerName, $UserName,$PassWord) or die("Could not open Mailbox - try again later!");
  19  
  20  if ($download == "1") 
  21  {
  22      echo "attribute=";
  23      print_r($att);
  24      $strFileName = $att[$file]->parameters[0]->value;
  25      $strFileType = strrev(substr(strrev($strFileName),0,4));
  26      $fileContent = imap_fetchbody($mbox,$msgno,$file+2);
  27  }
  28  
  29  /**     Function to download the File
  30   *    @param string $strFileType - File Type
  31   *    @param string $strFileName - File Name
  32   *    @param string $fileContents- File contents
  33  **/
  34  function downloadFile($strFileType,$strFileName,$fileContent) 
  35  {
  36      $ContentType = "application/octet-stream";
  37  
  38      if ($strFileType == ".asf") 
  39      $ContentType = "video/x-ms-asf";
  40      if ($strFileType == ".avi")
  41      $ContentType = "video/avi";
  42      if ($strFileType == ".doc")
  43      $ContentType = "application/msword";
  44      if ($strFileType == ".zip")
  45      $ContentType = "application/zip";
  46      if ($strFileType == ".xls")
  47      $ContentType = "application/vnd.ms-excel";
  48      if ($strFileType == ".gif")
  49      $ContentType = "image/gif";
  50      if ($strFileType == ".jpg" || $strFileType == "jpeg")
  51      $ContentType = "image/jpeg";
  52      if ($strFileType == ".wav")
  53      $ContentType = "audio/wav";
  54      if ($strFileType == ".mp3")
  55      $ContentType = "audio/mpeg3";
  56      if ($strFileType == ".mpg" || $strFileType == "mpeg")
  57      $ContentType = "video/mpeg";
  58      if ($strFileType == ".rtf")
  59      $ContentType = "application/rtf";
  60      if ($strFileType == ".htm" || $strFileType == "html")
  61      $ContentType = "text/html";
  62      if ($strFileType == ".xml") 
  63      $ContentType = "text/xml";
  64      if ($strFileType == ".xsl") 
  65      $ContentType = "text/xsl";
  66      if ($strFileType == ".css") 
  67      $ContentType = "text/css";
  68      if ($strFileType == ".php") 
  69      $ContentType = "text/php";
  70      if ($strFileType == ".asp") 
  71      $ContentType = "text/asp";
  72      if ($strFileType == ".pdf")
  73      $ContentType = "application/pdf";
  74  
  75      header ("Content-Type: $ContentType"); 
  76      header("Cache-Control: private");
  77      header("Content-Description: PHP Generated Data");
  78      header ("Content-Disposition: attachment; filename=$strFileName");    
  79      echo imap_base64($fileContent);
  80      #echo base64_decode($fileContent);
  81  }
  82  ?>


Généré le : Sun Feb 25 10:22:19 2007 par Balluche grâce à PHPXref 0.7