<!-- #include file="conn.asp" -->
<!-- #include file="check.asp" -->

<% 
 '===========================================================================================
	'软件名称：126 cms 视频影视管理系统
	'程序版权：126电影               '咨询QQ：479025
	'开发作者：magicblack(479025)    '官方网站：http://www.126oo.com/
	'Copyright (C) 2009 - ... 126oo.com  All Rights Reserved.
	'郑重声明:
	'    1、免费版本请在程序首页保留版权信息，并做上本站LOGO友情连接,商业版本无此要求;
	'    2、任何个人或组织不得以盈利为目的发布,修改,本软件及其他副本上一切关于版权的信息；
	'    3、126电影保留此软件的法律追究权利；
'==========================================================================================
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<HTML xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
<TITLE>广告管理 - 后台管理中心 - 126电影程序CMS</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<LINK href="images/css_body.css" type=text/css rel=stylesheet>
</HEAD>
<BODY>
<DIV class=bodytitle>
<DIV class=bodytitleleft></DIV>
<DIV class=bodytitletxt>广告管理</DIV>
<DIV class=bodytitletxt2><a href="admin_ads.asp?action=add">添加广告</a></DIV>
</DIV>

<%
response.Charset="GBK"
dim action
action = SafeData("RQ","action",0)

Select case action
	case "add" : add
	case "addsave" : addsave
	case "edit" : edit
	case "editsave" : editsave
	case "del" : del
	case "delall" : delAll
	case else : main
End Select

sub addsave()
Dim A_Name : A_Name = SafeData("RF","A_Name",0)
Dim A_Code : A_Code = SafeData("RF","A_Code",0)
Dim A_Remarks : A_Remarks = SafeData("RF","A_Remarks",0)
Dim A_Content : A_Content = request.Form("A_Content")
Dim EcdoeContent :EcdoeContent= HtmlEncode(A_Content)

Dim result : result = DataBase.AddRecord("Tbl_Ads",Array("A_Name:"&A_Name, "A_Code:"&A_Code, "A_Remarks:"&A_Remarks, "A_Content:"&EcdoeContent)) 

A_Content = htmltojs(A_Content)

FSOOBJ.createhtml "../js/gg/"&A_Code&".js",A_Content

If result<>0 Then  
    ShowMsg "添加广告成功！"  ,"admin_ads.asp" 
End If
end sub

sub editsave()
Dim A_ID : A_ID = SafeData("RF","A_ID",0)
Dim A_Name : A_Name = SafeData("RF","A_Name",0)
Dim A_Code : A_Code = SafeData("RF","A_Code",0)
Dim A_Remarks : A_Remarks = SafeData("RF","A_Remarks",0)
Dim A_Content : A_Content = request.Form("A_Content")
Dim EcdoeContent :EcdoeContent= HtmlEncode(A_Content)

Dim result : result = DataBase.UpdateRecord("Tbl_Ads","A_ID = "& A_ID ,Array("A_Name:"&A_Name, "A_Remarks:"&A_Remarks, "A_Content:"&EcdoeContent))  

A_Content = htmltojs(A_Content)

FSOOBJ.createhtml "../js/gg/"&A_Code&".js",A_Content
If result<>0 Then  
    ShowMsg "修改广告成功！"  ,"admin_ads.asp" 
End If
end sub

sub del()
	Dim A_ID : A_ID = SafeData("RQ","A_ID",0)
	Dim A_Code : A_Code = SafeData("RQ","A_Code",0)
	Dim result : result = Database.DeleteRecord("Tbl_Ads", "A_ID:" & A_ID)
	FSOOBJ.delFile "../js/gg/"&A_Code&".js"
	If result<>0 Then  
    	ShowMsg "删除记录成功!" ,"admin_ads.asp"  
	End If  
end sub

sub main()
Dim rs : Set rs = DataBase.GetPageRecord(0,Array("Tbl_Ads:A_ID,A_Name,A_Code,A_Remarks","","A_ID Asc","A_ID")) 

Dim Page
 Page = DataBase.GetPager ("")
 %>
