Exemple #1
0
 /**
  * If this MIME part can contain embedded MIME part(s), and those part(s)
  * exist, return a representation of that data.
  *
  * @return mixed  A Horde_Mime_Part object representing the embedded data.
  *                Returns null if no embedded MIME part(s) exist.
  */
 protected function _getEmbeddedMimeParts()
 {
     /* Get the data from the attachment. */
     try {
         if (!($tnef = $this->getConfigParam('tnef'))) {
             $tnef = Horde_Compress::factory('Tnef');
             $this->setConfigParam('tnef', $tnef);
         }
         $tnefData = $tnef->decompress($this->_mimepart->getContents());
     } catch (Horde_Compress_Exception $e) {
         $tnefData = array();
     }
     if (!count($tnefData)) {
         return null;
     }
     $mixed = new Horde_Mime_Part();
     $mixed->setType('multipart/mixed');
     reset($tnefData);
     while (list(, $data) = each($tnefData)) {
         $temp_part = new Horde_Mime_Part();
         $temp_part->setName($data['name']);
         $temp_part->setDescription($data['name']);
         $temp_part->setContents($data['stream']);
         /* Short-circuit MIME-type guessing for winmail.dat parts;
          * we're showing enough entries for them already. */
         $type = $data['type'] . '/' . $data['subtype'];
         if (in_array($type, array('application/octet-stream', 'application/base64'))) {
             $type = Horde_Mime_Magic::filenameToMIME($data['name']);
         }
         $temp_part->setType($type);
         $mixed->addPart($temp_part);
     }
     return $mixed;
 }
