<!--#include file="conn.asp"-->
<!--#include file="Top.asp"-->
<!--#include file="error.ini"-->
<%if session("flag")>1 then
    response.write "<script>alert('您的操作权限不够！');history.back();</script>"
    response.end
end if
%>
<%if request("action")="save" then
	call Msave()
else
	call Mails()
end if
sub mails
on error resume next
set rs =conn.execute("select FloatAd,IsFloatAd from [ads1]")
if not rs.eof then
	FloatAd=split(rs(0),"$")
	IsFloatAd=rs("IsFloatAd")
end if
rs.close
set rs=nothing
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>广告管理</title>
<link href="Images/Admin_Style.Css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.样式1 {color: #000000}
body {
	margin-top: 0px;
}
-->
</style>
</head>

</head>
<body leftmargin="2" topmargin="0" marginwidth="0" marginheight="0">

<form name="myform" method="post" action="ads.asp">
 <input type=hidden name=action value=save>
    <table cellpadding="2" cellspacing="1" border="0" width="100%" class="border" align=center>
      <tr align="center"> 
        <td height=22 colspan=2 class="title 样式1" ><strong>首面浮动图片广告设置</strong> 
      
      <tr>
        <td  class="tdbg" height=23><div align="center">是否开启</div></td>
        <td class="tdbg"><input type=radio name="IsFloatAd" value="0" <%if IsFloatAd=0 then%>checked<%end if%>>
        否　 
          <input type=radio name="IsFloatAd" value="1" <%if IsFloatAd=1 then%>checked<%end if%>>
        是</td>
      </tr>
      <tr> 
        <td  class="tdbg" height=23><div align="center">图片地址</div></td>
        <td class="tdbg"><div align="center"></div>          <input size="50" name="FloatAd" value="<%=FloatAd(0)%>"></td>
      </tr>
      <tr>
        <td class="tdbg" height=23><div align="center">链接地址</div></td>
        <td width="50%" class="tdbg"><input size="50" name="FloatAd" value="<%=FloatAd(1)%>"></td>
      </tr>
      <tr> 
        <td class="tdbg" height=23><div align="center">链接说明</div></td>
        <td class="tdbg"><input size="50" name="FloatAd" value="<%=FloatAd(2)%>"></td>
      </tr>
      <tr> 
        <td height=40 colspan="2" class="tdbg"><div align="center"><input type="submit" name="Submit"class=button  value="提 交"></div>          </td>
      </tr>
    </table>
</form>
</body>
</html>
<%
end sub        
sub Msave()
	MFloatAd=REPLACE(request("FloatAd"),", ","$")
	MIsFloatAd=request("IsFloatAd")
	if MIsFloatAd="" then:MIsFloatAd=0
	set rs =conn.execute("select FloatAd from [ads1]")
	if rs.eof then
		conn.execute("Insert into ads1(FloatAd,IsFloatAd)values('"&MFloatAd&"','"&MIsFloatAd&"')")
	else
		conn.execute("update ads1 set FloatAd='"&MFloatAd&"',IsFloatAd="&MIsFloatAd&"")
	end if
	rs.close
	set rs=nothing
	call makeFloatAd(MFloatAd,MIsFloatAd)
	response.redirect Request.ServerVariables("HTTP_REFERER")
end sub

sub makeFloatAd(code,isf)
	FloatAd=split(code,"$")
	if isf="1" then
		dim JS_Body
		set objFso = server.CreateObject("scripting.filesystemobject")
		set Fso = objFso.opentextfile(server.mappath("../ads/ads.js"),1)
		JS_Body = Fso.readall
		Fso.close
		set Fso = nothing
		
		dim JS
		JS=JS+"<!-- Begin"&vbcrlf
		JS=JS+"var floatimg='"&FloatAd(0)&"';"&vbcrlf
		JS=JS+"var floaturl='"&FloatAd(1)&"';"&vbcrlf
		JS=JS+"var floattitle='"&FloatAd(2)&"';"&vbcrlf
		JS=JS+JS_Body
		JS=JS+"//  End -->"&vbcrlf
	else
		JS=""
	end if
	FolderPath = Server.MapPath("../ads")
	Set fso = Server.CreateObject("Scripting.FileSystemObject")
	Set fout = fso.CreateTextFile(FolderPath&"/ads1.js")
	fout.WriteLine JS
	JS=""
	'关闭连接
	fout.close
	set fout = nothing
	
end sub
%>