doSendfile() public static method

Send appropriate headers for sendfile support based on server.
public static doSendfile ( string $filename, string $type )
$filename string The full file path of the file to send.
$type string The MIME type of the file.
Example #1
0
<?php

/**
 * Copyright 2003-2015 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 Chuck Hagenbuch <*****@*****.**>
 */
require_once __DIR__ . '/../lib/Application.php';
Horde_Registry::appInit('ansel');
$image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage(Horde_Util::getFormData('image'));
$gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($image->gallery);
if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::READ)) {
    throw new Horde_Exception_PermissionDenied(_("Access denied viewing this photo."));
}
/* Sendfile support. Lighttpd < 1.5 only understands the X-LIGHTTPD-send-file header */
if ($conf['vfs']['src'] == 'sendfile') {
    /* Need to ensure the file exists */
    try {
        $image->createView('screen', Ansel::getStyleDefinition('ansel_default'), $GLOBALS['prefs']->getValue('watermark_auto') ? $GLOBALS['prefs']->getValue('watermark_text', '') : '');
    } catch (Ansel_Exception $e) {
        Horde::log($result, 'ERR');
        exit;
    }
    $filename = $injector->getInstance('Horde_Core_Factory_Vfs')->create('images')->readFile($image->getVFSPath('screen'), $image->getVFSName('screen'));
    Ansel::doSendfile($filename, $image->getType('screen'));
    exit;
}
$image->display('screen');