Exemple #2
0
        $currDir = $injector->getInstance('Horde_Core_Factory_TextFilter')->filter($currentDir, 'space2html', array('encode' => true, 'encode_all' => true));
        require CHORA_TEMPLATES . '/directory/dir.inc';
    }
    echo '</tbody>';
}
/* Display all of the files in this directory */
$readmes = array();
if ($fileList) {
    echo '<tbody>';
    foreach ($fileList as $currFile) {
        if ($conf['hide_restricted'] && Chora::isRestricted($currFile->getFileName())) {
            continue;
        }
        $lg = $currFile->getLastLog();
        $realname = $currFile->getFileName();
        $mimeType = Horde_Mime_Magic::filenameToMIME($realname);
        $currFile->mimeType = $mimeType;
        if (Horde_String::lower(Horde_String::substr($realname, 0, 6)) == 'readme') {
            $readmes[] = $currFile;
        }
        $icon = $injector->getInstance('Horde_Core_Factory_MimeViewer')->getIcon($mimeType);
        $author = Chora::showAuthorName($lg->getAuthor());
        $filerev = $lg->getRevision();
        $date = $lg->getDate();
        $log = $lg->getMessage();
        $attic = $currFile->isDeleted();
        $fileName = $where . ($attic ? '/' . 'Attic' : '') . '/' . $realname;
        $name = $injector->getInstance('Horde_Core_Factory_TextFilter')->filter($realname, 'space2html', array('encode' => true, 'encode_all' => true));
        $url = Chora::url('browsefile', $fileName, $branchArgs);
        $readableDate = Chora::readableTime($date);
        if ($log) {
Exemple #3
0
 /**
  * Get summary info for a MIME ID.
  *
  * @param string $id     The MIME ID.
  * @param integer $mask  A bitmask indicating what information to return:
  * <pre>
  * Always output:
  *   'type' = MIME type
  *
  * IMP_Contents::SUMMARY_BYTES
  *   Output: parts = 'bytes'
  *
  * IMP_Contents::SUMMARY_SIZE
  *   Output: parts = 'size'
  *
  * IMP_Contents::SUMMARY_ICON
  * IMP_Contents::SUMMARY_ICON_RAW
  *   Output: parts = 'icon'
  *
  * IMP_Contents::SUMMARY_DESCRIP
  *   Output: parts = 'description_raw'
  *
  * IMP_Contents::SUMMARY_DESCRIP_LINK
  *   Output: parts = 'description'
  *
  * IMP_Contents::SUMMARY_DOWNLOAD
  *   Output: parts = 'download', 'download_url'
  *
  * IMP_Contents::SUMMARY_IMAGE_SAVE
  *   Output: parts = 'img_save'
  *
  * IMP_Contents::SUMMARY_PRINT
  * IMP_Contents::SUMMARY_PRINT_STUB
  *   Output: parts = 'print'
  *
  * IMP_Contents::SUMMARY_STRIP
  *   Output: parts = 'strip'
  * </pre>
  *
  * @return array  An array with the requested information.
  */
 public function getSummary($id, $mask = 0)
 {
     $autodetect_link = false;
     $param_array = array();
     $this->_buildMessage();
     $part = array('bytes' => null, 'download' => null, 'download_url' => null, 'id' => $id, 'img_save' => null, 'size' => null, 'strip' => null);
     $mime_part = $this->getMimePart($id, array('nocontents' => true));
     if (!$mime_part) {
         return $part;
     }
     $mime_type = $mime_part->getType();
     /* If this is an attachment that has no specific MIME type info, see
      * if we can guess a rendering type. */
     if (in_array($mime_type, array('application/octet-stream', 'application/base64'))) {
         $mime_type = Horde_Mime_Magic::filenameToMIME($mime_part->getName());
         if ($mime_type == $mime_part->getType()) {
             $autodetect_link = true;
         } else {
             $mime_part = clone $mime_part;
             $mime_part->setType($mime_type);
             $param_array['ctype'] = $mime_type;
         }
     }
     $part['type'] = $mime_type;
     /* Is this part an attachment? */
     $is_atc = $mime_part->isAttachment();
     /* Get bytes/size information. */
     if ($mask & self::SUMMARY_BYTES || $mask & self::SUMMARY_SIZE) {
         $part['bytes'] = $size = $mime_part->getBytes();
         $part['size'] = $size > 1048576 ? sprintf(_("%s MB"), IMP::numberFormat($size / 1048576, 1)) : sprintf(_("%s KB"), max(round($size / 1024), 1));
     }
     /* Get part's icon. */
     if ($mask & self::SUMMARY_ICON || $mask & self::SUMMARY_ICON_RAW) {
         $part['icon'] = $GLOBALS['injector']->getInstance('IMP_Factory_MimeViewer')->getIcon($mime_type);
         if ($mask & self::SUMMARY_ICON) {
             $part['icon'] = Horde_Themes_Image::tag($part['icon'], array('attr' => array('title' => $mime_type)));
         }
     } else {
         $part['icon'] = null;
     }
     /* Get part's description. */
     $description = $this->getPartName($mime_part, true);
     if ($mask & self::SUMMARY_DESCRIP_LINK) {
         if (($can_d = $this->canDisplay($mime_part, self::RENDER_FULL)) || $autodetect_link) {
             $part['description'] = $this->linkViewJS($mime_part, 'view_attach', htmlspecialchars($description), array('jstext' => sprintf(_("View %s"), $description), 'params' => array_filter(array_merge($param_array, array('autodetect' => !$can_d)))));
         } else {
             $part['description'] = htmlspecialchars($description);
         }
     }
     if ($mask & self::SUMMARY_DESCRIP) {
         $part['description_raw'] = $description;
     }
     /* Download column. */
     if ($is_atc && $mask & self::SUMMARY_DOWNLOAD) {
         $part['download'] = $this->linkView($mime_part, 'download_attach', '', array('attr' => array('download' => $mime_part->getName(true) ?: $mime_part->getPrimaryType()), 'class' => 'iconImg downloadAtc', 'jstext' => _("Download")));
         $part['download_url'] = $this->urlView($mime_part, 'download_attach');
     }
     /* Display the image save link if the required registry calls are
      * present. */
     if ($mask & self::SUMMARY_IMAGE_SAVE && $GLOBALS['registry']->hasMethod('images/selectGalleries') && $mime_part->getPrimaryType() == 'image') {
         $part['img_save'] = Horde::link('#', _("Save Image in Gallery"), 'iconImg saveImgAtc', null, Horde::popupJs(IMP_Basic_Saveimage::url(), array('params' => array('muid' => strval($this->getIndicesOb()), 'id' => $id), 'height' => 200, 'width' => 450, 'urlencode' => true)) . 'return false;') . '</a>';
     }
     /* Add print link? */
     if (($mask & self::SUMMARY_PRINT || $mask & self::SUMMARY_PRINT_STUB) && $this->canDisplay($id, self::RENDER_FULL)) {
         $part['print'] = $mask & self::SUMMARY_PRINT ? $this->linkViewJS($mime_part, 'print_attach', '', array('css' => 'iconImg printAtc', 'jstext' => _("Print"), 'onload' => 'IMP_JS.printWindow', 'params' => $param_array)) : Horde::link('#', _("Print"), 'iconImg printAtc', null, null, null, null, array('mimeid' => $id)) . '</a>';
     }
     /* Strip Attachment? Allow stripping of base parts other than the
      * base multipart and the base text (body) part. */
     if ($mask & self::SUMMARY_STRIP && $id != 0 && intval($id) != 1 && strpos($id, '.') === false) {
         $part['strip'] = Horde::link(Horde::selfUrlParams()->add(array('actionID' => 'strip_attachment', 'imapid' => $id, 'muid' => strval($this->getIndicesOb()), 'token' => $GLOBALS['session']->getToken())), _("Strip Attachment"), 'iconImg deleteImg stripAtc', null, null, null, null, array('mimeid' => $id)) . '</a>';
     }
     return $part;
 }
Exemple #4
0
 /**
  * Convert a TNEF attachment into a multipart/mixed part.
  *
  * @param  integer|Horde_Mime_part $data  Either a mime part id or a
  *                                        Horde_Mime_Part object containing
  *                                        the TNEF attachment.
  *
  * @return Horde_Mime_Part  The multipart/mixed MIME part containing any
  *                          attachment data we can decode.
  */
 protected function _decodeTnefData($data)
 {
     $wrapper = new Horde_Mime_Part();
     $wrapper->setType('multipart/mixed');
     if (!$data instanceof Horde_Mime_Part) {
         $mime_part = $this->getMimePart($data);
     } else {
         $mime_part = $data;
     }
     $tnef_parser = Horde_Compress::factory('Tnef');
     try {
         $tnef_data = $tnef_parser->decompress($mime_part->getContents());
     } catch (Horde_Compress_Exception $e) {
         return false;
     }
     if (!count($tnef_data)) {
         return false;
     }
     reset($tnef_data);
     while (list(, $data) = each($tnef_data)) {
         $tmp_part = new Horde_Mime_Part();
         $tmp_part->setName($data['name']);
         $tmp_part->setDescription($data['name']);
         $tmp_part->setContents($data['stream']);
         $type = $data['type'] . '/' . $data['subtype'];
         if (in_array($type, array('application/octet-stream', 'application/base64'))) {
             $type = Horde_Mime_Magic::filenameToMIME($data['name']);
         }
         $tmp_part->setType($type);
         $wrapper->addPart($tmp_part);
     }
     return $wrapper;
 }
Exemple #5
0
    echo implode("\n", $VC->diff($fl, $vars->r1, $vars->r2, array('num' => $num, 'type' => $type))) . "\n";
    exit;
}
/* Human-Readable diff. */
$abbrev_r1 = $VC->abbrev($vars->r1);
$abbrev_r2 = $VC->abbrev($vars->r2);
$title = sprintf(_("Diff for %s between version %s and %s"), $injector->getInstance('Horde_Core_Factory_TextFilter')->filter($where, 'space2html', array('encode' => true, 'encode_all' => true)), $abbrev_r1, $abbrev_r2);
/* Format log entries. */
$log_messages = array();
foreach ($VC->getRevisionRange($fl, $vars->r1, $vars->r2) as $val) {
    $clog = $fl->getLog($val);
    if (!is_null($clog)) {
        $log_messages[] = $clog;
    }
}
$page_output->addScriptFile('stripe.js', 'horde');
Chora::header($title);
require CHORA_TEMPLATES . '/diff/header.inc';
$mime_type = Horde_Mime_Magic::filenameToMIME($fullname);
if (substr($mime_type, 0, 6) == 'image/') {
    /* Check for images. */
    $url1 = Chora::url('co', $where, array('r' => $vars->r1, 'p' => 1));
    $url2 = Chora::url('co', $where, array('r' => $vars->r2, 'p' => 1));
    echo "<tr><td><img src=\"{$url1}\" alt=\"" . htmlspecialchars($vars->r1) . '" /></td>' . "<td><img src=\"{$url2}\" alt=\"" . htmlspecialchars($vars->r2) . '" /></td></tr>';
} else {
    $view = $injector->createInstance('Horde_View');
    $view->addHelper('Chora_Diff_Helper');
    echo $view->diff($fl, $vars->r1, $vars->r2);
    echo $view->diffCaption();
}
$page_output->footer();
Exemple #6
0
 /**
  * Adds an attachment to the outgoing compose message.
  *
  * @param string $atc_file  Temporary file containing attachment contents.
  * @param integer $bytes    Size of data, in bytes.
  * @param string $filename  Filename of data.
  * @param string $type      MIME type of data.
  *
  * @return IMP_Compose_Attachment  Attachment object.
  * @throws IMP_Compose_Exception
  */
 protected function _addAttachment($atc_file, $bytes, $filename, $type)
 {
     global $conf, $injector;
     $atc = new Horde_Mime_Part();
     $atc->setBytes($bytes);
     /* Try to determine the MIME type from 1) the extension and
      * then 2) analysis of the file (if available). */
     if (strlen($filename)) {
         $atc->setName($filename);
         if ($type == 'application/octet-stream') {
             $type = Horde_Mime_Magic::filenameToMIME($filename, false);
         }
     }
     $atc->setType($type);
     if ($atc->getType() == 'application/octet-stream' || $atc->getPrimaryType() == 'text') {
         $analyze = Horde_Mime_Magic::analyzeFile($atc_file, empty($conf['mime']['magic_db']) ? null : $conf['mime']['magic_db'], array('nostrip' => true));
         $atc->setCharset('UTF-8');
         if ($analyze) {
             $ctype = new Horde_Mime_Headers_ContentParam('Content-Type', $analyze);
             $atc->setType($ctype->value);
             if (isset($ctype->params['charset'])) {
                 $atc->setCharset($ctype->params['charset']);
             }
         }
     } else {
         $atc->setHeaderCharset('UTF-8');
     }
     $atc_ob = new IMP_Compose_Attachment($this, $atc, $atc_file);
     /* Check for attachment size limitations. */
     $size_limit = null;
     if ($atc_ob->linked) {
         if (!empty($conf['compose']['link_attach_size_limit'])) {
             $linked = true;
             $size_limit = 'link_attach_size_limit';
         }
     } elseif (!empty($conf['compose']['attach_size_limit'])) {
         $linked = false;
         $size_limit = 'attach_size_limit';
     }
     if (!is_null($size_limit)) {
         $total_size = $conf['compose'][$size_limit] - $bytes;
         foreach ($this as $val) {
             if ($val->linked == $linked) {
                 $total_size -= $val->getPart()->getBytes();
             }
         }
         if ($total_size < 0) {
             throw new IMP_Compose_Exception(strlen($filename) ? sprintf(_("Attached file \"%s\" exceeds the attachment size limits. File NOT attached."), $filename) : _("Attached file exceeds the attachment size limits. File NOT attached."));
         }
     }
     try {
         $injector->getInstance('Horde_Core_Hooks')->callHook('compose_attachment', 'imp', array($atc_ob));
     } catch (Horde_Exception_HookNotSet $e) {
     }
     $this->_atc[$atc_ob->id] = $atc_ob;
     $this->changed = 'changed';
     return $atc_ob;
 }