<!-- #include file="include/onlogin.asp" -->
<!-- #include file="include/csk3000_page_cute.asp" -->
<!-- #include file="include/conn.asp" -->
<%
dim id,asort,atype,asize,awidth,aheight,aname,alink,aurl,ltim,emoney,add
tit="<a href='?'>广告管理</a> ┋ " & _
    "<a href='?action=add'>添加广告</a>"
response.write header(9,tit)
titt="广告管理"
response.write admin_bar(titt,1,"99%")
id=trim(request.querystring("id"))

select case action
case "del"
  if isnumeric(id) then
    call ads_del()
  else
    call ads_main()
  end if
case "add"
  call ads_add()
case "edit"
  if isnumeric(id) then
    call ads_edit()
  else
    call ads_main()
  end if
case else
  call ads_main()
end select

close_conn
response.write admin_bar(titt,2,"99%")
response.write ender()

function first_id(ndata)
  dim rsf
  set rsf=conn.execute("select top 1 aid from "&ndata&" order by aid desc")
  first_id=rsf("aid")
  rsf.close:set rsf=nothing
end function

sub ads_file(aid)
  dim asort,atype,atemp,awh:awh=""
  sql="select asort,atype,asize,awidth,aheight,aname,alink,aurl from ads where aid="&aid
  set rs=conn.execute(sql)
  if rs.eof and rs.bof then
    rs.close:set rs=nothing
    exit sub
  end if
  asort=rs("asort")
  atype=int(rs("atype"))
  if rs("asize")=true then
   awh=" width="&rs("awidth")&" height="&rs("aheight")
  end if
  select case atype
  case 1
    atemp="<a href='"&rs("alink")&"' target=_blank><img src='"&rs("aurl")&"' border=0 alt='"&rs("aname")&"'"&awh&"></a>"
  case 2
    atemp="<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0'"&awh&">" & _
	  "<param name=movie value='"&rs("aurl")&"'><param name=quality value=high>" & _
	  "<embed src='"&rs("aurl")&"' quality=high pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash'"&awh&">" & _
	  "</embed></object>"
  case 3
    atemp="<a href='"&rs("alink")&"' target=_blank>"&rs("aname")&"</a>"
  case 4
    atemp="<object id='NSPlay' width="&rs("awidth")&" height="&rs("aheight")&" classid='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95' codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2o99.cab#Version=5,1,52,701' standby='Loading Microsoft Media Player components...' type='application/x-oleobject'>" & _
       "<param name='FileName' value='"&rs("aurl")&"'>" & _
       "<param name='AnimationAtStart' value='true'>" & _
       "<param name='TransparentAtStart' value='false'><param name='ShowControls' value='0'>" & _
       "<param name='ShowPositionControls' value='1'><param name='AutoSize' value='0'>" & _
       "<param name='ShowStatusBar' value='1'>" & _
       "<embed type='video/x-ms-asf-plugin' pluginspage='http://www.microsoft.com/netshow/download/player.htm' src='"&rs("aurl")&"' showcontrols=0 showpositioncontrols=1 showstatusbar=1 autosize=0 width="&rs("awidth")&" height="&rs("aheight")&">" & _
       "</embed></object>" & _
       "<br>广告说明:"&rs("aname")&""
  case 5
    atemp="<object id='RAOCX' name='rmplay' classid='clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA'  width="&rs("awidth")&" height="&rs("aheight")&">" & _
       "<param name='SRC' value='"&rs("aurl")&"'><param name='CONSOLE' value='Clip1'>" & _
       "<param name='CONTROLS' value='imagewindow'><param name='AUTOSTART' value='true'><param name='CONTROLS' value='PlayButton'><param name='CONTROLS' value='PositionSlider'></object>" & _
       "<br>广告说明:"&rs("aname")&""
  end select
  rs.close:set rs=nothing
  atemp="document.write("""&atemp&""");"
  
  dim fileos,filepath,filetemp,file_name
  file_name="ads/ads_"&asort&".js"
  set fileos=CreateObject("Scripting.FileSystemObject")
  filepath=server.mappath(file_name)
  set filetemp=fileos.createtextfile(filepath,true)
  filetemp.writeline( atemp )
  filetemp.close
  set filetemp=nothing
  set fileos=nothing
end sub

sub ads_edit()
  set rs=server.createobject("adodb.recordset")
  sql="select * from ads where aid="&id
  rs.open sql,conn,1,3
  if rs.eof and rs.bof then
    rs.close:set rs=nothing
    response.write("<script language=javascript>" & _
		   vbcrlf & "alert(""您的操作有错误（error in edit）存在！\n\n点击返回。"");" & _
		   vbcrlf & "location='?'" & _
		   vbcrlf & "</script>")
    exit sub
  end if
  if trim(request.querystring("chk"))="ok" then
    asort=objv7.code_form(request.form("asort"))
    atype=int(request.form("atype"))
    asize=trim(request.form("asize"))
    awidth=trim(request.form("awidth"))
    aheight=trim(request.form("aheight"))
    aname=objv7.code_form(request.form("aname"))
    alink=trim(request.form("alink"))
    aurl=trim(request.form("aurl"))
    ltim=trim(request.form("ltim"))
    emoney=trim(request.form("emoney"))
    add=trim(request.form("add"))
    if len(asort)<1 then response.write "广告代码 不能为空！<br><br>"&go_back:exit sub
    if asize="yes" and (not(isnumeric(awidth)) or not(isnumeric(aheight))) then response.write "广告 宽 和 高  只能为数字！<br><br>"&go_back:exit sub
    if atype=3 and len(aname)<1 then response.write "文字广告的 文字说明 不能为空！<br><br>"&go_back:exit sub
    'response.write "广告代码："&asort&" 已存在！请选用其它的代码。<br><br>"&go_back:exit sub
    rs("asort")=asort
    rs("atype")=atype
    if asize="yes" then
      rs("asize")=true
      rs("awidth")=awidth
      rs("aheight")=aheight
    else
      rs("asize")=false
    end if
    rs("aname")=aname
    rs("alink")=alink
    rs("aurl")=aurl
    rs("ltim")=ltim
    rs("emoney")=emoney
    rs("add")=add
    rs.update
    rs.close:set rs=nothing
    call ads_file(id)
    response.write "<script lanuage=javascrip>alert(""修改广告成功！"");location.href='?';</script>"
    exit sub
  end if
%>
<table border=0 width=450 cellspacing=0 cellpadding=2>
<form action='?action=edit&chk=ok&id=<%response.write id%>' method=post>
  <tr>
    <td colspan=2 align=center height=50><font class=red>修改广告</font></td>
  </tr>
  <tr height=30>
    <td width='20%'>广告代码：</td>
    <td width='80%'><input onmouseover=this.style.borderColor='#486841';this.style.backgroundColor='#E2F1A6' onmouseout=this.style.borderColor='#006D91';this.style.backgroundColor='#EFEFEF' type=text name=asort value='<%=rs("asort")%>' readonly size=10 maxlength=10>　区别某一版块，不可修改，如：down_1</td>
  </tr>
  <% atype=int(rs("atype")) %>
  <tr>
    <td width='20%'>广告类型：</td>
    <td width='80%'><input onmouseover=this.style.borderColor='#486841';this.style.backgroundColor='#E2F1A6' onmouseout=this.style.borderColor='#006D91';this.style.backgroundColor='#EFEFEF' type=radio name=atype value='1'<%if atype=1 then response.write " checked"%>>图片
    <input onmouseover=this.style.borderColor='#486841';this.style.backgroundColor='#E2F1A6' onmouseout=this.style.borderColor='#006D91';this.style.backgroundColor='#EFEFEF' type=radio name=atype value='2'<%if atype=2 then response.write " checked"%>>FLASH
    <input onmouseover=this.style.borderColor='#486841';this.style.backgroundColor='#E2F1A6' onmouseout=this.style.borderColor='#006D91';this.style.backgroundColor='#EFEFEF' type=radio name=atype value='3'<%if atype=3 then response.write " checked"%>>文字
<input onmouseover=this.style.borderColor='#486841';this.style.backgroundColor='#E2F1A6' onmouseout=this.style.borderColor='#006D91';this.style.backgroundColor='#EFEFEF' type=radio name=atype value='4'<%if atype=4 then response.write " checked"%>>视频(mb)
<input onmouseover=this.style.borderColor='#486841';this.style.backgroundColor='#E2F1A6' onmouseout=this.style.borderColor='#006D91';this.style.backgroundColor='#EFEFEF' type=radio name=atype value='5'<%if atype=5 then response.write " checked"%>>视频(rm)</td>
  </tr>
  <tr>
    <td width='20%'>广告时间</td>
    <td width='80%'>视频播放时间:<input onmouseover=this.style.borderColor='#486841';this.style.backgroundColor='#E2F1A6' onmouseout=this.style.borderColor='#006D91';this.style.backgroundColor='#EFEFEF' type=text name=ltim value='<%=rs("ltim")%>' size=9 maxlength=10>秒 
    加影币:<input onmouseover=this.style.borderColor='#486841';this.style.backgroundColor='#E2F1A6' onmouseout=this.style.borderColor='#006D91';this.style.backgroundColor='#EFEFEF' type=text name=emoney value='<%=rs("emoney")%>' size=9 maxlength=10>个</td>
  </tr>
  <tr>
    <td width='20%'>广告类别</td>
    <td width='80%'><select size="1" name="add">
    <option value="2" <%if rs("add")=2 then response.write "selected"%>>点播广告</option>
    <option value="1" <%if rs("add")=1 then response.write "selected"%>>播放器上方</option>
    <option value="3">其它位置</option>
    </select></td>
  </tr>
  <tr height=30>
</td>
  </tr>
  <tr height=30 valign=top>
    <td><table border=0><tr><td>广告大小：</td></tr></table></td>
    <td><table border=0>
<tr><td><input onmouseover=this.style.borderColor='#486841';this.style.backgroundColor='#E2F1A6' onmouseout=this.style.borderColor='#006D91';this.style.backgroundColor='#EFEFEF' type=checkbox name=asize value='yes'<%if rs("asize")=true then response.write " checked"%>> 选中后则按下面的大小显示，否则按默认显示<br>
  请按规定，宽不能大于375高不能大于460</td></tr>
<tr>
  <td>宽：<input onmouseover=this.style.borderColor='#486841';this.style.backgroundColor='#E2F1A6' onmouseout=this.style.borderColor='#006D91';this.style.backgroundColor='#EFEFEF' type=text name=awidth value='<%=rs("awidth")%>' size=10 maxlength=10> 像素　高：<input onmouseover=this.style.borderColor='#486841';this.style.backgroundColor='#E2F1A6' onmouseout=this.style.borderColor='#006D91';this.style.backgroundColor='#EFEFEF' type=text name=aheight value='<%=rs("aheight")%>' size=10 maxlength=10> 像素</td>
</tr>
</table></td>
  </tr>
  <tr height=30>
    <td>文字说明：</td>
    <td><input onmouseover=this.style.borderColor='#486841';this.style.backgroundColor='#E2F1A6' onmouseout=this.style.borderColor='#006D91';this.style.backgroundColor='#EFEFEF' type=text name=aname value='<%=rs("aname")%>' size=50 maxlength=50></td>
  </tr>
  <tr height=30>
    <td>链接地址：</td>
    <td><input onmouseover=this.style.borderColor='#486841';this.style.backgroundColor='#E2F1A6' onmouseout=this.style.borderColor='#006D91';this.style.backgroundColor='#EFEFEF' type=text name=alink value='<%=rs("alink")%>' size=60 maxlength=200></td>
  </tr>
  <tr height=30>
    <td>文件地址：</td>
    <td><input onmouseover=this.style.borderColor='#486841';this.style.backgroundColor='#E2F1A6' onmouseout=this.style.borderColor='#006D91';this.style.backgroundColor='#EFEFEF' type=text name=aurl value='<%=rs("aurl")%>' size=60 maxlength=100></td>
  </tr>
  <tr height=30 align=center>
    <td colspan=2><input onmouseover=this.style.borderColor='#486841';this.style.backgroundColor='#E2F1A6' onmouseout=this.style.borderColor='#006D91';this.style.backgroundColor='#EFEFEF' type=submit value='修 改 广 告'></td>
  </tr>
</form></table>
<%
end sub

sub ads_add()
  if trim(request.querystring("chk"))="ok" then
    asort=objv7.code_form(request.form("asort"))
    atype=int(request.form("atype"))
    asize=trim(request.form("asize"))
    awidth=trim(request.form("awidth"))
    aheight=trim(request.form("aheight"))
    aname=objv7.code_form(request.form("aname"))
    alink=trim(request.form("alink"))
    aurl=trim(request.form("aurl"))
    ltim=trim(request.form("ltim"))
    emoney=trim(request.form("emoney"))
    add=trim(request.form("add"))
    if len(asort)<1 then response.write "广告代码 不能为空！<br><br>"&go_back:exit sub
    if asize="yes" and (not(isnumeric(awidth)) or not(isnumeric(aheight))) then response.write "广告 宽 和 高  只能为数字！<br><br>"&go_back:exit sub
    if atype=3 and len(aname)<1 then response.write "文字广告的 文字说明 不能为空！<br><br>"&go_back:exit sub
    
    set rs=server.createobject("adodb.recordset")
    sql="select * from ads where asort='"&asort&"'"
    rs.open sql,conn,1,3
    if not(rs.eof and rs.bof) then
      rs.close:set rs=nothing
      response.write "广告代码："&asort&" 已存在！请选用其它的代码。<br><br>"&go_back:exit sub
    end if
    rs.addnew
    rs("asort")=asort
    rs("atype")=atype
    if asize="yes" then
      rs("asize")=true
      rs("awidth")=awidth
      rs("aheight")=aheight
    else
      rs("asize")=false
    end if
    rs("aname")=aname
    rs("alink")=alink
    rs("aurl")=aurl 
    rs("ltim")=ltim
    rs("emoney")=emoney
    rs("add")=add
    rs.update
    rs.close:set rs=nothing
    call ads_file(first_id("ads"))
    response.write "<script lanuage=javascrip>alert(""添加广告成功！"");location.href='?';</script>"
    exit sub
  end if
%>
<table border=0 width=450 cellspacing=0 cellpadding=2>
<form action='?action=add&chk=ok' method=post>
  <tr>
    <td colspan=2 align=center height=50><font class=red>添加广告</font></td>
  </tr>
  <tr height=30>
    <td width='20%'>广告代码：</td>
    <td width='80%'><input onmouseover=this.style.borderColor='#486841';this.style.backgroundColor='#E2F1A6' onmouseout=this.style.borderColor='#006D91';this.style.backgroundColor='#EFEFEF' type=text name=asort size=10 maxlength=10>　区别某一版块，不可修改，如：down_1</td>
  </tr>
  <tr height=30>
    <td width='20%'>广告类型：</td>
    <td width='80%'><input onmouseover=this.style.borderColor='#486841';this.style.backgroundColor='#E2F1A6' onmouseout=this.style.borderColor='#006D91';this.style.backgroundColor='#EFEFEF' type=radio name=atype value='1' checked>图片
    <input onmouseover=this.style.borderColor='#486841';this.style.backgroundColor='#E2F1A6' onmouseout=this.style.borderColor='#006D91';this.style.backgroundColor='#EFEFEF' type=radio name=atype value='2'>FLASH
    <input onmouseover=this.style.borderColor='#486841';this.style.backgroundColor='#E2F1A6' onmouseout=this.style.borderColor='#006D91';this.style.backgroundColor='#EFEFEF' type=radio name=atype value='3'>文字
  <input onmouseover=this.style.borderColor='#486841';this.style.backgroundColor='#E2F1A6' onmouseout=this.style.borderColor='#006D91';this.style.backgroundColor='#EFEFEF' type=radio name=atype value='4'>视频(mb)
<input onmouseover=this.style.borderColor='#486841';this.style.backgroundColor='#E2F1A6' onmouseout=this.style.borderColor='#006D91';this.style.backgroundColor='#EFEFEF' type=radio name=atype value='5'>视频(rm)</td></tr>
  <tr height=30>
    <td width='20%'>广告时间</td>
    <td width='80%'>视频播放时间:<input onmouseover=this.style.borderColor='#486841';this.style.backgroundColor='#E2F1A6' onmouseout=this.style.borderColor='#006D91';this.style.backgroundColor='#EFEFEF' type=text name=ltim size=10 maxlength=10 value="10">秒 
    加影币:<input onmouseover=this.style.borderColor='#486841';this.style.backgroundColor='#E2F1A6' onmouseout=this.style.borderColor='#006D91';this.style.backgroundColor='#EFEFEF' type=text name=emoney value='0' size=9 maxlength=10>个</td></tr>
  <tr height=30>
    <td width='20%'>广告类别</td>
    <td width='80%'><select size="1" name="add">
    <option value="1">播放器上方</option>
    <option value="2">点播广告</option>
    <option value="3">其它位置</option>
    </select></td></tr>
  <tr height=30 valign=top>
    <td><table border=0><tr><td>广告大小：</td></tr></table></td>
    <td><table border=0>
<tr><td><input onmouseover=this.style.borderColor='#486841';this.style.backgroundColor='#E2F1A6' onmouseout=this.style.borderColor='#006D91';this.style.backgroundColor='#EFEFEF' type=checkbox name=asize value='yes' checked> 选中后则按下面的大小显示，否则按默认显示<br>
  请按规定，宽不能大于375高不能大于460</td></tr>
<tr>
  <td>宽：<input onmouseover=this.style.borderColor='#486841';this.style.backgroundColor='#E2F1A6' onmouseout=this.style.borderColor='#006D91';this.style.backgroundColor='#EFEFEF' type=text name=awidth size=10 maxlength=10> 像素　高：<input onmouseover=this.style.borderColor='#486841';this.style.backgroundColor='#E2F1A6' onmouseout=this.style.borderColor='#006D91';this.style.backgroundColor='#EFEFEF' type=text name=aheight size=10 maxlength=10> 像素</td>
</tr>
</table></td>
  </tr>
  <tr height=30>
    <td>文字说明：</td>
    <td><input onmouseover=this.style.borderColor='#486841';this.style.backgroundColor='#E2F1A6' onmouseout=this.style.borderColor='#006D91';this.style.backgroundColor='#EFEFEF' type=text name=aname size=50 maxlength=50></td>
  </tr>
  <tr height=30>
    <td>链接地址：</td>
    <td><input onmouseover=this.style.borderColor='#486841';this.style.backgroundColor='#E2F1A6' onmouseout=this.style.borderColor='#006D91';this.style.backgroundColor='#EFEFEF' type=text name=alink value='http://' size=60 maxlength=200></td>
  </tr>
  <tr height=30>
    <td>文件地址：</td>
    <td><input onmouseover=this.style.borderColor='#486841';this.style.backgroundColor='#E2F1A6' onmouseout=this.style.borderColor='#006D91';this.style.backgroundColor='#EFEFEF' type=text name=aurl value='ads/' size=60 maxlength=100></td>
  </tr>
  <tr height=30 align=center>
    <td colspan=2><input onmouseover=this.style.borderColor='#486841';this.style.backgroundColor='#E2F1A6' onmouseout=this.style.borderColor='#006D91';this.style.backgroundColor='#EFEFEF' type=submit value='添 加 广 告'></td>
  </tr>
</form></table>
<%
end sub

sub ads_del()
  on error resume next
  conn.execute("delete from ads where aid="&id)
  if err then
    err.clear
    response.write("<script language=javascript>" & _
		   vbcrlf & "alert(""您的操作有错误（error in del）存在！\n\n点击返回。"");" & _
		   vbcrlf & "location='?'" & _
		   vbcrlf & "</script>")
  else
    response.write("<script language=javascript>" & _
		   vbcrlf & "alert(""成功删除了一条广告！\n\n点击返回。"");" & _
		   vbcrlf & "location='?'" & _
		   vbcrlf & "</script>")
  end if
end sub

sub ads_main()
  dim i,rssum,nummer,thepages,viewpage,pageurl,page,sort,sqladd,sname,iid,ads_main2
  pageurl="admin_links.asp?action=main&"
  sort=trim(request.querystring("sort"))

  sql="select aid,asort,atype,asort,aname,count from ads order by aid"
  set rs=server.createobject("adodb.recordset")
  rs.open sql,conn,1,1
  if rs.eof and rs.bof then
   ads_main2="现在还没有！"
  else
    rssum=rs.recordcount
    nummer=8
    if rssum mod nummer > 0 then
      thepages=rssum\nummer+1
    else
      thepages=rssum\nummer
    end if
  
    page=trim(request.querystring("page"))
    if page="" or isnull(page) or not(isnumeric(page)) then
      page=1
    end if
  
    if page="" then
      viewpage=1
    else
      if int(page)>thepages then
        viewpage=1
      else
        viewpage=page
      end if
    end if
    
    ads_main2=ads_main2&vbcrlf&"<script language=JavaScript><!--" & _
	      vbcrlf&"function Do_del_data(data1)" & _
	      vbcrlf&"{" & _
	      vbcrlf&"if (confirm(""此操作将删除id为 ""+data1+"" 的广告！\n真的要删除吗？\n删除后将无法恢复！""))" & _
	      vbcrlf&"  window.location=""?action=del&id=""+data1" & _
	      vbcrlf&"}" & _
	      vbcrlf&"//--></script>" & _
	      vbcrlf&"<table border=1 width=600 cellspacing=0 cellpadding=1 bordercolorlight=#C0C0C0 bordercolordark=#FFFFFF>" & _
	      vbcrlf&"<tr><td colspan=6 align=center height=30><table border=0 width='100%'cellspacing=0 cellpadding=0>" & _
	      vbcrlf&"<tr align=center><td width='40%'>现在有 <font class=red>"&rssum&"</font> 个 <font class=red_4>"&sname&"</font> 广告</td>" & _
	      vbcrlf&"<td width='60%'>"&pagecute_fun(viewpage,thepages,pageurl)&"</td></tr></table></td></tr>" & _
	      "<tr align=center bgcolor=#ededed><td width='8%'>序号</td><td width='20%'>广告代码</td><td width='20%'>广告类型</td><td width='30%'>文字说明</td><td width='17%'>操作</td><td width='5%'>计数</td></tr>"
    if viewpage<>"1" then
      rs.move (viewpage-1)*nummer
    end if
    for i=1 to nummer
      if rs.eof then exit for
      iid=rs("aid")
      ads_main2=ads_main2&vbcrlf&"<tr align=center><td>"&i+(viewpage-1)*nummer&".</td><td>"&rs("asort")&"</td><td>"
      select case int(rs("atype"))
      case 1
        ads_main2=ads_main2&"图片广告"
      case 2
        ads_main2=ads_main2&"FLASH广告"
      case 3
        ads_main2=ads_main2&"文字广告"      
      case 4
        ads_main2=ads_main2&"视频(mb)广告"
      case 5
        ads_main2=ads_main2&"视频(rm)广告"
      end select
      ads_main2=ads_main2&"</td><td>"&objv7.code_html(rs("aname"),1,12)&"</td><td>" & _
		"<a href='?action=edit&id="&iid&"'>修改</a>┋<a href='javascript:Do_del_data("&iid&")'>删除</a></td><td>"&rs("count")&"</td></tr>"
      rs.movenext
    next
    ads_main2=ads_main2&vbcrlf&"</table>"
  end if
  rs.close:set rs=nothing
  response.write ads_main2
%>
<br>
<table border=0 align=center>
<tr>
<td>调用方法：</td>
<td>&lt;script language=javascript src='ads/ads_<font class=red>(广告代码)</font>.js'&gt;&lt;/script&gt;</td>
</tr>
</table>
<%
end sub
%>