Discuz!官方免费开源建站系统

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

[插件] 上传的音乐附件(MP3/WMV/RM/FLASH)在线播放 For 4.10 By Oytktk

[复制链接]
yrsy 发表于 2006-10-30 12:46:20 | 显示全部楼层
原帖由 yrsy 于 2006-10-30 12:38 发表
原来用的好好的,怎么最近升完级了反而不能播放了呢?

救命呀。呵呵
附件也无法直接下载了



  attachments。php这个文件用原来的覆盖了就好拉。

贴出来给看看
:能用的

<?php

/*
        [Discuz!] (C)2001-2006 Comsenz Inc.
        This is NOT a freeware, use is subject to license terms

        $RCSfile: attachment.php,v $
        $Revision: 1.3 $
        $Date: 2006/03/05 12:34:33 $
*/

require_once './include/common.inc.php';

$discuz_action = 14;

if($attachrefcheck && $_SERVER['HTTP_REFERER'] && preg_replace("/https?:\/\/([^\/]+).*/i", "\\1", $_SERVER['HTTP_REFERER']) != $_SERVER['HTTP_HOST']) {
        //header("Location: {$boardurl}images/common/invalidreferer.gif");
        showmessage('attachment_referer_invalid', NULL, 'HALTED');
}

/*
$query = $db->query("SELECT a.*, t.fid, p.authorid FROM {$tablepre}attachments a, {$tablepre}threads t, {$tablepre}posts p
        WHERE a.aid='$aid' AND t.tid=a.tid AND p.pid=a.pid AND t.displayorder>='0' AND p.invisible='0'");
$attach = $db->fetch_array($query);
*/

$attachexists = FALSE;
if(!empty($aid)) {
        $query = $db->query("SELECT * FROM {$tablepre}attachments WHERE aid='$aid'");
        if($attach = $db->fetch_array($query)) {
                $query = $db->query("SELECT fid FROM {$tablepre}threads WHERE tid='$attach[tid]' AND displayorder>='0'");
                if($attach['fid'] = $db->result($query, 0)) {
                        $query = $db->query("SELECT authorid FROM {$tablepre}posts WHERE pid='$attach[pid]' AND invisible='0'");
                        if($db->num_rows($query)) {
                                $attach['authorid'] = $db->result($query, 0);
                                $attachexists = TRUE;
                        }
                }
        }
}


if($allowgetattach && $attach['readperm'] && $attach['readperm'] > $readaccess && $adminid <= 0 && !($discuz_uid && $discuz_uid == $attach['authorid'])) {
        showmessage('attachment_nopermission', NULL, 'NOPERM');
}

$filename = $attachdir.'/'.$attach['attachment'];

