Added:
trunk/upload/include/attachment.func.php
Modified:
trunk/upload/include/discuzcode.func.php
trunk/upload/templates/babel/viewthread.htm
Log:
attachment dir bug fixed
Added: trunk/upload/include/attachment.func.php
==============================================================================
--- (empty file)
+++ trunk/upload/include/attachment.func.php Sat Jun 21 04:33:13 2008
@@ -0,0 +1,140 @@
+<?php
+
+/*
+ [Discuz!] (C)2001-2007 Comsenz Inc.
+ This is NOT a freeware, use is subject to license terms
+
+ $RCSfile: attachment.func.php,v $
+ $Revision: 1.14.2.6 $
+ $Date: 2007/04/20 15:56:14 $
+*/
+
+if(!defined('IN_DISCUZ')) {
+ exit('Access Denied');
+}
+
+function attachtype($type, $returnval = 'html') {
+ global $bbsdir;
+ if(!isset($GLOBALS['_DCACHE']['attachicon'])) {
+ $GLOBALS['_DCACHE']['attachicon'] = array(
+ 1 => 'common.gif',
+ 2 => 'binary.gif',
+ 3 => 'zip.gif',
+ 4 => 'rar.gif',
+ 5 => 'msoffice.gif',
+ 6 => 'text.gif',
+ 7 => 'html.gif',
+ 8 => 'real.gif',
+ 9 => 'av.gif',
+ 10 => 'flash.gif',
+ 11 => 'image.gif',
+ 12 => 'pdf.gif',
+ 13 => 'torrent.gif'
+ );
+ }
+ if(is_numeric($type)) {
+ $typeid = $type;
+ } else {
+ if(preg_match("/bittorrent|^torrent\t/", $type)) {
+ $typeid = 13;
+ } elseif(preg_match("/pdf|^pdf\t/", $type)) {
+ $typeid = 12;
+ } elseif(preg_match("/image|^(jpg|gif|png|bmp)\t/", $type)) {
+ $typeid = 11;
+ } elseif(preg_match("/flash|^(swf|fla|swi)\t/", $type)) {
+ $typeid = 10;
+ } elseif(preg_match("/audio|video|^(wav|mid|mp3|m3u|wma|asf|asx|vqf|mpg|mpeg|avi|wmv)\t/", $type)) {
+ $typeid = 9;
+ } elseif(preg_match("/real|^(ra|rm|rv)\t/", $type)) {
+ $typeid = 8;
+ } elseif(preg_match("/htm|^(php|js|pl|cgi|asp)\t/", $type)) {
+ $typeid = 7;
+ } elseif(preg_match("/text|^(txt|rtf|wri|chm)\t/", $type)) {
+ $typeid = 6;
+ } elseif(preg_match("/word|powerpoint|^(doc|ppt)\t/", $type)) {
+ $typeid = 5;
+ } elseif(preg_match("/^rar\t/", $type)) {
+ $typeid = 4;
+ } elseif(preg_match("/compressed|^(zip|arj|arc|cab|lzh|lha|tar|gz)\t/", $type)) {
+ $typeid = 3;
+ } elseif(preg_match("/octet-stream|^(exe|com|bat|dll)\t/", $type)) {
+ $typeid = 2;
+ } elseif($type) {
+ $typeid = 1;
+ } else {
+ $typeid = 0;
+ }
+ }
+ if($returnval == 'html') {
+ return '<img src="'.$bbsdir.'/images/attachicons/'.$GLOBALS['_DCACHE']['attachicon'][$typeid].'" border="0" class="absmiddle" alt="" />';
+ } elseif($returnval == 'id') {
+ return $typeid;
+ }
+}
+
+function sizecount($filesize) {
+ if($filesize >= 1073741824) {
+ $filesize = round($filesize / 1073741824 * 100) / 100 . ' GB';
+ } elseif($filesize >= 1048576) {
+ $filesize = round($filesize / 1048576 * 100) / 100 . ' MB';
+ } elseif($filesize >= 1024) {
+ $filesize = round($filesize / 1024 * 100) / 100 . ' KB';
+ } else {
+ $filesize = $filesize . ' Bytes';
+ }
+ return $filesize;
+}
+
+function parseattach($attachpids, $attachtags, &$postlist, $showimages = 1) {
+ global $db, $tablepre, $discuz_uid, $readaccess, $attachlist, $attachimgpost, $maxchargespan, $timestamp, $forum, $ftp, $attachurl, $dateformat, $timeformat, $timeoffset, $hideattach, $exthtml;
+
+ $query = $db->query("SELECT a.*, ap.aid AS payed FROM {$tablepre}attachments a LEFT JOIN {$tablepre}attachpaymentlog ap ON ap.aid=a.aid AND ap.uid='$discuz_uid' WHERE a.pid IN ($attachpids)");
+ if($db->num_rows($query)) {
+ while($attach = $db->fetch_array($query)) {
+ $exthtml = '';
+ $attached = 0;
+ $extension = strtolower(fileext($attach['filename']));
+ $attach['attachicon'] = attachtype($extension."\t".$attach['filetype']);
+ $attach['attachsize'] = sizecount($attach['filesize']);
+ $attach['attachimg'] = $showimages && $attachimgpost && $attach['isimage'] && (!$attach['readperm'] || $readaccess >= $attach['readperm']) ? 1 : 0;
+ if($attach['price']) {
+ if($maxchargespan && $timestamp - $attach['dateline'] >= $maxchargespan * 3600) {
+ $db->query("UPDATE {$tablepre}attachments SET price='0' WHERE aid='$attach[aid]'");
+ $attach['price'] = 0;
+ } else {
+ if(!$discuz_uid || (!$forum['ismoderator'] && $attach['uid'] != $discuz_uid && !$attach['payed'])) {
+ $attach['unpayed'] = 1;
+ }
+ }
+ }
+ $attach['payed'] = $attach['payed'] || $forum['ismoderator'] || $attach['uid'] == $discuz_uid ? 1 : 0;
+ $attach['url'] = $attach['remote'] ? $ftp['attachurl'] : $attachurl;
+ $attach['dateline'] = gmdate("$dateformat $timeformat", $attach['dateline'] + $timeoffset * 3600);
+ $postlist[$attach['pid']]['attachments'][$attach['aid']] = $attach;
+ if(is_array($attachtags[$attach['pid']]) && in_array($attach['aid'], $attachtags[$attach['pid']])) {
+ $findattach[$attach['pid']][] = "/\[attach\]$attach[aid]\[\/attach\]/i";
+ $replaceattach[$attach['pid']][] = $hideattach ? '[attach]***[/attach]' : attachtag($attach['pid'], $attach['aid'], $postlist);
+ $attached = 1;
+ }
+
+ include_once template('viewthread_attachlist');
+ if(!$attached || $attach['unpayed']) {
+ ob_start();
+ attachlist($attach);
+ $postlist[$attach['pid']]['attachlist'] .= ob_get_contents();
+ ob_end_clean();
+ }
+
+ $postlist[$attach['pid']]['message'] .= $exthtml ? $exthtml : '';
+ }
+
+ foreach($attachtags as $pid => $aids) {
+ $findattach[$pid] && $postlist[$pid]['message'] = preg_replace($findattach[$pid], $replaceattach[$pid], $postlist[$pid]['message']);
+ }
+
+ } else {
+ $db->query("UPDATE {$tablepre}posts SET attachment='0' WHERE pid IN ($attachpids)", 'UNBUFFERED');
+ }
+}
+
+?>
\ No newline at end of file
Modified: trunk/upload/include/discuzcode.func.php
==============================================================================
--- trunk/upload/include/discuzcode.func.php (original)
+++ trunk/upload/include/discuzcode.func.php Sat Jun 21 04:33:13 2008
@@ -40,7 +40,7 @@
mt_srand((double)microtime() * 1000000);
function attachtag($pid, $aid, &$postlist) {
- global $language, $attachrefcheck, $thumbstatus, $extcredits, $creditstrans, $ftp, $exthtml;
+ global $language, $attachrefcheck, $thumbstatus, $extcredits, $creditstrans, $ftp, $exthtml, $bbsdir;
if(isset($postlist[$pid]['attachments'][$aid])) {
include_once language('misc');
@@ -52,27 +52,27 @@
if($attach['attachimg']) {
if($thumbstatus && $attach['thumb']) {
- $replacement .= ($attachrefcheck || $attach['remote']) && !($attach['remote'] && substr($ftp['attachurl'], 0, 3) == 'ftp' && !$ftp['hideurl']) ? '<a href="attachment.php?aid='.$attach['aid'].'&noupdate=yes&nothumb=yes" target="_blank"><img src="attachment.php?aid='.$attach['aid'].'" border="0" alt="'.$language['attach_img_thumb'].'" onmouseover="attachimginfo(this, \'attach_'.$attach['aid'].'\', 1)" onmouseout="attachimginfo(this, \'attach_'.$attach['aid'].'\', 0, event)" /></a>' :
+ $replacement .= ($attachrefcheck || $attach['remote']) && !($attach['remote'] && substr($ftp['attachurl'], 0, 3) == 'ftp' && !$ftp['hideurl']) ? '<a href="'.$bbsdir.'/attachment.php?aid='.$attach['aid'].'&noupdate=yes&nothumb=yes" target="_blank"><img src="'.$bbsdir.'/attachment.php?aid='.$attach['aid'].'" border="0" alt="'.$language['attach_img_thumb'].'" onmouseover="attachimginfo(this, \'attach_'.$attach['aid'].'\', 1)" onmouseout="attachimginfo(this, \'attach_'.$attach['aid'].'\', 0, event)" /></a>' :
'<a href="'.$attach['url'].'/'.$attach['attachment'].'" target="_blank"><img src="'.$attach['url'].'/'.$attach['attachment'].'.thumb.jpg" border="0" alt="'.$language['attach_img_thumb'].'" onmouseover="attachimginfo(this, \'attach_'.$attach['aid'].'\', 1)" onmouseout="attachimginfo(this, \'attach_'.$attach['aid'].'\', 0, event)" /></a>';
} else {
- $replacement .= ($attachrefcheck || $attach['remote']) && !($attach['remote'] && substr($ftp['attachurl'], 0, 3) == 'ftp' && !$ftp['hideurl']) ? '<img src="attachment.php?aid='.$attach['aid'].'&noupdate=yes" border="0" onload="attachimg(this, \'load\', \''.$language['attach_img_zoom'].'\')" onmouseover="attachimginfo(this, \'attach_'.$attach['aid'].'\', 1);attachimg(this, \'mouseover\')" onclick="attachimg(this, \'click\', \'attachment.php?aid='.$attach['aid'].'\')" onmouseout="attachimginfo(this, \'attach_'.$attach['aid'].'\', 0, event)" onmousewheel="return imgzoom(this)" alt="" />' :
+ $replacement .= ($attachrefcheck || $attach['remote']) && !($attach['remote'] && substr($ftp['attachurl'], 0, 3) == 'ftp' && !$ftp['hideurl']) ? '<img src="'.$bbsdir.'/attachment.php?aid='.$attach['aid'].'&noupdate=yes" border="0" onload="attachimg(this, \'load\', \''.$language['attach_img_zoom'].'\')" onmouseover="attachimginfo(this, \'attach_'.$attach['aid'].'\', 1);attachimg(this, \'mouseover\')" onclick="attachimg(this, \'click\', \''.$bbsdir.'/attachment.php?aid='.$attach['aid'].'\')" onmouseout="attachimginfo(this, \'attach_'.$attach['aid'].'\', 0, event)" onmousewheel="return imgzoom(this)" alt="" />' :
'<img src="'.$attach['url'].'/'.$attach['attachment'].'" border="0" onload="attachimg(this, \'load\', \''.$language['attach_img_zoom'].'\')" onmouseover="attachimginfo(this, \'attach_'.$attach['aid'].'\', 1);attachimg(this, \'mouseover\')" onclick="attachimg(this, \'click\', \''.addslashes("$attach[url]/$attach[attachment]").'\')" onmouseout="attachimginfo(this, \'attach_'.$attach['aid'].'\', 0, event)" onmousewheel="return imgzoom(this)" alt="" />';
}
$replacement .= '<span style="display:none" id="attach_'.$attach['aid'].'" onmouseover="showMenu(this.id, 0, 1)"><img src="'.IMGDIR.'/attachimg.gif" border="0"></span>';
$exthtml .= '<div title="menu" class="t_attach" id="attach_'.$attach['aid'].'_menu" style="display: none">'.
- $attach['attachicon'].' <a href="attachment.php?aid='.$attach['aid'].'&nothumb=yes" target="_blank" class="bold">'.$attach['filename'].'</a> ('.$attach['attachsize'].')<br>'.
+ $attach['attachicon'].' <a href="'.$bbsdir.'/attachment.php?aid='.$attach['aid'].'&nothumb=yes" target="_blank" class="bold">'.$attach['filename'].'</a> ('.$attach['attachsize'].')<br>'.
($attach['description'] ? $attach['description'].'<br>' : '');
} else {
- $replacement .= $attach['attachicon'].' <span style="white-space:nowrap" id="attach_'.$attach['aid'].'" onmouseover="showMenu(this.id)"><a href="attachment.php?aid='.$attach['aid'].'" target="_blank" class="bold">'.$attach['filename'].'</a> ('.$attach['attachsize'].')</span>';
+ $replacement .= $attach['attachicon'].' <span style="white-space:nowrap" id="attach_'.$attach['aid'].'" onmouseover="showMenu(this.id)"><a href="'.$bbsdir.'/attachment.php?aid='.$attach['aid'].'" target="_blank" class="bold">'.$attach['filename'].'</a> ('.$attach['attachsize'].')</span>';
- $exthtml .= '<div title="menu" class="t_attach" id="attach_'.$attach['aid'].'_menu" style="display: none">'.$attach['attachicon'].' <a href="attachment.php?aid='.$attach['aid'].'" target="_blank" class="bold">'.$attach['filename'].'</a> ('.$attach['attachsize'].')<br>'.
+ $exthtml .= '<div title="menu" class="t_attach" id="attach_'.$attach['aid'].'_menu" style="display: none">'.$attach['attachicon'].' <a href="'.$bbsdir.'/attachment.php?aid='.$attach['aid'].'" target="_blank" class="bold">'.$attach['filename'].'</a> ('.$attach['attachsize'].')<br>'.
($attach['description'] ? $attach['description'].'<br>' : '').
$language['attach_downloads'].': '.$attach['downloads'].'<br>'.
($attach['readperm'] ? $language['attach_readperm'].': '.$attach['readperm'].'<br>' : '');
}
$exthtml .= ($attach['price'] ? $language['price'].': '.$extcredits[$creditstrans]['title'].' '.$attach['price'].' '.$extcredits[$creditstrans]['unit'].' <a href="misc.php?action=viewattachpayments&aid='.$aid.'" target="_blank">['.$language['pay_view'].']</a>'.
- ($attach['payed'] ? '' : ' <a href="misc.php?action=attachpay&aid='.$attach['aid'].'" target="_blank">['.$language['attachment_buy'].']</a>') : '').'<div class="right smalltxt">'.$attach['dateline'].'</div></div>';
+ ($attach['payed'] ? '' : ' <a href="'.$bbsdir.'/misc.php?action=attachpay&aid='.$attach['aid'].'" target="_blank">['.$language['attachment_buy'].']</a>') : '').'<div class="right smalltxt">'.$attach['dateline'].'</div></div>';
return $replacement;
} else {
Modified: trunk/upload/templates/babel/viewthread.htm
==============================================================================
--- trunk/upload/templates/babel/viewthread.htm (original)
+++ trunk/upload/templates/babel/viewthread.htm Sat Jun 21 04:33:13 2008
@@ -119,7 +119,7 @@
<script type="text/javascript">
function setanswer(pid){
if(confirm("{lang reward_set_bestanswer_confirm}")){
- document.delpost.action='misc.php?action=bestanswer&tid=$thread['tid']&pid=' + pid + '&bestanswersubmit=yes';
+ document.delpost.action='$bbsdir/misc.php?action=bestanswer&tid=$thread['tid']&pid=' + pid + '&bestanswersubmit=yes';
document.delpost.submit();
}
}
@@ -130,9 +130,9 @@
<!--{else}-->
<div id="message$post[pid]" class="t_msgfont">$post[message]</div>
<!--{if $post['attachment']}-->
- <br><br><img src="images/attachicons/common.gif" alt="" /> {lang attachment}: <i>{lang attach_nopermission}</i>
+ <br><br><img src="$bbsdir/images/attachicons/common.gif" alt="" /> {lang attachment}: <i>{lang attach_nopermission}</i>
<!--{elseif $hideattach && $post['attachments']}-->
- <br><br><img src="images/attachicons/common.gif" alt="" /> {lang attachment}: <i>{lang attachment_reply_show}</i>
+ <br><br><img src="$bbsdir/images/attachicons/common.gif" alt="" /> {lang attachment}: <i>{lang attachment_reply_show}</i>
<!--{elseif $post['attachlist']}-->
<br><br>
<div class="msgbody">
@@ -147,7 +147,7 @@
<!--{if !empty($post['ratelog'])}-->
<div class="rate">
<fieldset>
- <legend><a href="misc.php?action=viewratings&tid=$tid&pid=$post[pid]" title="{lang rate_view}">{lang thread_rate_log_lately}</a></legend>
+ <legend><a href="$bbsdir/misc.php?action=viewratings&tid=$tid&pid=$post[pid]" title="{lang rate_view}">{lang thread_rate_log_lately}</a></legend>
<ul>
<!--{loop $post['ratelog'] $ratelog}--><li><cite><a href="$bbsdir/space.php?uid=$ratelog[uid]" target="_blank">$ratelog[username]</a></cite>{$extcredits[$ratelog[extcredits]][title]}<strong>$ratelog[score]</strong>
<em>$ratelog[reason]</em>$ratelog[dateline]</li><!--{/loop}-->
@@ -204,9 +204,9 @@
<!--{else}-->
<span style="font-size: {MSGFONTSIZE};" id="pid_$post['pid']">$post[message]</span>
<!--{if $post['attachment']}-->
- <br><br><img src="images/attachicons/common.gif" alt="" /> {lang attachment}: <i>{lang attach_nopermission}</i>
+ <br><br><img src="$bbsdir/images/attachicons/common.gif" alt="" /> {lang attachment}: <i>{lang attach_nopermission}</i>
<!--{elseif $hideattach && $post['attachments']}-->
- <br><br><img src="images/attachicons/common.gif" alt="" /> {lang attachment}: <i>{lang attachment_reply_show}</i>
+ <br><br><img src="$bbsdir/images/attachicons/common.gif" alt="" /> {lang attachment}: <i>{lang attachment_reply_show}</i>
<!--{elseif $post['attachlist']}-->
<br><br>
<div class="msgbody">
@@ -221,7 +221,7 @@
<!--{if !empty($post['ratelog'])}-->
<div class="rate">
<fieldset>
- <legend><a href="misc.php?action=viewratings&tid=$tid&pid=$post[pid]" title="{lang rate_view}">{lang thread_rate_log_lately}</a></legend>
+ <legend><a href="$bbsdir/misc.php?action=viewratings&tid=$tid&pid=$post[pid]" title="{lang rate_view}">{lang thread_rate_log_lately}</a></legend>
<ul>
<!--{loop $post['ratelog'] $ratelog}--><li><cite><a href="$bbsdir/space.php?uid=$ratelog[uid]" target="_blank">$ratelog[username]</a></cite>{$extcredits[$ratelog[extcredits]][title]}<strong>$ratelog[score]</strong>
<em>$ratelog[reason]</em>$ratelog[dateline]</li><!--{/loop}-->
@@ -260,6 +260,10 @@
theform.replysubmit.disabled = true;
return true;
}
+ var advReply = function () {
+ location.href = '$bbsdir/reply-$fid-$tid-$page\.html' ;
+ return true;
+ }
</script>
<div class="light_odd">
<form method="post" id="postform" action="$bbsdir/post.php?action=reply&fid=$fid&tid=$tid&extra=$extra&replysubmit=yes" onSubmit="return validate(this)">
@@ -278,6 +282,7 @@
<div class="left">
<input class="button" type="submit" name="replysubmit" id="postsubmit" value="{lang post_topicsubmit}" tabindex="3" title="{lang post_submit_hotkey}">
</div>
+ <input type="button" class="lightbutton" value="��ģʽ" title="��ģʽ" onclick="advReply();" tabindex="4">
<input type="submit" name="previewpost" class="lightbutton" value="{lang post_previewpost}" tabindex="4">
<input type="button" class="lightbutton" name="restoredata" id="restoredata" value="{lang post_autosave_restore}" tabindex="5" title="{lang post_autosave_last_restore}" onclick="loadData()">
<input type="reset" name="topicsreset" class="lightbutton" value="{lang post_topicreset}" tabindex="6">
@@ -322,7 +327,7 @@
<div class="light_odd" align="left">
<span class="tip"><img src="{IMGDIR}/vcard.png" align="absmiddle" /> �ڻظ�֮ǰ����Ҫ�Ƚ��е�¼</span>
<table cellpadding="0" cellspacing="0" border="0" class="form">
- <form method="post" name="login" action="logging.php?action=login&">
+ <form method="post" name="login" action="$bbsdir/logging.php?action=login&">
<input type="hidden" name="formhash" value="{FORMHASH}">
<input type="hidden" name="referer" value="$_SERVER['REQUEST_URI']">
<input type="hidden" name="loginsubmit" value="��¼">