#####################################################
#  LEO SuperCool BBS / LeoBBS X / 雷傲極酷超級論壇  #
#####################################################
# 基於山鷹(糊)、花無缺製作的 LB5000 XP 2.30 免費版  #
#   新版程式製作 & 版權所有: 雷傲科技 (C)(R)2004    #
#####################################################
#      主頁地址： http://www.LeoBBS.com/            #
#      論壇地址： http://bbs.LeoBBS.com/            #
#####################################################

    if ($startnewthreads eq "onlysub") {&error("發表&對不起，這裡是純子論壇區，不准許\發言！"); }
    $testentry = $query->cookie("forumsallowed$inforum");
    if ((($testentry eq $forumpass)&&($testentry ne ""))||($allowedentry{$inforum} eq "yes")||($membercode eq "ad")||($membercode eq 'smo')||($inmembmod eq "yes")) { $allowed = "yes"; }
    if (($privateforum eq "yes") && ($allowed ne "yes")) { &error("發表&對不起，您不准許\在此論壇發表！"); }
    if ($postopen eq "no") { &error("發表或回覆主題&對不起，本論壇不准許\發表或回覆主題！"); }
    &error("普通錯$div_wrong&訪客不能查看文章內容，請註冊或登入後再試") if (($guestregistered eq "off")&&($inmembername eq "訪客"));

    open(FILE, "${lbdir}forum$inforum/$intopic.thd.cgi");
    @threads = <FILE>;
    close(FILE);
    $posttoget = $inpostno - 1;

    ($membername, $topictitle, $postipaddress, $showemoticons, $showsignature ,$postdate, $post, $posticon) = split(/\t/, $threads[$posttoget]);
    $topictitle =~ s/^＊＃！＆＊//;

    my $filetoopens = "$lbdir" . "data/onlinedata.cgi";
    $filetoopens = &lockfilename($filetoopens);
    if (!(-e "$filetoopens.lck")) {
	if ($privateforum ne "yes") {
	    &whosonline("$inmembername\t$forumname\tnone\t引用回覆<a href=\"topic.cgi?forum=$inforum&topic=$intopic\"><b>$topictitle</b></a>\t");
	}
	else {
    	    &whosonline("$inmembername\t$forumname(密)\tnone\t引用回覆保密文章\t");
	}
    }

    if ((($onlinetime + $onlinetimeadd) < $onlinepost)&&($onlinepost ne "")&&($membercode ne "ad")&&($membercode ne "smo")&&($membercode ne "cmo")&&($membercode ne "mo")&&($membercode ne "amo")&&($membercode !~ /^rz/))     {  $onlinetime = $onlinetime + $onlinetimeadd; &error("回覆主題&對不起，本論壇不准許\在線時間少於 $onlinepost 秒的會員回覆主題！你目前已經在線 $onlinetime 秒！"); }

    &getmember($membername,"no");
    $post = "此會員的發言已經被屏蔽！" if ($membercode eq "masked");
    $membercode = $mymembercode;
	
    if  ($post=~/LBHIDDEN\[(.*?)\]LBHIDDEN/sg){
	$checked=$1;
	if ((lc($inmembername) eq lc($membername))||($mymembercode eq "ad") || ($mymembercode eq 'smo') || ($mymembercode eq "mo") || ($mymembercode eq "amo") || ($inmembmod eq "yes")|| ($myrating >= $1) ){
	    $weiwangoptionbutton=~s/value=$checked/value=$checked selected/isg;
	    $weiwangoptionbutton=~s/value=\"yes\" /value=\"yes\" checked /;
	}
	undef $checked;
	$post="(保密文章)";
    }
    if  ($post=~/LBSALE\[(.*?)\]LBSALE/sg){
	$post="(保密文章)";
    }

    $post =~ s/\[post=(.+?)\](.+?)\[\/post\]//isg;
    $post =~ s/\[jf=(.+?)\](.+?)\[\/jf\]//isg;
    $post =~ s/\[hide\](.+?)\[\/hide\]//isg;
    $post =~ s/\[watermark\](.+?)\[\/watermark\]/\n\(水印部分不能引用\)\n/isg;
    $post =~ s/(\&\#35\;|#)Moderation Mode//isg;
    $post =~ s/\<p\>/\n\n/ig;
    $post =~ s/\<br\>/\n/ig;
    $post =~ s/ \&nbsp;/  /ig;
    $post =~ s/\[curl=\s*(http|https|ftp):\/\/(.*?)\s*\]/\[加密連結\]/isg if ($usecurl ne "no");
    $post =~ s/\[DISABLELBCODE\]//isg;
    $post =~ s/\[ADMINOPE=(.+?)\]//isg;
    if ($post =~ /\[POSTISDELETE=(.+?)\]/) {
    	if ($1 ne " ") { $presult = "屏蔽理由：$1"; } else { $presult = ""; }
        $post = "此文章內容已經被單獨屏蔽！$presult";
    }

    $membernametemp=$membername;

    $postdate = $postdate + ($timedifferencevalue + $timezone)*3600;
    $postdate = &dateformat("$postdate");
    $rawpost = $post;

    &mischeader("引用回覆文章");

    if ($emoticons eq "on") {
        $emoticonslink = qq~<li><a href="javascript:openScript('misc.cgi?action=showsmilies',300,350)">准許\<B>使用</B>表情字符轉換</a>~;
        $emoticonsbutton =qq~<input type=checkbox name="inshowemoticons" value="yes" checked>您是否希望<b>使用</b>表情字符轉換在您的文章中？<br>~;
    }

    if ($emailfunctions eq "on") {
	if ($innotify eq "yes") { $requestnotify = " checked"; } else { $requestnotify = ""; }
	$requestnotify = qq~<input type=checkbox name="notify" value="yes"$requestnotify>有回覆時使用郵件通知您？<br>~;
    }

    $output .= qq~<script language="javascript">function smilie(smilietext) {smilietext=' :'+smilietext+': ';if (document.FORM.inpost.createTextRange && document.FORM.inpost.caretPos) {var caretPos = document.FORM.inpost.caretPos;caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? smilietext + ' ' : smilietext;document.FORM.inpost.focus();} else {document.FORM.inpost.value+=smilietext;document.FORM.inpost.focus();}}</script>~;
    
    $rawpost =~ s/\[這個(.+?)最後由(.+?)編輯\]\n//isg;
    $rawpost =~ s/LBHIDDEN\[(.*?)\]LBHIDDEN//sg;
    $rawpost =~ s/LBSALE\[(.*?)\]LBSALE//sg;
    $rawpost =~ s/\[quote\](.*)\[quote\](.*)\[\/quote](.*)\[\/quote\]//isg;
    $rawpost =~ s/\[quote\](.*)\[\/quote\]//isg;
    $rawpost =~ s/\[equote\](.*)\[\/equote\]//isg;
    $rawpost =~ s/\[fquote\](.*)\[\/fquote\]//isg;
    $rawpost =~ s/\[hide\](.*)\[hide\](.*)\[\/hide](.*)\[\/hide\]//isg; 
    $rawpost =~ s/\[hide\](.*)\[\/hide\]//isg; 
    $rawpost =~ s/\[post=(.+?)\](.+?)\[\/post\](.*)\[post=(.+?)\](.+?)\[\/post\]//isg; 
    $rawpost =~ s/\[post=(.+?)\](.+?)\[\/post\]//isg; 
    $rawpost =~ s/\[\s*(.*?)\s*\]\s*(.*?)\s*\[\s*(.*?)\s*\]/$2/isg;
    $rawpost =~ s/\:.{0,20}\://isg;
    $rawpost =~ s/\<img\s*(.*?)\s*\>//isg;
    $rawpost =~ s/(http|https|ftp):\/\/(.*?)\.(png|jpg|jpeg|bmp|gif|swf)/($2\.$3)/isg;
    $rawpost =~ s/\&nbsp;/ /ig;
    $rawpost =~ s/( )+$//isg;
    $rawpost =~ s/^( )+//isg;
    $rawpost =~ s/\[.+?\]//g;
    $rawpost =~ s/(\n)+/\n/isg;
    $rawpost =~ s/^\n//isg;
    chomp $rawpost;

    my @postall = split(/\n/,$rawpost);
    my $postall = @postall;
    if ($postall > 4) { $rawpost = "$postall[0]\n$postall[1]\n$postall[2]\n$postall[3]\n..."; }
    $rawpost = &lbhz($rawpost,200);

    $inpost = qq~\[quote\]\[b\]下面引用由\[u\]$membernametemp\[\/u\]在 \[i\]$postdate\[\/i\] 發表的內容：\[\/b\]\n$rawpost\n\[\/quote\]\n~;
    if ($htmlstate eq "on")     { $htmlstates = "可以使用";     } else { $htmlstates = "不可以使用";     }
    if ($idmbcodestate eq "on") { $idmbcodestates = "可以使用"; $canlbcode =qq~<input type=checkbox name="uselbcode" value="yes" checked>使用 LeoBBS 標籤？<br>~; } else { $idmbcodestates = "不可以使用"; $canlbcode= "";}
    if ($useemote eq "no") { $emotestates = "不可以使用"; } else { $emotestates = "可以使用"; }

    $output .= qq~<script>
var autoSave = false;
function storeCaret(textEl) {if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate();if (autoSave)savePost();}
function HighlightAll(theField) {
var tempval=eval("document."+theField)
tempval.focus()
tempval.select()
therange=tempval.createTextRange()
therange.execCommand("Copy")}
</script>
<SCRIPT>valigntop()</SCRIPT>
<table cellpadding=0 cellspacing=0 width=$tablewidth bgcolor=$tablebordercolor align=center>
<tr><td>
<table cellpadding=6 cellspacing=1 width=100%>
<tr><td bgcolor=$titlecolor colspan=2 $catbackpic>
<form action=$thisprog method=post name=FORM enctype="multipart/form-data">
<input type=hidden name=action value=addreply>
<input type=hidden name=forum value=$inforum>
<input type=hidden name=topic value=$intopic>
<font color=$titlefontcolor><b>主題標題</b>： $topictitle</td></tr>
~;
    &posttable(2);
    require "dothreadreview.pl";
1;
