<!--#include file="conn.asp" -->
<!--#include file="inc/const.asp" -->
<%
	dim ArticleID,rootid,Title,reNum,avgGrade,selArticleID,Rs,SQL,classid
	dim CurrentPage,MaxPerPage,totalnumber,Pcount
	dim DownloadClass_Ads,NC_ArticleEssay
        DownsysClass.LoadTemplates ("article")
        Set DownloadClass_Ads = New Adcolumn_Cls
	Set Rs = Server.CreateObject("adodb.recordset")
	if not isnumeric(request("id")) and request("id")<>"" then
  	        response.write"错误的系统参数!ID必须是数字"
		response.end
	end if
	if request("id")="0" or request("id")="" then
		response.write "Sorry！错误的系统参数,请选择正确的连接方式。"
		response.end
	else
		ArticleID = Clng(request("id"))
	end if
	SQL="select ID,Title,classid from [NC_Article] where ID = "& ArticleID
	Rs.open SQL,conn,1,1 
	if Rs.bof and Rs.eof then
		response.write  "Sorry！没有找到任何文章信息。或者您选择了错误的系统参数!"
	else
		Title=trim(Rs("Title"))
		classid=trim(Rs("classid"))
	end if
	Rs.close
	SQL="select count(ID) as reNum,AVG(Grade) as avgGrade from NC_ArticleEssay where ArticleID = "& ArticleID
	Rs.open SQL,conn,1,1 
		reNum=Rs("reNum")
		avgGrade=Rs("avgGrade")
	Rs.close

Dim NowStats,HtmlTitle,Style_CSS,HtmlTempStr
Dim TempTopStr,TempFootStr
        NowStats = "文章评论"
        HtmlTitle = "文章评论"
        TempTopStr = DownsysClass.mainhtml(0) & DownsysClass.mainhtml(1) & DownsysClass.mainhtml(2) & DownsysClass.mainhtml(3)
        TempFootStr = DownsysClass.mainhtml(4)
        Style_CSS = Replace(Replace(DownsysClass.Style_CSS, "{$SetupDir}", DownsysClass.SetupDir), "{$PicUrl}", DownsysClass.TempDir)
        HtmlTempStr = TempTopStr
        HtmlTempStr = Replace(HtmlTempStr, "{$NavMenu}", DownsysClass.SortingMenu)
        HtmlTempStr = Replace(HtmlTempStr, "{$Width}", DownsysClass.mainset(0))
        HtmlTempStr = Replace(HtmlTempStr, "{$Style_CSS}", Style_CSS)
        If CInt(DownsysClass.Setting(5)) = 0 Then
                HtmlTempStr = Replace(HtmlTempStr, "{$TopMeun}", DownsysClass.mainset(9))
        Else
                HtmlTempStr = Replace(HtmlTempStr, "{$TopMeun}", DownsysClass.mainset(10))
        End If
        HtmlTempStr = Replace(HtmlTempStr, "{$NowStats}", NowStats)
        HtmlTempStr = Replace(HtmlTempStr, "{$Title}", HtmlTitle)
        HtmlTempStr = Replace(HtmlTempStr, "{$Adcolumn(0)}", DownloadClass_Ads.RunScriptAds(6))
        HtmlTempStr = Replace(HtmlTempStr, "{$Adcolumn(1)}", DownloadClass_Ads.BannerAds(6))
        HtmlTempStr = Replace(HtmlTempStr, "{$Adcolumn(2)}", DownloadClass_Ads.AdsColumn(6, 2))
        HtmlTempStr = Replace(HtmlTempStr, "{$Adcolumn(3)}", DownloadClass_Ads.AdsColumn(6, 3))
	Response.write HtmlTempStr
        TempFootStr = Replace(TempFootStr, "{$FootMeun}", DownsysClass.mainset(11))
        TempFootStr = Replace(TempFootStr, "{$Width}", DownsysClass.mainset(0))
        TempFootStr = Replace(TempFootStr, "{$Adcolumn(4)}", DownloadClass_Ads.ScriptFloatAds(6))
        TempFootStr = Replace(TempFootStr, "{$Adcolumn(5)}", DownloadClass_Ads.ScriptFixedAds(6))
