<!--#include file="Inc.asp"-->
<%
If Not BBS94KK.Founduser Then BBS94KK.GoToErr(10)
BBS94KK.Head"大埔监狱"
Select Case request.querystring("action")
case"jieyu"
	jieyu()
case"baoshi"
	baoshi()
case else
	Main()
End  Select 
BBS94KK.Footer
Sub Main
Dim Rs,Content
Set Rs=BBS94KK.Execute("select name,zm,zxtime,locktime,lock From [KK_user] where Lock=True")
 If Rs.eof Then
 	Content="<table width='100%' border=1' style='border-collapse: collapse;WORD-BREAK: break-all;'><tr align=center><td width='100%' height='25'><font color=blue>本猪婷家园治安良好,大埔监狱所长没事干^_^</font></td></tr>"
  Else
	 Content="<table width='100%' border=1' style='border-collapse: collapse;WORD-BREAK: break-all;'><tr align=""center"" bgcolor='#D6DFE4'><td width=""90"" height=""26""><b>犯 人</b></td><td width=""200"" height=""26""><b>罪 名</b></td><td width=""91"" height=""26""><b>有期徒刑</b><b>(天)</b></td><td width=""77""><b>执行时间</b></td><td width=""60""><b>剩余时间</b></td><td width=""68"" height=""26""><b>操 作</b></td></tr>"
	Dim leftday
 Do While Not rs.eof  
	leftday=datediff("d",cdate(rs("zxtime")),cdate(now()))
	leftday=int(rs("locktime"))-int(leftday)
	If int(leftday)<=0 Then
		bbs94kk.execute("update [kk_user] set lock=False where name='"&rs("name")&"'")
	End if
  Content=Content&"<tr align=""center"" height=""25""><td width=""90"" align=""center""><a href=""userinfo.asp?name="&Rs("name")&""">"&Rs("name")&"</a></td><td  width=""200"" align=""center"">"&rs("zm")&"</td><td  width=""91"" align=""center"">"&Rs("locktime")&"天</td><td  width=""77"" align=""center"">"&rs("zxtime")&"</td><td  width=""60"" align=""center"">"&leftday&"天</td><td  width=""88"" align=""center""><a href=""?action=baoshi&name="&rs("name")&""">保释</a> <font color=red>|</font> <a href=""?action=jieyu&name="&rs("name")&""">劫狱</a></td></tr>"
	Rs.movenext
	Loop
	End if
   Rs.close
   Set rs=nothing
	Content=Content&"<tr align='center'><td colspan=""6""><font color=""#FF0000"">重要提示：保释需花费现金15000两，劫狱无需花钱，但失败后会被抓(由于几率很小，所以....)</font></td></tr></table>"
	Call BBS94KK.ShowTable("社区监狱",Content)
End Sub
dim NewSmsNum
Sub baoshi()
If int(SESSION(CacheName & "MyInfo")(7))<=15000 then
	Call DisMsg("保释失败，可能您尚未登陆，或者您的现金不够",16,"prison.asp")
Else
	BBS94KK.Execute("update [KK_User] set Coin=Coin-14000 where name='"&BBS94KK.MyName&"'")
	BBS94KK.Execute("update [KK_User] set lock=False where name='"&replace(request.querystring("name"),"'","''")&"'")
	bbs94kk.ExeCute("INSERT INTO [kk_sms] (myname,name,content) values('"&replace(request.querystring("name"),"'","''")&"','大埔监狱所长','你朋友 "&BBS94KK.MyName&" 到大埔监狱里找所长帮你保释了，现在你已自由了，快去谢谢他（她）吧。')")
    BBS94KK.ExeCute("Update [KK_user] Set NewSmsNum=NewSmsNum+1 Where Name='"&replace(request.querystring("name"),"'","''")&"'")
   	Session(CacheName & "MyInfo") = Empty
Call DisMsg("保释成功！感谢您的付出！返还给您1000现金！",16,"prison.asp")
End If
End Sub

Sub jieyu()
	Dim Rs
	set Rs=BBS94KK.Execute("select name from [kk_user] where name='"&BBS94KK.MyName&"' and lock=True")
	If not Rs.eof then
	 Set Rs=nothing 
		Call DisMsg("您都在大埔监狱里呢，还劫别人？！",16,"prison.asp")
	End if
set Rs=nothing
Randomize
If int(fix(rnd*10))=7 Then
BBS94KK.Execute("update [kk_user] set coin=coin+5000 where name='"&bbs94kk.myname&"'")
BBS94KK.Execute("update [kk_user] set lock=false where name='"&Replace(request.querystring("name"),"'","''")&"'")
bbs94kk.ExeCute("INSERT INTO [kk_sms] (myname,name,content) values('"&replace(request.querystring("name"),"'","''")&"','大埔监狱所长','你朋友 "&BBS94KK.MyName&" 为了你到大埔监狱里去劫狱，很幸运的把你救出来了，快去谢谢他（她）吧。')")
BBS94KK.ExeCute("Update [KK_user] Set NewSmsNum=NewSmsNum+1 Where Name='"&replace(request.querystring("name"),"'","''")&"'")
Session(CacheName & "MyInfo") = Empty
Call DisMsg("恭喜，劫狱成功！送您5000现金！但请告诫你的朋友不要再触犯法律！！！",16,"prison.asp")
Else
bbs94kk.execute("update [kk_user] set lock=true,zm='为"&Replace(Server.htmlencode(request.querystring("name")),"'","''")&"劫狱失败而被抓', locktime=5 ,zxtime='"&date&"'where name='"&bbs94kk.myname&"'")
bbs94kk.ExeCute("INSERT INTO [kk_sms] (myname,name,content) values('"&replace(request.querystring("name"),"'","''")&"','大埔监狱所长','你朋友 "&BBS94KK.MyName&" 为了你到大埔监狱里去劫狱，不幸被抓，快去安慰安慰他（她）吧。')")
BBS94KK.ExeCute("Update [KK_user] Set NewSmsNum=NewSmsNum+1 Where Name='"&replace(request.querystring("name"),"'","''")&"'")
Call DisMsg("劫狱失败，您不但没有救出朋友，自己也被抓了！",16,"prison.asp")
end if
end sub

Function DisMsg(C,F,U)
	Response.Write"<script type=""text/vbscript"">"&VbCrlf
	Response.Write"msgbox """&C&""","&F&",""提示！！"""&VbCrlf
	Response.Write"location.href="""&U&""""&VbCrlf&"</script>"
	Response.End
End Function
%>