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

你需要修改attachment.php文件 在根目录下 
在$attachexists = $ispaid = FALSE;下面添加 
if (!empty($checktwo)) { 
在最末尾的?>前添加 
} else { 
echo "<script>alert('写上你要提示的内容')</script>"; 
echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"0;URL=$PHP_SELF?checktwo=1&aid=$aid\">"; 

我在本机架设Discuz! 5.0.1调试通过了 
完整代码如下: 
<?php 
/* 
[Discuz!] (C)2001-2006 Comsenz Inc. 
This is NOT a freeware, use is subject to license terms 
$RCSfile: attachment.php,v $ 
$Revision: 1.13 $ 
$Date: 2006/08/11 06: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("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); 
*/ 
periodscheck('attachbanperiods'); 
$attachexists = $ispaid = FALSE; 
if (!empty($checktwo)) { 
if(!empty($aid)) { 
$query = $db->query("SELECT * FROM {$tablepre}attachments WHERE aid='$aid'"); 
if($attach = $db->fetch_array($query)) { 
$query = $db->query("SELECT tid, fid, price, special FROM {$tablepre}threads WHERE tid='$attach[tid]' AND displayorder>='0'"); 
$thread = $db->fetch_array($query); 
if($thread['fid']) { 
$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_forum_nopermission', NULL, 'NOPERM'); 

if(!$thread['special'] && $thread['price'] > 0 && (!$discuz_uid || ($discuz_uid && $discuz_uid != $attach['authorid'] && $adminid <=0))) { 
$query = $db->query("SELECT uid FROM {$tablepre}paymentlog WHERE uid='$discuz_uid' AND tid='$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("SELECT f.viewperm, f.getattachperm, f.getattachcredits, a.allowgetattach FROM {$tablepre}forumfields f 
LEFT JOIN {$tablepre}access a ON a.uid='$discuz_uid' AND a.fid=f.fid 
WHERE f.fid='$thread[fid]'"); 
$forum = $db->fetch_array($query); 
if(!$ispaid) { 
if(!$forum['allowgetattach']) { 
if(!$forum['getattachperm'] && !$allowgetattach) { 
showmessage('group_nopermission', NULL, 'NOPERM'); 
} elseif(($forum['getattachperm'] && !forumperm($forum['getattachperm'])) || ($forum['viewperm'] && !forumperm($forum['viewperm']))) { 
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'); 


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, d M Y H: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 "<script>alert('$PHP_SELF')</script>"; 
echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"0;URL=$PHP_SELF?checktwo=1&aid=$aid\">"; 

?> 

时间: 2024-08-05 09:36:01

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

VC++6.0编译setup程序中出现的在commctrl.h中的错误

问题描述 VC++6.0编译setup程序中出现的在commctrl.h中的错误 c:program files (x86)microsoft visual studiovc98includecommctrl.h(26) : error C2146: syntax error : missing ';' before identifier 'HRESULT'c:program files (x86)microsoft visual studiovc98includecommctrl.h(26)

安卓4.0以上 实现程序中vpn连接 可付费购买支持

问题描述 安卓4.0以上 实现程序中vpn连接 可付费购买支持 安卓4.0以上 实现程序中vpn连接 可付费购买支持 支持的协议为pptp l2tp openvpn 最好能连通l2tp,如有大神能提供帮助,必有重谢. 解决方案 参考:http://stackoverflow.com/questions/13704519/programmatically-configure-pptp-l2tp-vpn-in-android

PHP程序中,怎么插入JS点击事件

问题描述 PHP程序中,怎么插入JS点击事件 求高手解答.我需要做一个循环表格结构,大约是以下形式:foreach ( $result as $row ) { echo "" tr> td> input type='hidden' value='"".$rou['id'].""' /> /td>""; echo "" td>无关紧要内容 /td> /tr>"

在线等待,如何在程序中真接调如(百度,sohu.sogou)搜索片定义的关键字,比如我在程序中加入一个文本框,输入关键字后,点击百度搜索程序就直接调用百度搜索这个关键字,谢谢!

问题描述 在线等待,如何在程序中真接调如(百度,sohu.sogou)搜索片定义的关键字,比如我在程序中加入一个文本框,输入关键字后,点击百度搜索程序就直接调用百度搜索这个关键字,点sohu就调用SOHU,谢谢! 解决方案 解决方案二:我这有个百度的,我常用,你把下面的内容另存为HTML文件就行了.1.<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.0Transitional//EN"><!--savedfromurl=(0043)http:

java-这段Java程序中,有一段语法我不太明白,大神进来给看看~

问题描述 这段Java程序中,有一段语法我不太明白,大神进来给看看~ public class ChengJi { public static void main(String[] args) { int x; char grade; Scanner s = new Scanner(System.in); System.out.print("Please input Grade: "); x = s.nextInt(); if (x > 100) { System.out.pri

mfc listbox-MFC-LISTBOX列表框如何在程序中自选多项呢,不用鼠标点击选择

问题描述 MFC-LISTBOX列表框如何在程序中自选多项呢,不用鼠标点击选择 我setcuesel(0)为什么没有反应呢,我想点击某个按钮时自选固定的某几项,应该怎么写呢 解决方案 属性里有个,selectemode,你把它设置成multiextended就可以了

c#代码-C#窗体程序中的平方和开方的代码是什么?

问题描述 C#窗体程序中的平方和开方的代码是什么? 问题如上,在写一个简单计算器,这个不知道是什么?求大神告知,在C#窗体程序中表示平方和开方的代码, 解决方案 已查到,不用麻烦大家了

c++-Activex如何在网页中插入一段Js

问题描述 Activex如何在网页中插入一段Js 基于ATL模板,如何插入JS.下面是已经写的部分代码,在这基础上怎么加呢? CComPtr isp; CComPtr ppBrowser; CComPtr pDispDoc; CComPtr pDocument2; HRESULT hr = S_OK; DISPID dispid; CComVariant avarParams[1]; avarParams[0].vt = VT_UI1; DISPPARAMS dispparams = {avar

小工具:计算当前文件夹中,有多少行JS代码和ASP代码,并且还可统计代码有多少字节

js|统计 计算当前文件夹中,有多少行JS代码和ASP代码,并且还可统计代码有多少字节 有示例代码 <%'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'\\'\\    from codeproject.com'\\    calculate code'\\    bluedestiny'\\    mail:bluedestiny at 126.com'\\'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ opt