1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
<?php
/**
* $Horde: gollem/view.php,v 1.51.2.1 2006/01/01 21:28:47 jan Exp $
*
* Copyright 1999-2006 Charles J. Hagenbuch <chuck@horde.org>
* Copyright 1999-2006 Max Kalika <max@horde.org>
*
* See the enclosed file COPYING for license information (GPL). If you
* did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
*/
$session_control = 'readonly';
$no_compress = true;
@define('GOLLEM_BASE', dirname(__FILE__));
require_once GOLLEM_BASE . '/lib/base.php';
$actionID = Util::getFormData('actionID');
$driver = Util::getFormData('driver');
$filedir = Util::getFormData('dir');
$filename = Util::getFormData('file');
$type = Util::getFormData('type');
if ($driver != $GLOBALS['gollem_be']['driver']) {
$url = Util::addParameter(Horde::applicationUrl('login.php'), array('backend_key' => $driver, 'change_backend' => 1, 'url' => Horde::selfURL(true)), null, false);
header('Location: ' . $url);
exit;
}
$data = $GLOBALS['gollem_vfs']->read($filedir, $filename);
if (is_a($data, 'PEAR_Error')) {
$notification->push(sprintf(_("Access denied to %s"), $filename), 'horde.error');
header('Location: ' . Util::addParameter(Horde::applicationUrl('manager.php', true), 'actionID', $actionID));
exit;
}
/* Run through action handlers. */
switch ($actionID) {
case 'download_file':
$browser->downloadHeaders($filename);
echo $data;
break;
case 'view_file':
require_once 'Horde/MIME/Contents.php';
require_once 'Horde/MIME/Magic.php';
require GOLLEM_BASE . '/config/mime_drivers.php';
$mime = &new MIME_Part(MIME_Magic::extToMIME($type), $data);
$mime->setName($filename);
$contents = &new MIME_Contents($mime);
$body = $contents->renderMIMEPart($mime);
$type = $contents->getMIMEViewerType($mime);
$browser->downloadHeaders($mime->getName(true, true), $type, true, strlen($body));
echo $body;
break;
}
|