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

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

Jun 13, 2016 pm 12:31 PM
discuz download code member join in pop up hint Click program window automatic forum appendix

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

我在本机架设Discuz! 5.0.1调试通过了 
完整代码如下: 
/* 
[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 showmessage('attachment_forum_nopermission', NULL, 'NOPERM'); 

if(!$thread['special'] && $thread['price'] > 0 && (!$discuz_uid || ($discuz_uid && $discuz_uid != $attach['authorid'] && $adminid $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 ""; 

?> 

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to make Google Maps the default map in iPhone How to make Google Maps the default map in iPhone Apr 17, 2024 pm 07:34 PM

The default map on the iPhone is Maps, Apple's proprietary geolocation provider. Although the map is getting better, it doesn't work well outside the United States. It has nothing to offer compared to Google Maps. In this article, we discuss the feasible steps to use Google Maps to become the default map on your iPhone. How to Make Google Maps the Default Map in iPhone Setting Google Maps as the default map app on your phone is easier than you think. Follow the steps below – Prerequisite steps – You must have Gmail installed on your phone. Step 1 – Open the AppStore. Step 2 – Search for “Gmail”. Step 3 – Click next to Gmail app

What should I do if I download other people's wallpapers after logging into another account on wallpaperengine? What should I do if I download other people's wallpapers after logging into another account on wallpaperengine? Mar 19, 2024 pm 02:00 PM

When you log in to someone else's steam account on your computer, and that other person's account happens to have wallpaper software, steam will automatically download the wallpapers subscribed to the other person's account after switching back to your own account. Users can solve this problem by turning off steam cloud synchronization. What to do if wallpaperengine downloads other people's wallpapers after logging into another account 1. Log in to your own steam account, find cloud synchronization in settings, and turn off steam cloud synchronization. 2. Log in to someone else's Steam account you logged in before, open the Wallpaper Creative Workshop, find the subscription content, and then cancel all subscriptions. (In case you cannot find the wallpaper in the future, you can collect it first and then cancel the subscription) 3. Switch back to your own steam

Introduction to how to download and install the superpeople game Introduction to how to download and install the superpeople game Mar 30, 2024 pm 04:01 PM

The superpeople game can be downloaded through the steam client. The size of this game is about 28G. It usually takes one and a half hours to download and install. Here is a specific download and installation tutorial for you! New method to apply for global closed testing 1) Search for "SUPERPEOPLE" in the Steam store (steam client download) 2) Click "Request access to SUPERPEOPLE closed testing" at the bottom of the "SUPERPEOPLE" store page 3) After clicking the request access button, The "SUPERPEOPLECBT" game can be confirmed in the Steam library 4) Click the install button in "SUPERPEOPLECBT" and download

Instructions for automatic renewal and cancellation of Kugou Music APP membership Instructions for automatic renewal and cancellation of Kugou Music APP membership Mar 19, 2024 pm 07:28 PM

How to cancel automatic membership renewal on Kugou Music APP? There are many users who have applied for Kugou Music’s VIP auto-renewal service. Later, they want to cancel this service, but they don’t know where to cancel it. Below, I will bring you a tutorial on how to cancel the auto-renewal of Kugou Music. I hope it will be helpful to everyone. . It is very simple to cancel automatic renewal in Kugou Music APP: just enter the member center, find the music package/luxury VIP option, select automatic renewal enabled, and then click to close renewal. 2. WeChat: As shown in the picture below, go to the payment page, click the three dots in the upper right corner, select the deduction service, click Kugou Music to close the service; 3. Alipay: Go to the settings page, select payment settings, and select password-free payment/ Automatically deduct fees, and finally choose Kugou Music to terminate the contract.

Where to download files from Quark Network Disk_How to download Quark Network Disk to local area and share Where to download files from Quark Network Disk_How to download Quark Network Disk to local area and share Mar 21, 2024 pm 03:57 PM

As a convenient and practical network disk tool, Quark can help users easily obtain their favorite resources. What if you want to download a file locally? Let the editor tell you now, let’s learn it together! How to download Quark Network Disk to local sharing method 1. First open the Quark software, enter the homepage, and click the [Cloud Icon] on the lower right; 2. Then on the Quark Network Disk page, we click the [Document] function; 3. Then go to the document page, select the file you want to download, and click the [three-dot icon]; 4. After the final click, we click [Download] in the pop-up dialog box;

How to download foobar2000? -How to use foobar2000 How to download foobar2000? -How to use foobar2000 Mar 18, 2024 am 10:58 AM

foobar2000 is a software that can listen to music resources at any time. It brings you all kinds of music with lossless sound quality. The enhanced version of the music player allows you to get a more comprehensive and comfortable music experience. Its design concept is to play the advanced audio on the computer The device is transplanted to mobile phones to provide a more convenient and efficient music playback experience. The interface design is simple, clear and easy to use. It adopts a minimalist design style without too many decorations and cumbersome operations to get started quickly. It also supports a variety of skins and Theme, personalize settings according to your own preferences, and create an exclusive music player that supports the playback of multiple audio formats. It also supports the audio gain function to adjust the volume according to your own hearing conditions to avoid hearing damage caused by excessive volume. Next, let me help you

Clock app missing in iPhone: How to fix it Clock app missing in iPhone: How to fix it May 03, 2024 pm 09:19 PM

Is the clock app missing from your phone? The date and time will still appear on your iPhone's status bar. However, without the Clock app, you won’t be able to use world clock, stopwatch, alarm clock, and many other features. Therefore, fixing missing clock app should be at the top of your to-do list. These solutions can help you resolve this issue. Fix 1 – Place the Clock App If you mistakenly removed the Clock app from your home screen, you can put the Clock app back in its place. Step 1 – Unlock your iPhone and start swiping to the left until you reach the App Library page. Step 2 – Next, search for “clock” in the search box. Step 3 – When you see “Clock” below in the search results, press and hold it and

How to download and save Douyin videos How to download and save Douyin videos Mar 25, 2024 pm 09:46 PM

How to download and save Douyin videos? You can download and save videos in Douyin short video APP. Most users don’t know how to download and save Douyin videos. Next is the diagram of how to download and save Douyin videos brought by the editor. Text tutorial, interested users come and take a look! Tutorial on how to use Douyin: How to download and save Douyin videos 1. First open the Douyin short video APP, enter the main page and click the [Share] button on the right; 2. After that, the multi-function bar will expand below, slide to the right to find [ Save local] icon; 3. Then you need to wait for the download, and then the [Saved, please go to the album to view] border will appear; 4. Finally jump to the album page, and you can see that the video you just downloaded has been saved.

See all articles