Пример #1
0
        if (@($fp = fopen(DISCUZ_ROOT . $_G['forum_logfile'], 'a'))) {
            fwrite($fp, "{$aid}\n");
            fclose($fp);
        } elseif ($_G['adminid'] == 1) {
            showmessage('view_log_invalid', '', array('logfile' => $_G['forum_logfile']));
        }
    } else {
        C::t('forum_attachment')->update_download($aid);
    }
}
$db = DB::object();
$db->close();
!$_G['config']['output']['gzip'] && ob_end_clean();
//Begin Of Upyun Insert Code
include_once DISCUZ_ROOT . 'source/plugin/upyun/function_upyun.php';
upyun_attachment_download($attach, 'forum');
//End Of Upyun Insert Code
$filesize = !$attach['remote'] ? filesize($filename) : $attach['filesize'];
$attach['filename'] = '"' . (strtolower(CHARSET) == 'utf-8' && strexists($_SERVER['HTTP_USER_AGENT'], 'MSIE') ? urlencode($attach['filename']) : $attach['filename']) . '"';
dheader('Date: ' . gmdate('D, d M Y H:i:s', $attach['dateline']) . ' GMT');
dheader('Last-Modified: ' . gmdate('D, d M Y H:i:s', $attach['dateline']) . ' GMT');
dheader('Content-Encoding: none');
if ($isimage && !empty($_GET['noupdate']) || !empty($_GET['request'])) {
    dheader('Content-Disposition: inline; filename=' . $attach['filename']);
} else {
    dheader('Content-Disposition: attachment; filename=' . $attach['filename']);
}
if ($isimage) {
    dheader('Content-Type: image');
} else {
    dheader('Content-Type: application/octet-stream');
Пример #2
0
    include template('portal/portal_attachment');
    exit;
} else {
    $filename = $_G['setting']['attachdir'] . '/portal/' . $attach['attachment'];
    if (!$attach['remote'] && !is_readable($filename)) {
        showmessage('attachment_nonexistence');
    }
    $readmod = 2;
    //read local file's function: 1=fread 2=readfile 3=fpassthru 4=fpassthru+multiple
    $range = 0;
    if ($readmod == 4 && !empty($_SERVER['HTTP_RANGE'])) {
        list($range) = explode('-', str_replace('bytes=', '', $_SERVER['HTTP_RANGE']));
    }
    //Begin Of Upyun Insert Code
    include_once DISCUZ_ROOT . 'source/plugin/upyun/function_upyun.php';
    upyun_attachment_download($attach, 'portal');
    //End Of Upyun Insert Code
    $filesize = $attach['filesize'];
    $attach['filename'] = '"' . (strtolower(CHARSET) == 'utf-8' && strexists($_SERVER['HTTP_USER_AGENT'], 'MSIE') ? urlencode($attach['filename']) : $attach['filename']) . '"';
    dheader('Date: ' . gmdate('D, d M Y H:i:s', $attach['dateline']) . ' GMT');
    dheader('Last-Modified: ' . gmdate('D, d M Y H:i:s', $attach['dateline']) . ' GMT');
    dheader('Content-Encoding: none');
    dheader('Content-Disposition: attachment; filename=' . $attach['filename']);
    dheader('Content-Type: ' . $attach['filetype']);
    dheader('Content-Length: ' . $filesize);
    if ($readmod == 4) {
        dheader('Accept-Ranges: bytes');
        if (!empty($_SERVER['HTTP_RANGE'])) {
            $rangesize = $filesize - $range > 0 ? $filesize - $range : 0;
            dheader('Content-Length: ' . $rangesize);
            dheader('HTTP/1.1 206 Partial Content');