<TABLE width="96%" border=0 align=center cellpadding="5" cellSpacing=1 class=tbtitle style="BACKGROUND: #cad9ea;">
  <TBODY>
    <TR bgColor="#f5fafe">
      <TD align="center"  width="20%">广告名称</TD>
      <TD align="center">广告调用代码</TD>
      <TD width="15%" align="center">操作</TD>
    </TR>
	<%do while not rs.eof%>
    <TR bgcolor="#FFFFFF">
      <TD align="center"><%=rs("A_Name")%></TD>
      <TD align="center">
	  <input "text<%=rs("A_ID")%>" name="text<%=rs("A_ID")%>" type="text" value='<script src="<%=app_installdir%>js/gg/<%=rs("A_Code")%>.js"></script>' size="60"> 
	  <INPUT class=inputbut type=button value=复制 name=Submit onClick='document.getElementById("text<%=rs("A_ID")%>").select();document.getElementById("text<%=rs("A_ID")%>").createTextRange().execCommand("Copy");alert("复制成功");'>
	  </TD>
      <TD align="center"><A href="admin_ads.asp?action=edit&A_id=<%=rs("A_ID")%>&A_Code=<%=rs("A_Code")%>">修改</a> | <A href="admin_ads.asp?action=del&A_id=<%=rs("A_ID")%>&A_Code=<%=rs("A_Code")%>" onClick="return confirm('确定要删除吗?');">删除</a></TD>
    </TR>
	<%rs.MoveNext
	loop%>
	<TR align="center" bgcolor="#f8fbfb">
      <TD colspan="6"><%=Page%></TD>
    </TR>
  </TBODY>
</TABLE>
<%
Database.C(rs)
end sub

sub add()%>
<TABLE width="96%" border=0 align=center cellpadding="4" cellSpacing=1 class=tbtitle style="BACKGROUND: #cad9ea;">
<form action="?action=addsave" method="post">
  <TBODY>
    <TR>
      <TD vAlign=center width="20%" bgColor=#f5fafe>广告名称：</TD>
      <TD bgColor=#ffffff><INPUT id="A_Name" size=50 value="" name="A_Name" dataType="Require" msg="请填写广告名称"></TD>
    </TR>
    <TR>
      <TD vAlign=center width="20%" bgColor=#f5fafe>广告文件名：</TD>
      <TD bgColor=#ffffff><INPUT id="A_Code" size=50 value="" name="A_Code" dataType="Require" msg="请填写广告文件名"></TD>
    </TR>
    <TR>
      <TD vAlign=center width="20%" bgColor=#f5fafe>广告描述：</TD>
      <TD bgColor=#ffffff><INPUT id="A_Remarks" size=50 value="" name="A_Remarks" dataType="Require" msg="请填写广告文件名"></TD>
    </TR>
    <TR>
      <TD bgColor=#f5fafe>广告内容：</TD>
      <TD bgColor=#ffffff><textarea id="A_Content" name="A_Content" style="width:100%;" rows="20" dataType="Require" msg="请填写广告内容"></textarea></TD>
    </TR>
    <TR align="center" bgcolor="#f8fbfb">
      <TD colspan="2"><INPUT class=inputbut type=submit value=添加 name=Submit>
      &nbsp;</TD>
    </TR>
  </TBODY>
  </form>
</TABLE>
<%
end sub

sub edit()
Dim A_ID : A_ID = SafeData("RQ","A_ID",0)
Dim rs : Set rs = Database.GetRecordDetail("Tbl_Ads","A_ID=" & A_ID)  

if rs.eof then ShowMsg "找不到此ID的广告!","admin_ads.asp"

%>
<TABLE width="96%" border=0 align=center cellpadding="4" cellSpacing=1 class=tbtitle style="BACKGROUND: #cad9ea;">
<form action="?action=editsave" method="post" onSubmit="return Validator.Validate(this,3)">
<input name="A_ID" type="hidden" value="<%=rs("A_ID")%>">
<input name="A_Code" type="hidden" value="<%=rs("A_Code")%>">
  <TBODY>
    <TR>
      <TD vAlign=center width="20%" bgColor=#f5fafe>广告名称：</TD>
      <TD bgColor=#ffffff><INPUT id="A_Name" size=50 value="<%=rs("A_Name")%>" name="A_Name" dataType="Require" msg="请填写广告名称"></TD>
    </TR>
    <TR>
      <TD vAlign=center width="20%" bgColor=#f5fafe>广告描述：</TD>
      <TD bgColor=#ffffff><INPUT id="A_Remarks" size=50 value="<%=rs("A_Remarks")%>" name="A_Remarks" dataType="Require" msg="请填写广告文件名"></TD>
    </TR>
    <TR>
      <TD bgColor=#f5fafe>广告内容：</TD>
      <TD bgColor=#ffffff><textarea id="A_Content" name="A_Content" style="width:100%;" rows="20" dataType="Require" msg="请填写广告内容"><%=jstohtml(FSOOBJ.FSOFileRead("../js/gg/"&rs("A_Code")&".js"))%></textarea></TD>
    </TR>
    <TR align="center" bgcolor="#f8fbfb">
      <TD colspan="2"><INPUT class=inputbut type=submit value=修改 name=Submit>
      &nbsp;</TD>
    </TR>
  </TBODY>
  </form>
</TABLE>

<%
Database.C(rs)
end sub
%>
</BODY>
</HTML>
