<!-- #include file=../inc/BBSsetup.asp -->
<!-- #include file=../inc/Board_Popfun.asp -->
<!-- #include file=conn.asp -->
<%
DEF_BBS_HomeUrl = "../"
if gbl_chk_user="" then
	response.write "您没有发布小字报的权限，请登陆或者注册。"
	connsp.close
	set connsp=nothing
	response.end
end if
initDatabase
BBS_SiteHead DEF_SiteNameString & " " & DEF_BBS_Name,GBL_board_ID," >> 发布小字报"
dim act
act=request.querystring("action")
If act="add" then
	call add()
else
	call main()
End if
closedatabase
connsp.close
set connsp=nothing
SiteBottom

Sub main()
%>
<table width="<%=DEF_BBS_ScreenWidth%>" border=0 cellspacing=1 cellpadding=5 align=center bgcolor=<%=DEF_BBS_DarkColor%> class=TBone>
<tr bgcolor=<%=DEF_BBS_LightDarkColor%> align=center>
<td class=TBHead><font color=#ffffff class=HeadFont><b>发布小字报</b></font></td>
</tr>
<form name="formadv" method="post" action="?action=add">
<tr bgcolor=<%=DEF_BBS_LightestColor%> class=TBBG9 align=center>
    <td>序号：<input type=text name=sid size=60 maxsize=30></td>
</tr>
<tr bgcolor=<%=DEF_BBS_LightestColor%> class=TBBG9 align=center>
    <td>标题：<input type=text name=stitle size=60 maxsize=45></td>
</tr>
<tr bgcolor=<%=DEF_BBS_LightestColor%> class=TBBG9 align=center>
    <td>内容：<textarea name=scontent cols=60 rows=5></textarea></td>
</tr>
<tr bgcolor=<%=DEF_BBS_LightestColor%> class=TBBG9 align=center>
    <td><INPUT type=submit value=确　认 name=submit></td>
</tr>
</form>
<tr bgcolor=<%=DEF_BBS_LightestColor%> class=TBBG9>
    <td>使用帮助：<br>
    <li>序号的填写范围在1-5之间，超限无效。标题最长为45个字符，超限将出现错误。</li>
    <li>序号表示你要加的小字报要存放的顺序，1最前，5最后，价格对应为：<u>5-100牛币&nbsp;4-200牛币&nbsp;3-300牛币&nbsp;2-400牛币&nbsp;1-500牛币</u></li>
    <li>如果你选的序号已经有人发布了，将直接覆盖其内容，同理你发布的内容别人也可以直接覆盖。</li>
    <li>此小字报信息在所有版面，任何帖子的上方滚动播出，受众面极广，是广告的最佳发布地。</li>
    <li>小字报内容不能编辑，如果要改，直接发新信息覆盖原信息即可，费用照收。</li>
    </td>
</tr>
</table>
<%
End Sub

Sub add()
dim rs,sql,sid,advmoney
sid=request.form("sid")
If not isNumeric(sid) then
	response.write "<p align=center><font color=orange>错误的序号参数，必须是整数！</font>"
	exit sub
End if
If sid="" or Clng(sid)<0 or Clng(sid)>5 then
	response.write "<p align=center><font color=orange>错误的序号参数，必须是1到5之间的数字！</font>"&Clng(sid)
	exit sub
End if
sid=Clng(sid)
select case sid
	case 1
	advmoney=500
	case 2
	advmoney=400
	case 3
	advmoney=300
	case 4
	advmoney=200
	case 5
	advmoney=100
end select
If con.execute("Select top 1 Points from Leadbbs_user where username='"&GBL_CHK_User&"'")(0) < advmoney then
	response.write "<p align=center><font color=orange>你的牛币不够支付相关费用</font>"
	exit sub
End if
If strLength(request.form("stitle"))>30 then
	response.write "<p align=center><font color=orange>标题最长为30个字符</font>"
	exit sub
End if
sql="select sid,susername,stitle,scontent,saddtime from SmallPaper where sid="&sid
set rs=server.createobject("adodb.recordset")
rs.open sql,connsp,1,3
rs("susername")=GBL_CHK_User
rs("stitle")=Checkstr(request.form("stitle"))
rs("scontent")=Checkstr(request.form("scontent"))
rs("Saddtime")=now()
rs.update
rs.close
set rs=nothing
con.execute("update leadbbs_user set Points=Points-"&advmoney&" where username='"&GBL_CHK_User&"'")
response.write "<p align=center><font color=orange>恭喜，小字报发布成功！</font>"
End sub
Function Checkstr(Str)
	If Isnull(Str) Then
		checkStr = ""
		Exit Function 
	End If
	checkStr=Replace(Str,"'","''")
End Function
%>