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
The complete code is 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 \ "> ";
}
?>