%>
<SCRIPT LANGUAGE=javascript>
<!--
function Juge(myform)
{
    if (document.myform.UserName.value==""){
       alert ("你的用户名不可为空！");
       document.myform.UserName.focus();
       return(false);
    }
	if ((document.myform.Email.value.indexOf("@") == -1) || (document.myform.Email.value.indexOf(".") == -1)){
		alert("请查看您的E-mail地址是否正确，请重录入!");
		document.myform.Email.focus();
       return(false);
	}
	

	if (myform.content.value == "")
	{
		alert("评论内容不能为空！");
		myform.content.focus();
                return (false);
	}
}
function SelectAll() {
	for (var i=0;i<document.selform.selArticleID.length;i++) {
		var e=document.selform.selArticleID[i];
		e.checked=!e.checked;
	}
}

//-->
</script>
<TABLE width="<%=DownsysClass.mainset(0)%>" class=TableBorder cellSpacing=0 cellPadding=0 align=center border=0>
    <tr valign="top">
      <td width="25%" bgcolor="#F7FBFF"><table width="100%" align="center" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td height="26" align="center" background="<%=DownsysClass.SetupDir & DownsysClass.TempDir%>table_bg.gif"><strong> 站内搜索</strong></td>
        </tr>
        <tr height="50"><form method=post name=form action="<%=DownsysClass.SetupDir%>search.asp" target="_blank">
          <td align="center">
              <input name="keyword" type="text" size="25">
              <br>
              <select name="action">    
                <option value="info">文章搜索</option>
				<option value="soft">软件搜索</option>
                <option value="web">网站搜索</option>
              </select>
              &nbsp;<input type="submit" name="Submit" value="开始搜索">
          </td></form>
        </tr>
          <tr>
          <td height="26" align="center" background="<%=DownsysClass.SetupDir & DownsysClass.TempDir%>table_bg.gif"><strong>下载总排行</strong></td>
        </tr>
        <tr valign="top">
          <td><SCRIPT LANGUAGE=JavaScript src=<%=DownsysClass.SetupDir%>JS/ArticleTop/HotTop.JS></SCRIPT></td>
        </tr>
        <tr>
          <td height="26" align="center" background="<%=DownsysClass.SetupDir & DownsysClass.TempDir%>table_bg.gif"><strong>本类下载排行</strong></td>
        </tr>
        <tr valign="top">
          <td><SCRIPT LANGUAGE=JavaScript src=<%=DownsysClass.SetupDir%>JS/ArticleTop/ThisTop<%=classid%>.JS></SCRIPT></td>
        </tr>
      </table>
</td>
      <td width="1" background="<%=DownsysClass.SetupDir & DownsysClass.TempDir%>left_r2.gif">
          <img src="<%=DownsysClass.SetupDir & DownsysClass.TempDir%>left_r2.gif" width="10"></td>
      <td width="75%" valign="top">
<%
      if not isempty(request("selArticleID")) then
            selArticleID=request("selArticleID")
            if request("action")="del" then
                        call delessay()
            else
                  response.write "无效参数！"
                  response.end
            end if			
  	end if 
	if not isempty(request("page")) then
      		CurrentPage=cint(request("page"))
   	else
      		CurrentPage=1
   	end if

	MaxPerPage = 10  '###每页显示数
	if not isnumeric(request("page")) and request("page")<>"" then
  	        response.write"错误的系统参数!请输入整数"
		response.end
	end if
%>
<TABLE width="100%" cellSpacing=0 cellPadding=0 align=center border=0>
 <TR>
    <Th align="left">　文章评论</Th>
 </TR></TABLE>
<TABLE width="98%" bgcolor="#CECECE" cellSpacing=1 cellPadding=4 align=center border=0>
 <TR class=Border1>
    <TD width="20%" align=center>评论文章</TD>
    <TD width="80%"> 
<%If CInt(DownsysClass.Setting(5)) = 0 Then%>
      <A HREF=<%=DownsysClass.SetupDir%>Article/catalog<%=classid%>/<%=ArticleID%>.html><%=Title%></A>
<%Else%>
      <A HREF=Article.asp?id=<%=ArticleID%>><%=Title%></A>
