예제 #1
0
<?php

/// Copyright (c) 2004-2016, Needlworks  / Tatter Network Foundation
/// All rights reserved. Licensed under the GPL.
/// See the GNU General Public License for more details. (/documents/LICENSE, /documents/COPYRIGHT)
require ROOT . '/library/preprocessor.php';
if (empty($suri['value'])) {
    Respond::NotFoundPage();
}
if (!($attachment = getAttachmentByOnlyName($blogid, $suri['value']))) {
    Respond::NotFoundPage();
}
$fp = fopen(__TEXTCUBE_ATTACH_DIR__ . "/{$blogid}/{$attachment['name']}", 'rb');
if (!$fp) {
    Respond::NotFoundPage();
}
$fstat = fstat($fp);
if (!empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
    $modifiedSince = strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']);
    if ($modifiedSince && $modifiedSince >= $fstat['mtime']) {
        fclose($fp);
        header('HTTP/1.1 304 Not Modified');
        header('Connection: close');
        exit;
    }
}
ini_set('zlib.output_compression', 'off');
header('Content-Disposition: attachment; filename="' . rawurlencode(Utils_Unicode::bring($attachment['label'])) . '"');
header('Content-Transfer-Encoding: binary');
header('Last-Modified: ' . Timestamp::getRFC1123GMT($fstat['mtime']));
header('Content-Length: ' . $fstat['size']);
예제 #2
0
파일: ttml.php 프로젝트: ragi79/Textcube
function FM_TTML_getAttachmentBinder($filename, $property, $folderPath, $folderURL, $imageBlocks = 1, $useAbsolutePath = true, $bRssMode = false, $onclickFlag = false)
{
    $context = Model_Context::getInstance();
    $blogid = getBlogId();
    $path = "{$folderPath}/{$filename}";
    if ($useAbsolutePath) {
        $url = $context->getProperty('uri.service') . "/attach/{$blogid}/{$filename}";
    } else {
        $url = "{$folderURL}/{$filename}";
    }
    $fileInfo = getAttachmentByOnlyName($blogid, $filename);
    switch (Misc::getFileExtension($filename)) {
        case 'jpg':
        case 'jpeg':
        case 'gif':
        case 'png':
        case 'bmp':
            $bPassing = false;
            if (defined('__TEXTCUBE_MOBILE__') || defined('__TEXTCUBE_IPHONE__')) {
                if (!is_null(Setting::getBlogSettingGlobal("resamplingDefault"))) {
                    $waterMarkOn = Setting::getBlogSettingGlobal("waterMarkDefault", "no");
                    $exist = preg_match('/class="tt-watermark"/i', $property);
                    if ($waterMarkOn == 'yes' && $exist == 1) {
                        $bPassing = true;
                    }
                }
                if ($bPassing == false) {
                    return fireEvent('ViewAttachedImageMobile', "<img src=\"" . $context->getProperty('uri.blog') . "/imageResizer/?f=" . urlencode($filename) . "\" alt=\"\" />", $path);
                }
            }
            if ($onclickFlag == true && $bRssMode == false && $bPassing == false) {
                $imageStr = '<img src="' . $url . '" ' . $property . ' style="cursor: pointer;" onclick="open_img(\'' . $url . '\'); return false;" />';
            } else {
                $imageStr = '<img src="' . $url . '" ' . $property . ' />';
            }
            return fireEvent('ViewAttachedImage', $imageStr, $path);
            break;
        case 'swf':
            $id = md5($url) . rand(1, 10000);
            if ($useAbsolutePath && strncasecmp($url, 'http://', 7) == 0) {
                $url = substr($url, 7);
            }
            return "<span id=\"{$id}\"><script type=\"text/javascript\">//<![CDATA[" . CRLF . "writeCode(getEmbedCode('{$url}','300','400','{$id}','#FFFFFF',''), \"{$id}\");//]]></script></span>";
            break;
        case 'wmv':
        case 'avi':
        case 'asf':
        case 'mpg':
        case 'mpeg':
            $id = md5($url) . rand(1, 10000);
            if ($useAbsolutePath && strncasecmp($url, 'http://', 7) == 0) {
                $url = substr($url, 7);
            }
            return "<span id=\"{$id}\"><script type=\"text/javascript\">//<![CDATA[" . CRLF . "writeCode('<embed {$property} autostart=\"0\" src=\"{$url}\"></embed>', \"{$id}\")//]]></script></span>";
            break;
        case 'mp3':
        case 'mp2':
        case 'wma':
        case 'wav':
        case 'mid':
        case 'midi':
            $id = md5($url) . rand(1, 10000);
            if ($useAbsolutePath && strncasecmp($url, 'http://', 7) == 0) {
                $url = substr($url, 7);
            }
            return "<span id=\"{$id}\"><script type=\"text/javascript\">//<![CDATA[" . CRLF . "writeCode('<embed {$property} autostart=\"0\" height=\"45\" src=\"{$url}\"></embed>', \"{$id}\")//]]></script></span>";
            break;
        case 'mov':
            $id = md5($url) . rand(1, 10000);
            return "<span id=\"{$id}\"><script type=\"text/javascript\">//<![CDATA[" . CRLF . "writeCode(" . '\'<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" width="400px" height="300px"><param name="src" value="' . $url . '" /><param name="controller" value="true" /><param name="pluginspage" value="http://www.apple.com/QuickTime/download/" /><!--[if !IE]> <--><object type="video/quicktime" data="' . $url . '" width="400px" height="300px" class="mov"><param name="controller" value="true" /><param name="pluginspage" value="http://www.apple.com/QuickTime/download/" /></object><!--> <![endif]--></object>\'' . ", \"{$id}\")//]]></script></span>";
            break;
        default:
            if (file_exists(ROOT . '/resources/image/extension/' . Misc::getFileExtension($fileInfo['label']) . '.gif')) {
                return '<a class="extensionIcon" href="' . ($useAbsolutePath ? $context->getProperty('uri.host') : '') . $context->getProperty('uri.blog') . '/attachment/' . $filename . '">' . fireEvent('ViewAttachedFileExtension', '<img src="' . ($useAbsolutePath ? $context->getProperty('uri.service') : $context->getProperty('service.path')) . '/resources/image/extension/' . Misc::getFileExtension($fileInfo['label']) . '.gif" alt="" />') . ' ' . htmlspecialchars($fileInfo['label']) . '</a>';
            } else {
                return '<a class="extensionIcon" href="' . ($useAbsolutePath ? $context->getProperty('uri.host') : '') . $context->getProperty('uri.blog') . '/attachment/' . $filename . '">' . fireEvent('ViewAttachedFileExtension', '<img src="' . ($useAbsolutePath ? $context->getProperty('uri.service') : $context->getProperty('service.path')) . '/resources/image/extension/unknown.gif" alt="" />') . ' ' . htmlspecialchars($fileInfo['label']) . '</a>';
            }
            break;
    }
}