<%
Response.ContentType="text/html"
Response.Expires = -9999
Response.AddHeader "pragma", "no-cache"
Response.AddHeader "cache-ctrol", "no-cache"
NewAsp.ChkPostAgent()
Dim softid,sType,s,m,PJ_CookieName
Dim goodnum,badnum,totalscore,maxwidth,goodwidth,badwidth,goodpercent,badpercent

Sub main()
	softid=NewAsp.ChkNumeric(Request("id"))
	sType=NewAsp.ChkNumeric(Request("t"))
	s=NewAsp.ChkNumeric(Request("s"))
	m=NewAsp.ChkNumeric(Request("m"))
	PJ_CookieName="Soft_PingJia_"&ChannelID&"_"&softid
	If s=0 Then
		If softid>0 Then Call PostAppraised()
	Else
		If softid>0 Then Call LoadAppraised()
	End If
End Sub

Sub LoadAppraised()
	Dim Rs
	Set Rs = NewAsp.Execute("SELECT softid,good,bad FROM NC_SoftList WHERE softid="&softid)
	If Rs.BOF And Rs.EOF Then
		Response.Write ""
	Else
		goodnum=CLng(Rs("good"))
		badnum=CLng(Rs("bad"))
		totalscore=goodnum+badnum
		If totalscore>0 Then
			goodpercent=FormatPercent(goodnum/totalscore,0,-1)
			badpercent=FormatPercent(badnum/totalscore,0,-1)
		Else
			goodpercent="0%"
			badpercent="0%"
		End If
		goodwidth=GetGoodWidth(m)
		badwidth=GetBadWidth(m)
		Response.Clear
		Response.Write ""&totalscore&","&goodnum&","&badnum&","&goodpercent&","&badpercent&","&goodwidth&","&badwidth&""
	End If
	Set Rs = Nothing
End Sub

Sub PostAppraised()
	Dim Rs
	If Trim(Request.Cookies(PJ_CookieName)&"")="ok" Then Exit Sub
	Response.Cookies(PJ_CookieName).path = "/"
	Response.Cookies(PJ_CookieName).Expires = Date + 1
	Response.Cookies(PJ_CookieName)="ok"
	If sType=0 Then
		NewAsp.Execute ("UPDATE NC_SoftList SET bad=bad+1 WHERE softid="&softid)
	Else
		NewAsp.Execute ("UPDATE NC_SoftList SET good=good+1 WHERE softid="&softid)
	End If
	Call LoadAppraised()
End Sub

Function GetGoodWidth(sVariant)
	Dim w
	sVariant=NewAsp.ChkNumeric(sVariant)
	If sVariant=0 Then sVariant=100
	If totalscore>0 Then
		w=NewAsp.ChkNumeric(Fix((goodnum/totalscore)*sVariant))
	Else
		w=1
	End If
	If w<1 Then w=1
	GetGoodWidth=w
End Function

Function GetBadWidth(sVariant)
	Dim w
	sVariant=NewAsp.ChkNumeric(sVariant)
	If sVariant=0 Then sVariant=100
	If totalscore>0 Then
		w=NewAsp.ChkNumeric(Fix((badnum/totalscore)*sVariant))
	Else
		w=1
	End If
	If w<1 Then w=1
	GetBadWidth=w
End Function
%>