<%End If%>
    </TD>
 </TR>
 <TR class=Border2>
    <TD align=center>评论情况</TD>
    <TD>共有 <font color="#FF0000"><%=reNum%></font> 人参与评价，评均得分：<font color="#FF0000"><%=cint(avgGrade)%></font> 分</TD>
 </TR><form name="selform" method="post" action="">
<%
SQL="select * from [NC_ArticleEssay] where ArticleID="& ArticleID &" order by ID desc" 
	Rs.open SQL,conn,1,1
	if Rs.eof and Rs.bof then 
      response.write "<TR class=Border2><TD colSpan=2>没有评论</TD></TR>" 
   	else
            totalnumber=Rs.recordcount
		    if (totalnumber mod MaxPerPage)=0 then 
	     			Pcount= totalnumber \ MaxPerPage 
	   		else 
	      			Pcount= totalnumber \ MaxPerPage + 1 
	   		end if 
Rs.MoveFiRst
	if currentpage > Pcount then currentpage = Pcount
   	if currentpage<1 then currentpage=1
                                Rs.move  (currentPage-1)*MaxPerPage 
           			dim bookmark,i 
            			bookmark=Rs.bookmark  
	   	i=0 	
do while not Rs.eof and i < Clng(MaxPerPage)
%>
 <TR class=Border1>
    <TD colSpan=2>用户：<%=Rs("username")%> 打分：<%=Rs("Grade")%>分 Email：<%=Rs("usermail")%> 时间：<%=Rs("postime")%> 来自：<%=Rs("postip")%></TD>
 </TR>
 </TR>
 <TR class=Border2>
    <TD colSpan=2><%if session(DownsysClass.CacheName & "AdminName")<>"" then%><input type="checkbox" name="selArticleID" value="<%=Rs("id")%>"><%end if%> <%=Rs("Content")%></TD>
 </TR>
<%
      Rs.movenext
        i=i+1
	 if i>=MaxPerPage then exit do
	               loop
	end if
	Rs.close
%>
 <TR class=Border1>
    <TD colSpan=2><%call showpage()%></TD>
 </TR>
<%if session(DownsysClass.CacheName & "AdminName")<>"" then%>
 <TR class=Border2>
    <TD align=center>管理操作</TD>
    <TD> <a href="javascript:SelectAll()">全选/反选</a><input type="checkbox" name="checkbox" value="checkbox" onClick="javascript:SelectAll()">
	<input type="Hidden" name="id" value="<%=request("id")%>">
	<input type="Hidden" name="action" value="del">
<input type="submit" name="Submit" value="删除评论" class=button onclick="{if(confirm('您确定执行的操作吗?')){this.document.selform.submit();return true;}return false;}"></TD>
 </TR>
<%end if%>
</form>
</table>
<BR style="OVERFLOW: hidden; LINE-HEIGHT: 3px">
                  <table width="98%" border="0" cellpadding="1" align=center cellspacing="1" bgcolor="#E5E5E5">
                    <form name="myform" method="post" action="" target="_top" onSubmit="return Juge(this)" >
                      <tr bgcolor="#FCFCFC"> 
                        <td>用 户：</td>
                        <td> 
                          <input type="text" name="UserName" maxlength="15" size="28"> 
                          <font color="#FF0000">！</font> </td>
                        <td>Email：</td>
                        <td> 
                          <input type="text" name="Email" maxlength="50" size="28"> 
                          <font color="#FF0000">！</font><input type="Hidden" name="ArticleID" value='<%=request("id")%>'> 
                          <input type="Hidden" name="action" value='savessay'> </td>
                      </tr>
                      <tr bgcolor="#FCFCFC"> 
                        <td>分 值：</td>
                        <td colSpan=3> 
                          <input type="radio" name="Grade" value="100">100分 
                          <input type="radio" name="Grade" value="85" checked>85分 
                          <input type="radio" name="Grade" value="70">70分 
                          <input type="radio" name="Grade" value="55">55分 
                          <input type="radio" name="Grade" value="40">40分 
                          <input type="radio" name="Grade" value="25">25分 
                          <input type="radio" name="Grade" value="10">10分 
                          <input type="radio" name="Grade" value="0">0分</td>
                      </tr>
                      <tr bgcolor="#FCFCFC"> 
                        <td>说 明：</td>
                        <td colSpan=3> 
                          <textarea name="content" cols="65" rows="5" title="请注意用语文明且合法，不要发布带有攻击性的言论，谢谢合作！"></textarea><font color="#FF0000">！</font> </td>
                      </tr>
                      <tr bgcolor="#FCFCFC"> 
                        <td>　</td>
                        <td colSpan=3> 
                          <input type="submit" name="Submit" value="发表评论"> 
                          <input type="reset" name="Submit2" value="重 设">
                          (注：“<font color="#FF0000">！</font>”为必填内容。) </td>
                      </tr>
                    </form>
                  </table>
