Discuz! 5.0.0 Add a piece of js code to the Forum program and ask the Member to click the attachment to download. A Prompt window will pop up automatically.

Source: Internet
Author: User

You need to modify the attachment. php file in the root directory.
Add the following content under $ attachexists = $ ispaid = false;
If (! Empty ($ checktwo )){
At the end of?> Add
} Else {
Echo "<SCRIPT> alert ('write the content you want to prompt ') </SCRIPT> ";
Echo "<meta HTTP-EQUIV = \" Refresh \ "content = \" 0; url = $ php_self? Checktwo = 1 & Aid = $ aid \ "> ";
}
I set up discuz on the local machine! 5.0.1 debugging passed
Complete Code As follows:
<? 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. *, T. FID, P. authorid from {$ tablepre} attachments A, {$ tablepre} threads T, {$ tablepre} posts P
Where. aid = '$ aid' and T. tid =. TID and P. PID =. 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 ('attachances', '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 ['getattachcredres'] = $ Forum ['getattachcredres']? Unserialize ($ Forum ['getattachcredits ']): array ();
$ Getattachcredits = $ Forum ['getattachcredits ']? $ Forum ['getattachcredres']: $ creditspolicy ['getattach '];
Updatecredits ($ discuz_uid, $ getattachcredits,-1 );
}
$ Filesize = filesize ($ filename );
Ob_end_clean ();
Header ('cache-control: Max-age = 000000 ');
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 \ "> ";
}
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.