/usr/share/horde/gollem/view.php is in php-horde-gollem 3.0.10-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | <?php
/**
* Gollem view script.
*
* Copyright 1999-2016 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (GPL). If you
* did not receive this file, see http://www.horde.org/licenses/gpl.
*
* @author Max Kalika <max@horde.org>
* @author Chuck Hagenbuch <chuck@horde.org>
* @category Horde
* @license http://www.horde.org/licenses/gpl GPL
* @package Gollem
*/
require_once __DIR__ . '/lib/Application.php';
Horde_Registry::appInit('gollem', array(
'session_control' => 'readonly'
));
$vars = Horde_Variables::getDefaultVariables();
if ($vars->driver != Gollem::$backend['driver']) {
Horde::url('login.php')->add(array(
'backend_key' => $vars->driver,
'url' => Horde::selfUrl(true)
))->redirect();
}
try {
Gollem::changeDir();
} catch (Horde_Vfs_Exception $e) {
$notification->push($e);
}
$gollem_vfs = $injector->getInstance('Gollem_Vfs');
$stream = null;
$data = '';
try {
if (is_callable(array($gollem_vfs, 'readStream'))) {
$stream = $gollem_vfs->readStream($vars->dir, $vars->file);
} else {
$data = $gollem_vfs->read($vars->dir, $vars->file);
}
} catch (Horde_Vfs_Exception $e) {
Horde::log($e, 'NOTICE');
throw $e;
}
$mime_part = new Horde_Mime_Part();
$mime_part->setType(Horde_Mime_Magic::extToMime($vars->type));
$mime_part->setContents(is_resource($stream) ? $stream : $data);
$mime_part->setName($vars->file);
// We don't know better.
$mime_part->setCharset('US-ASCII');
$ret = $injector
->getInstance('Horde_Core_Factory_MimeViewer')
->create($mime_part)
->render('full');
reset($ret);
$key = key($ret);
try {
$size = $gollem_vfs->size($vars->dir, $vars->file);
} catch (Horde_Vfs_Exception $e) {
$size = null;
}
if (empty($ret)) {
$browser->downloadHeaders($vars->file, null, false, $size);
if (is_resource($stream)) {
fseek($stream, 0);
while ($buffer = fread($stream, 8192)) {
echo $buffer;
}
} else {
echo $data;
}
} elseif (strpos($ret[$key]['type'], 'text/html') !== false) {
$page_output->topbar = $page_output->sidebar = false;
$page_output->header();
echo $ret[$key]['data'];
$page_output->footer();
} else {
$browser->downloadHeaders($vars->file, $ret[$key]['type'], true, strlen($ret[$key]['data']));
echo $ret[$key]['data'];
}
|