<BR style="OVERFLOW: hidden; LINE-HEIGHT: 3px">
</TD>
 </TR></TABLE>
<%
	if request("action")="savessay" then
		if cint(DownsysClass.Setting(40))=1 then
		if Len(Request.form("content")) > Clng(DownsysClass.TempSet(10)) then Response.write ("<script>alert('对不起!评论字符超过了限制。');javascript:history.back(1)</script>"):Response.end
			SQL="select * from NC_ArticleEssay where (ID is null)"
			Rs.open SQL,conn,1,3
			Rs.addnew
				Rs("ArticleID")=ArticleID
				Rs("UserName")=DownsysClass.HTMLEncode(trim(request.form("UserName")))
				Rs("usermail")=trim(request.form("Email"))
				Rs("Grade")=trim(request.form("Grade"))	
				Rs("content")=DownsysClass.HTMLEncode(request.form("content"))
				Rs("postime")=Now()
				Rs("postip")=DownsysClass.GetUserip
			Rs.update	
			Rs.close
		response.redirect(Request.ServerVariables("HTTP_REFERER"))
		else
			Response.write"<script>alert('" & DownsysClass.TempSet(11) &"');javascript:history.back(1)</script>"
			Response.end
		end if
	end if
sub delessay()
	if session(DownsysClass.CacheName & "AdminName")<>"" then
		conn.execute("delete from NC_ArticleEssay where id in ("&selArticleID&")")
	else
		Response.write"<script>alert('对不起!你没有权限删除此文章评论。');javascript:history.back(1)</script>"
		Response.end
	end if
end sub

sub showpage()
  	dim filename,ii,n
  	filename="softessay.asp"
  	if totalnumber mod maxperpage=0 then
     		n= totalnumber \ maxperpage
  	else
     		n= totalnumber \ maxperpage+1
  	end if
  	response.write "<table cellspacing=1 width='100%' border=0><tr><td align=center> "& vbCrLf
  	if CurrentPage<2 then
    		response.write " 共有评论 <font COLOR=#FF0000>"&totalnumber&"</font> 个&nbsp;&nbsp;首 页&nbsp;&nbsp;上一页&nbsp;&nbsp;&nbsp;"
  	else
    		response.write "共有评论 <font COLOR=#FF0000>"&totalnumber&"</font> 个&nbsp;&nbsp;<a href="&filename&"?page=1&id="&request("id")&">首 页</a>&nbsp;&nbsp;"
    		response.write "<a href="&filename&"?page="&CurrentPage-1&"&id="&request("id")&">上一页</a>&nbsp;&nbsp;&nbsp;"
  	end if

  	if n-currentpage<1 then
    		response.write "下一页&nbsp;&nbsp;尾 页 "& vbCrLf
  	else
    		response.write "<a href="&filename&"?page="&(CurrentPage+1)&"&id="&request("id")&">下一页</a>"
    		response.write "&nbsp;&nbsp;<a href="&filename&"?page="&n&"&id="&request("id")&">尾 页</a>"& vbCrLf
  	end if
   	response.write "&nbsp;页次：<strong><font color=red>"&CurrentPage&"</font>/"&n&"</strong>页 "
    	response.write "&nbsp;<b>"&maxperpage&"</b>个/页 "& vbCrLf

	response.write "</td></tr></table>"& vbCrLf
end sub

Response.Write TempFootStr
If IsObject(DownloadClass_Ads) Then
	Set DownloadClass_Ads = Nothing
End If
CloseConn
%>