微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Discuz! 5.0.0论坛程序中加入一段js代码,让会员点击下载附件前自动弹出提示窗口

你需要修改attachment.PHP文件在根目录下
在$attachexists=$ispaid=FALSE;下面添加
if(!empty($checktwo)){
在最末尾的?>前添加
}else{
echo"";
echo"<MetaHTTP-EQUIV=\"Refresh\"CONTENT=\"0;URL=$PHP_SELF?checktwo=1&aid=$aid\">";
}
我在本机架设discuz!5.0.1调试通过了
完整代码如下:
<?PHP
/
discuz!2001-2006ComsenzInc.
ThisisNOTafreeware,useissubjecttolicenseterms
$RCSfile:attachment.PHP,v$
$Revision:1.13$
$Date:2006/08/1106:51:07$
/
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("SELECTa.,t.fid,p.authoridFROM{$tablepre}attachmentsa,{$tablepre}threadst,{$tablepre}postsp
WHEREa.aid='$aid'ANDt.tid=a.tidANDp.pid=a.pidANDt.displayorder>='0'ANDp.invisible='0'");
$attach=$db->fetch_array($query);
/
periodscheck('attachbanperiods');
$attachexists=$ispaid=FALSE;
if(!empty($checktwo)){
if(!empty($aid)){
$query=$db->query("SELECT*FROM{$tablepre}attachmentsWHEREaid='$aid'");
if($attach=$db->fetch_array($query)){
$query=$db->query("SELECTtid,fid,price,specialFROM{$tablepre}threadsWHEREtid='$attach[tid]'ANDdisplayorder>='0'");
$thread=$db->fetch_array($query);
if($thread['fid']){
$query=$db->query("SELECTauthoridFROM{$tablepre}postsWHEREpid='$attach[pid]'ANDinvisible='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('attachmentforumnopermission','nopERM');
}
if(!$thread['special']&&$thread['price']>0&&(!$discuz_uid||($discuz_uid&&$discuz_uid!=$attach['authorid']&&$adminid<=0))){
$query=$db->query("SELECTuidFROM{$tablepre}paymentlogWHEREuid='$discuz_uid'ANDtid='$attach[tid]'");
if($db->result($query,0)){
$ispaid=TRUE;
}else{
showmessage('attachment_payto','viewthread.PHP?tid='.$attach['tid']);
}
}
$filename=$attachdir.'/'.$attach['attachment'];
if(is_readable($filename)&&$attachexists){
$query=$db->query("SELECTf.viewperm,f.getattachperm,f.getattachcredits,a.allowgetattachFROM{$tablepre}forumfieldsf
LEFTJOIN{$tablepre}accessaONa.uid='$discuz_uid'ANDa.fid=f.fid
WHEREf.fid='$thread[fid]'");
$forum=$db->fetcharray($query);
if(!$ispaid){
if(!$forum['allowgetattach']){
if(!$forum['getattachperm']&&!$allowgetattach){
showmessage('group
nopermission','nopERM');
}elseif(($forum['getattachperm']&&!forumperm($forum['getattachperm']))||($forum['viewperm']&&!forumperm($forum['viewperm']))){
showmessage('attachmentforumnopermission','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_oncedisCUZ_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}attachmentsSETdownloads=downloads+'1'WHEREaid='$aid'",'UNBUFFERED');
}
}
if(!$isimage){
$forum['getattachcredits']=$forum['getattachcredits']?unserialize($forum['getattachcredits']):array();
$getattachcredits=$forum['getattachcredits']?$forum['getattachcredits']:$creditspolicy['getattach'];
updatecredits($discuz_uid,$getattachcredits,-1);
}
$filesize=filesize($filename);
ob_end_clean();
header('Cache-control:max-age=31536000');
header('Expires:'.gmdate('D,dMYH:i:s',$timestamp+31536000).'GMT');
header('content-encoding:none');
$attach['filename']=(strtolower($charset)=='utf-8'&&strexists($_SERVER['HTTP_USER_AGENT'],'MSIE'))?urlencode($attach['filename']):$attach['filename'];
if($isimage&&!empty($noupdate)){
header('Content-disposition:inline;filename='.$attach['filename']);
}else{
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; }else{
showmessage('attachment_nonexistence');
}
}else{
echo"";
echo"<MetaHTTP-EQUIV=\"Refresh\"CONTENT=\"0;URL=$PHP_SELF?checktwo=1&aid=$aid\">";
}
?>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