<!--#include file="conn.asp" -->
<!--#include file="inc/const.asp"-->
<%
Dim softid, rootid, softname, reNum, avgGrade, selSoftid, Rs, SQL, sortid
Dim CurrentPage, MaxPerPage, totalnumber, Pcount
Dim DownloadClass_Ads, NC_SoftEssay,DownloadClass,IsCreateHtml
DownsysClass.LoadTemplates ("softinfo")
Set DownloadClass_Ads = New Adcolumn_Cls
Set Rs = Server.CreateObject("adodb.recordset")
If Not IsNumeric(request("id")) And request("id")<>"" Then
	response.Write"Sorry！错误的系统参数!ID必须是数字"
	response.End
End If
If request("id") = "0" Or request("id") = "" Then
	response.Write "Sorry！错误的系统参数,请选择正确的连接方式。"
	response.End
Else
	softid = CLng(request("id"))
End If
sql = "select softid,softname,softver,sortid from [NC_softinfo] where softid="&softid
rs.Open sql, conn, 1, 1
If rs.bof And rs.EOF Then
	response.Write "Sorry！没有找到任何软件信息。或者您选择了错误的系统参数!"
Else
	softname = Trim(rs("softname"))&" "&Trim(rs("softver"))
	sortid = Trim(rs("sortid"))
End If
rs.Close
sql = "select count(ID) as reNum,AVG(Grade) as avgGrade from NC_SoftEssay where SoftID="&softid&""
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(3))
HtmlTempStr = Replace(HtmlTempStr, "{$Adcolumn(1)}", DownloadClass_Ads.BannerAds(3))
HtmlTempStr = Replace(HtmlTempStr, "{$Adcolumn(2)}", DownloadClass_Ads.AdsColumn(3, 2))
HtmlTempStr = Replace(HtmlTempStr, "{$Adcolumn(3)}", DownloadClass_Ads.AdsColumn(3, 3))
Response.Write HtmlTempStr
If CInt(DownsysClass.Setting(5)) = 1 Then
	TempFootStr = Replace(TempFootStr, "{$FootMeun}", DownsysClass.mainset(11))
Else 
	TempFootStr = Replace(TempFootStr, "{$FootMeun}", DownsysClass.mainset(44))
End If
TempFootStr = Replace(TempFootStr, "{$Width}", DownsysClass.mainset(0))
TempFootStr = Replace(TempFootStr, "{$Adcolumn(4)}", DownloadClass_Ads.ScriptFloatAds(3))
TempFootStr = Replace(TempFootStr, "{$Adcolumn(5)}", DownloadClass_Ads.ScriptFixedAds(3))
%>
<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.selSoftid.length;i++) {
		var e=document.selform.selSoftid[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="soft">软件搜索</option>
		<option value="info">文章搜索</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/SoftTop/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/SoftTop/ThisTop<%=sortid%>.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("selSoftid")) Then
	selSoftid = request("selSoftid")
	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%>software/catalog<%=sortid%>/<%=softid%>.html><%=softname%></A>
<%Else%>
      <A HREF=software.asp?id=<%=softid%>><%=softname%></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_SoftEssay] where softid="&softid&" 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)
		If Not Response.IsClientConnected Then responseend
%>
 <TR class=Border1>
    <TD colSpan=2>评论人：<%=rs("username")%>  打分：<%=rs("Grade")%>分  Email：<%=rs("usermail")%> 
	<BR style="OVERFLOW: hidden; LINE-HEIGHT: 3px">评论时间：<%=rs("postime")%>  来自：<%=rs("postip")%>
	</TD>
 </TR>
 </TR>
 <TR class=Border2>
    <TD colSpan=2><%if session(DownsysClass.CacheName & "AdminName")<>"" then%><input type="checkbox" name="selSoftid" 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="SoftEssay.Asp" target="_top" onSubmit="return Juge(this)" >
		      <tr bgcolor="#FCFCFC">
			<td align="center">评论人：</td>
			<td>
			  <input type="text" name="UserName" maxlength="15" size="28">
			  <font color="#FF0000">！</font> </td>
			<td align="center">Email：</td>
			<td>
			  <input type="text" name="Email" maxlength="50" size="28">
			  <font color="#FF0000">！</font><input type="Hidden" name="id" value='<%=softid%>'>
			  <input type="Hidden" name="action" value='savessay'> </td>
		      </tr>
		      <tr bgcolor="#FCFCFC">
			<td align="center">分 值：</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 align="center">内 容：</td>
			<td colSpan=3>
			  <textarea name="content" cols="75" 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
	Dim EssayID
	EssayID = Request("id")
	If CInt(DownsysClass.Setting(38)) = 1 Then
		If request.Cookies("Essay_"&EssayID) = "DownsysClassEssay_" &EssayID Then
			Response.Write ("<script>alert('对不起!你已经参与过评论。');javascript:history.back(1)</script>")
			Response.End
		End If
		Response.Cookies("Essay_"&EssayID) = "DownsysClassEssay_" &EssayID
		Response.Cookies("Essay_"&EssayID).expires = Date + 365
		If Len(Request.Form("content")) > CLng(DownsysClass.TempSet(7)) Then
			Response.Write ("<script>alert('对不起!评论字符超过了限制。');javascript:history.back(1)</script>")
			Response.End
		End If
		sql = "select * from NC_SoftEssay where (ID is null)"
		rs.Open sql, conn, 1, 3
		rs.addnew
		rs("SoftID") = SoftID
		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(12) &"');javascript:history.back(1)</script>"
		Response.End
	End If
End If

Sub delessay()
	If session(DownsysClass.CacheName & "AdminName")<>"" Then
		conn.Execute("delete from NC_SoftEssay where id in ("&selSoftid&")")
	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
%>
