<!-- #include file="Setup.asp" -->
<%
if SiteSettings("AdminPassword")<>session("pass") then response.redirect "Admin_Default.asp?menu=Login"
Log("")

AdminTop
%>
<form method=POST action=?action=fucnok>
<div align="center">
<table cellspacing="1" cellpadding="4" width="100%" border="0" class="a2" align="center">
		<tr height="25">
			<td class="a1" align="middle" colspan="2"><b>帖间广告设置</b></td>
		</tr>
  <tr height="40">
    <td width="40%"  class="a3">
论坛已有广告的显示效果：<br>支持HTML代码的编辑。</td>
    <td width="60%" class="a3">
论坛已有广告的代码：<br>清空代码即删除广告。</td>
  </tr>

<%
dim fso1,openfile,tmpstr,tmp,ad_num,ad_i,ad_tmp
set fso1 = server.createobject("scripting.filesystemobject")
Set openfile=fso1.OpenTextFile(Server.MapPath("inc/PostAd.js"))
tmpstr=openfile.readall
tmp=split(tmpstr,chr(13)&chr(10))
ad_num=replace(tmp(1),"a = ","")
ad_num=int(replace(ad_num,";if(a==0){a=1}",""))
for ad_i=1 to ad_num
ad_tmp=replace(tmp(ad_i+8),"b["&ad_i&"].under =","")
ad_tmp=replace(ad_tmp,"'","")
response.write"<tr><td width=40% class=a3>"&ad_tmp&"</td><td width=60% class=a3><textarea  rows=5 cols=75 name=ad_v"&ad_i&" style='font-family: 宋体; font-size: 10pt'>"&ad_tmp&"</textarea></td></tr>"
next
openfile.close
set fso1=nothing
%>  
  <tr>
    <td width="100%" class="a2" colspan="2" height="25">
    　</td>
  </tr>
  <tr>
    <td width="40%" class="a3">
增加广告：</td>
    <td width="60%" class="a3">
    <textarea row=3 cols=75 name=ad_v<%=ad_num+1%> rows="5" style="font-family: 宋体; font-size: 10pt"></textarea></td>
  </tr>  <tr>
    <td width="100%"  class="a3" colspan="2" height="35" align="center">
    <input type="submit" value="  确  认  修  改  " name="B1"></td>
  </tr>
</table></div>
</form>


<%
if Request("action")="fucnok" then
dim adv_num,ad_msg
set fso1 = server.createobject("scripting.filesystemobject")
Set openfile=fso1.OpenTextFile(Server.MapPath("inc/PostAd.js"))
tmpstr=openfile.readall
tmp=split(tmpstr,chr(13)&chr(10))
ad_num=replace(tmp(1),"a = ","")
ad_num=int(replace(ad_num,";if(a==0){a=1}",""))
openfile.close
set fso1=nothing
adv_num=0
for ad_i=1 to ad_num+1
ad_tmp=replace(request.form("ad_v"&ad_i&""),"'","")
if trim(ad_tmp)<>"" or isnull(ad_tmp)then
adv_num=adv_num+1
ad_msg=ad_msg&"b["&adv_num&"].under ='"&ad_tmp&"'"&vbcrlf
end if
next
dim objFSO,objname
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objname=objFSO.CreateTextFile(Server.MapPath("inc/PostAd.js"),True)
objname.Write"<!--"&vbcrlf&"a = "&adv_num&";if(a==0){a=1}"&vbcrlf&"var slump = Math.random();"&vbcrlf&"var talet = Math.round(slump * (a-1))+1;"&vbcrlf&"function create() { "&vbcrlf&"this.under = '' "&vbcrlf&"}"&vbcrlf&"b = new Array() "&vbcrlf&"for(var i=1; i<=a; i++) { b[i] = new create() } "&vbcrlf&ad_msg&"var visa = """";"&vbcrlf&"document.write(b[talet].under); "&vbcrlf&"//-->"
objname.close
set objfso=nothing
response.redirect"Admin_PostAd.Asp"
end if
%>