if(is_readable($filename) && $attachexists) {

        $query = $db->query("SELECT f.getattachperm, a.allowgetattach FROM {$tablepre}forumfields f
                        LEFT JOIN {$tablepre}access a ON a.uid='$discuz_uid' AND a.fid=f.fid
                        WHERE f.fid='$attach[fid]'");
        $forum = $db->fetch_array($query);

        if(!$forum['allowgetattach']) {
                if(!$forum['getattachperm'] && !$allowgetattach) {
                        showmessage('group_nopermission', NULL, 'NOPERM');
                } elseif($forum['getattachperm'] && !forumperm($forum['getattachperm'])) {
                        showmessage('attachment_forum_nopermission', NULL, 'NOPERM');
                }
        }

       
        if(!($isimage = preg_match("/^image\/.+/", $attach['filetype']))) {
                checklowerlimit($creditspolicy['getattach'], -1);
        }

        if(empty($noupdate)) {
                if($delayviewcount == 2 || $delayviewcount == 3) {
                        $logfile = './forumdata/cache/cache_attachviews.log';
                        if(substr($timestamp, -1) == '0') {
                                require_once DISCUZ_ROOT.'./include/misc.func.php';
                                updateviews('attachments', 'aid', 'downloads', $logfile);
                        }

                        if(@$fp = fopen(DISCUZ_ROOT.$logfile, 'a')) {
                                fwrite($fp, "$aid\n");
                                fclose($fp);
                        } elseif($adminid == 1) {
                                showmessage('view_log_invalid');
                        }
                } else {
                        $db->query("UPDATE {$tablepre}attachments SET downloads=downloads+'1' WHERE aid='$aid'", 'UNBUFFERED');
                }
        }

        $filesize = filesize($filename);

        ob_end_clean();
        header('Cache-control: max-age=31536000');
        header('Expires: '.gmdate('D, d M Y H:i:s', $timestamp + 31536000).' GMT');
        header('Content-Encoding: none');
        //header('Content-Length: '.$filesize);

        //forbid flash be opened directly
        //header('Content-Disposition: '.(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') ? 'inline; ' : 'attachment; ').'filename='.$attach['filename']);

        header('Content-Disposition: attachment; filename='.$attach['filename']);
        header('Content-Type: '.$attach['filetype']);

        @$fp = fopen($filename, 'rb');
        @flock($fp, 2);
        $attachment = @fread($fp, $filesize);
        @fclose($fp);

        echo $attachment;

        if(!$isimage) {       
                updatecredits($discuz_uid, $creditspolicy['getattach'], -1);
        }

} else {

        showmessage('attachment_nonexistence');

}

?>

替换成下面的就不能用了。

<?php

/*
        [Discuz!] (C)2001-2006 Comsenz Inc.
        This is NOT a freeware, use is subject to license terms

        $RCSfile: attachment.php,v $
        $Revision: 1.3 $
        $Date: 2006/03/05 12:34:33 $
*/

require_once './include/common.inc.php';

$discuz_action = 14;

if($attachrefcheck && $_SERVER['HTTP_REFERER'] && preg_replace("/https?:\/\/([^\/]+).*/i", "\\1", $_SERVER['HTTP_REFERER']) != $_SERVER['HTTP_HOST']) {
        //header("Location: {$boardurl}images/common/invalidreferer.gif");
        showmessage('attachment_referer_invalid', NULL, 'HALTED');
}

/*
$query = $db->query("SELECT a.*, t.fid, p.authorid FROM {$tablepre}attachments a, {$tablepre}threads t, {$tablepre}posts p
        WHERE a.aid='$aid' AND t.tid=a.tid AND p.pid=a.pid AND t.displayorder>='0' AND p.invisible='0'");
$attach = $db->fetch_array($query);
*/

$attachexists = FALSE;
if(!empty($aid)) {
        $query = $db->query("SELECT * FROM {$tablepre}attachments WHERE aid='$aid'");
        if($attach = $db->fetch_array($query)) {
                $query = $db->query("SELECT fid FROM {$tablepre}threads WHERE tid='$attach[tid]' AND displayorder>='0'");
                if($attach['fid'] = $db->result($query, 0)) {
                        $query = $db->query("SELECT authorid FROM {$tablepre}posts WHERE pid='$attach[pid]' AND invisible='0'");
                        if($db->num_rows($query)) {
                                $attach['authorid'] = $db->result($query, 0);
                                $attachexists = TRUE;
                        }
                }
        }
}


if($allowgetattach && $attach['readperm'] && $attach['readperm'] > $readaccess && $adminid <= 0 && !($discuz_uid && $discuz_uid == $attach['authorid'])) {
        showmessage('attachment_nopermission', NULL, 'NOPERM');
}

$filename = $attachdir.'/'.$attach['attachment'];

if(is_readable($filename) && $attachexists) {

        $query = $db->query("SELECT f.getattachperm, a.allowgetattach FROM {$tablepre}forumfields f
                        LEFT JOIN {$tablepre}access a ON a.uid='$discuz_uid' AND a.fid=f.fid
                        WHERE f.fid='$attach[fid]'");
        $forum = $db->fetch_array($query);

        if(!$forum['allowgetattach']) {
                if(!$forum['getattachperm'] && !$allowgetattach) {
                        showmessage('group_nopermission', NULL, 'NOPERM');
                } elseif($forum['getattachperm'] && !forumperm($forum['getattachperm'])) {
                        showmessage('attachment_forum_nopermission', NULL, 'NOPERM');
                }
        }

       
        if(!($isimage = preg_match("/^image\/.+/", $attach['filetype']))) {
                checklowerlimit($creditspolicy['getattach'], -1);
        }

        if(empty($noupdate)) {
                if($delayviewcount == 2 || $delayviewcount == 3) {
                        $logfile = './forumdata/cache/cache_attachviews.log';
                        if(substr($timestamp, -1) == '0') {
                                require_once DISCUZ_ROOT.'./include/misc.func.php';
                                updateviews('attachments', 'aid', 'downloads', $logfile);
                        }

                        if(@$fp = fopen(DISCUZ_ROOT.$logfile, 'a')) {
                                fwrite($fp, "$aid\n");
                                fclose($fp);
                        } elseif($adminid == 1) {
                                showmessage('view_log_invalid');
                        }
                } else {
                        $db->query("UPDATE {$tablepre}attachments SET downloads=downloads+'1' WHERE aid='$aid'", 'UNBUFFERED');
                }
        }

        $filesize = filesize($filename);

        ob_end_clean();


/* DISCUZ原始代码
        header('Cache-control: max-age=31536000');
        header('Expires: '.gmdate('D, d M Y H:i:s', $timestamp + 31536000).' GMT');
        header('Content-Encoding: none');
        //header('Content-Length: '.$filesize);

        //forbid flash be opened directly
        //header('Content-Disposition: '.(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') ? 'inline; ' : 'attachment; ').'filename='.$attach['filename']);

        header('Content-Disposition: attachment; filename='.$attach['filename']);
        header('Content-Type: '.$attach['filetype']);

        @$fp = fopen($filename, 'rb');
        @flock($fp, 2);
        $attachment = @fread($fp, $filesize);
        @fclose($fp);

        echo $attachment;
*/

//********************** by Shuttle ********************************
    header("Content-type:application/x-msdownload\n");  //application/octet-stream
    header("Content-type:unknown/unknown;");
    header('Content-Disposition: attachment; filename='.$attach['filename']);
//    header("Content-disposition: inline; filename=\"".$attach['filename']."\"");
    header('Content-transfer-encoding: binary');

    if ($range = $HTTP_SERVER_VARS["HTTP_RANGE"]) // 当有偏移量的时候,采用206的断点续传头
    {
        $range = explode('=', $range);
        $range = $range[1];
         
        header("HTTP/1.1 206 Partial Content");
        header("Date: " . gmdate("D, d M Y H:i:s") . " GMT");
        header("Last-Modified: ".gmdate("D, d M Y H:i:s", filemtime($filename))." GMT");
        header("Accept-Ranges: bytes");
        header("Content-Length:".($filesize - $range));
        header("Content-Range: bytes ".$range.($filesize-1)."/".$filesize);
        header("Connection: close"."\n\n");
    }
    else
    {
        header("Content-Length:".$filesize."\n\n");
        $range = 0;
    }

    $fp = fopen($filename, 'rb');
    fseek($fp, $range);
    while ($bbsf = fread($fp, 4096))
    {
        echo $bbsf;
    }
    fclose($fp);
//******************************************************************


        if(!$isimage) {       
                updatecredits($discuz_uid, $creditspolicy['getattach'], -1);
        }

} else {

        showmessage('attachment_nonexistence');

}

?>
回复

使用道具 举报

kkhpop 发表于 2006-11-16 17:45:44 | 显示全部楼层
已用了靖枫for4.0的
回复

使用道具 举报

fax211 发表于 2007-2-13 20:49:53 | 显示全部楼层
绝对有效,修改之后全部一齐正常,播什么都可以了,谢谢楼主喇!
回复

使用道具 举报

jie522 发表于 2008-7-1 19:10:45 | 显示全部楼层
請問一下.6.0版本的可以做嗎?
需要改哪些程式碼嗎?
謝謝各位大大的幫忙~~~
回复

使用道具 举报

fxx8788 发表于 2008-11-20 21:10:56 | 显示全部楼层
感谢~正在烦恼呢
回复

使用道具 举报

灰空间2 发表于 2008-12-3 01:40:48 | 显示全部楼层
谢谢~正需要啊....
回复

使用道具 举报

wxy505 发表于 2009-1-21 14:12:15 | 显示全部楼层
谢谢了,,,
回复

使用道具 举报

海上城市 发表于 2009-2-15 12:25:13 | 显示全部楼层
这个有没有DZ7.0的啊
回复

使用道具 举报

pankai3122 发表于 2009-6-5 23:02:59 | 显示全部楼层
有没有6.1的啊 !!跪求
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2024-4-29 02:07 , Processed in 0.102524 second(s), 15 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表