[ Index ]
 

Code source de vtiger CRM 5.0.2

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

title

Body

[fermer]

/modules/Webmails/ -> dlAttachments.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 Initial Developer of the Original Code is FOSS Labs.
   6    * Portions created by FOSS Labs are Copyright (C) FOSS Labs.
   7    * Portions created by vtiger are Copyright (C) vtiger.
   8    * All Rights Reserved.
   9    *
  10    ********************************************************************************/
  11  
  12  
  13  include ('config.php');
  14  require_once ('include/utils/UserInfoUtil.php');
  15  require_once ('include/utils/utils.php');
  16  require_once ('modules/Webmails/Webmail.php');
  17  require_once ('modules/Webmails/MailBox.php');
  18  
  19  global $MailBox;
  20  $MailBox = new MailBox($_REQUEST["mailbox"]);
  21  
  22  $mailid=$_REQUEST["mailid"];
  23  $num=$_REQUEST["num"];
  24  
  25  $email = new Webmail($MailBox->mbox,$mailid);
  26  $attachments=$email->downloadAttachments();
  27  $inline=$email->downloadInlineAttachments();
  28  
  29  if($num == "" || !isset($num) && count($attachments) >0 ) {
  30      echo "<table width='100%' cellspacing='1' cellpadding='0' border='0'><tr><td align='center'>There are ".count($attachments)." attachment(s) to choose from:</td></tr>";
  31  
  32      for($i=0;$i<count($attachments);$i++) {
  33          echo "<tr><td align='center'>".count($attachments).") &nbsp; <a href='index.php?module=Webmails&action=dlAttachments&mailid=".$mailid."&num=".$i."&mailbox=".$_REQUEST["mailbox"]."'>".$attachments[$i]["filename"]."</td></tr>";
  34      }
  35  
  36      echo "</table><br>";
  37      echo "<table width='100%' cellspacing='1' cellpadding='0' border='0'><tr><td align='center'>There are ".count($inline)." <b>inline</b> attachment(s) to choose from:</td></tr>";
  38  
  39      for($i=0;$i<count($inline);$i++) {
  40          echo "<tr><td align='center'>".count($inline).") &nbsp; <a href='index.php?module=Webmails&action=dlAttachments&mailid=".$mailid."&num=".$i."&inline=true&mailbox=".$_REQUEST["mailbox"]."'>".$inline[$i]["filename"]."</td></tr>";
  41      }
  42  
  43      echo "</table><br><br>";
  44  
  45  } elseif (count(attachments) == 0 && count($inline) == 0) {
  46      echo "<center><strong>No vtiger_attachments for this email</strong></center><br><br>";
  47  } else {
  48  
  49  global $root_directory;
  50  $save_path=$root_directory.'/modules/Webmails/tmp';
  51  if(!is_dir($save_path))
  52      mkdir($save_path);
  53  
  54  $user_dir=$save_path."/".$_SESSION["authenticated_user_id"];
  55  if(!is_dir($user_dir))
  56      mkdir($user_dir);
  57  
  58  if(isset($_REQUEST["inline"]) && $_REQUEST["inline"] == "true") {
  59      $fp = fopen($user_dir.'/'.$inline[$num]["filename"], "w") or die("Can't open file");
  60      fputs($fp, base64_decode($inline[$num]["filedata"]));
  61      $filename = 'modules/Webmails/tmp/'.$_SESSION['authenticated_user_id'].'/'.$inline[$num]['filename'];
  62  } else {
  63      $fp = fopen($user_dir.'/'.$attachments[$num]["filename"], "w") or die("Can't open file");
  64      fputs($fp, base64_decode($attachments[$num]["filedata"]));
  65      $filename = 'modules/Webmails/tmp/'.$_SESSION['authenticated_user_id'].'/'.$attachments[$num]['filename'];
  66  }
  67  fclose($fp);
  68  imap_close($MailBox->mbox);
  69  
  70  ?>
  71  <center><h2>File Download</h2></center>
  72  <META HTTP-EQUIV="Refresh"
  73  CONTENT="0; URL=<?php echo $filename;?>"
  74  ]"
  75  <?
  76  }
  77  ?>


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