<!-- #include file="include/onlogin.asp" -->
<!-- #INCLUDE file="include/jk_page_cute.asp" -->
<!-- #include file="include/conn.asp" -->
<html>

<%
dim id,nsort,rssum,nummer,thepages,viewpage,pageurl,page
nsort=trim(request("nsort"))
select case nsort
case "popwin"
  nsort="popwin"
case else
  nsort="news"
end select

sql="select * from popwin"			' where sort='"&nsort&"'"
   
tit=vbcrlf & "<a href='admin_adsmain.asp?'>广告管理</a>&nbsp;┋ <a href='admin_adv.asp'>论坛广告管理</a>┋&nbsp;<a href='admin_popwin.asp?nsort=popwin'>弹出广告</a>┋&nbsp;" & _
    vbcrlf & "<a href='admin_adsmain.asp?action=edit'>广告分类</a>"
response.write header(4,tit)
id=trim(request.querystring("id"))

select case action
case "add"
  response.write news_add()
case "addchk"
  response.write news_addchk()
case "del"
  if isnumeric(id) then
    response.write news_del(id)
  else
    response.write news_main()
  end if
case "edit"
  if isnumeric(id) then
    response.write news_edit(id)
  else
    response.write news_main()
  end if
case "editchk"
  if isnumeric(id) then
    response.write news_editchk(id)
  else
    response.write news_main()
  end if
case else
  response.write news_main()
end select

response.write ender()

function news_del(id)
  on error resume next
  conn.execute("delete from popwin where sort='"&nsort&"' and id="&id)
  call upload_del("update",id)
   if err then
    err.clear
    response.write("<script language=javascript>" & _
		   vbcrlf & "alert(""您的操作有错误（error in del）存在！\n\n点击返回。"");" & _
		   vbcrlf & "location='?nsort="&nsort&"'" & _
		   vbcrlf & "</script>")
  else
   ' call main_update_gunjs("jtdog",4,13,1,1)
    response.write("<script language=javascript>" & _
		   vbcrlf & "alert(""成功删除了一条更新！\n\n点击返回。"");" & _
		   vbcrlf & "location='?nsort="&nsort&"'" & _
		   vbcrlf & "</script>")
  end if
end function

function news_main()
  pageurl="?nsort="&nsort&"&action=main&"
  set rs=server.createobject("adodb.recordset")
  sql=sql&" where sort='"&nsort&"' order by id desc"
  rs.open sql,conn,1,1
  if not(rs.eof and rs.bof) then
    rssum=rs.recordcount
    nummer=15
    call format_pagecute
dim hidden,temp1
hidden=rs("hidden") 
if hidden=0 then  
      temp1=temp1&vbcrlf&"当前弹出窗口状态 不显示"
else
      temp1=temp1&vbcrlf&"当前弹出窗口状态 显示"
end if
    news_main=news_main&vbcrlf&"<script language=JavaScript><!--" & _
	      vbcrlf&"function Do_del_data(data1)" & _
	      vbcrlf&"{" & _
	      vbcrlf&"if (confirm(""此操作将删除id为 ""+data1+"" 的展会信息！\n真的要删除吗？\n删除后将无法恢复！""))" & _
	      vbcrlf&"  window.location=""?nsort="&nsort&"&action=del&id=""+data1" & _
	      vbcrlf&"}" & _
	      vbcrlf&"//--></script>" & _
	      vbcrlf&"<table border=1 width=500 cellspacing=0 cellpadding=1 bordercolorlight=#C0C0C0 bordercolordark=#FFFFFF>" & _
	      vbcrlf&"<tr><td colspan=3 align=center height=30>海风科技</td></tr>" & _
	      vbcrlf&"<tr><td colspan=3 align=center height=30>"&temp1&"</td></tr>" & _
	      "<tr align=center><td width='8%'>序号</td><td width='75%'>标题</td><td width='17%'>操作</td></tr>"
    if int(viewpage)>1 then
      rs.move (viewpage-1)*nummer
    end if
    for i=1 to nummer
      if rs.eof then exit for
      news_main=news_main&vbcrlf&"<tr align=center><td>"&i+(viewpage-1)*nummer&".</td><td align=left>"&code_html(rs("topic"),1,28)&"</td><td><a href='?nsort="&nsort&"&action=edit&id="&rs("id")&"'>修改</a></td></tr>"
      rs.movenext
    next
    news_main=news_main&vbcrlf&"</table>"&kong&pagecute_fun(viewpage,thepages,pageurl)
  end if
  rs.close:set rs=nothing
end function

function news_add()

%>
<body>

<table border="1" cellpadding="1" cellspacing="1" style="border-collapse: collapse" bordercolor="#111111" width="98%">
  <form name="add_frm" action="?action=addchk" method="post">
    <input type="hidden" name="upid" value>
    <tr>
      <td colspan="2" align="center" height="50"><font class="red">添加弹出窗口广告</font></td>
    </tr>
    <tr>
      <td width="15%" align="center">广告标题：</td>
      <td width="85%"><input type="text" name="topic" size="69" maxlength="255"></td>
    </tr>
    <tr>
      <td align="center" height="30">新增类型：</td>
      <td><input type="hidden" name="nsort" value="popwin">窗口弹出时间间隔&nbsp;<input type="text" name="num" size="4">&nbsp;<select size="1" name="cheng">
      <option value="1">秒</option>
      <option value="60">分</option>
      <option value="3600">时</option>
      <option value="86400">天</option>
      </select> 显示滚动条<select size="1" name="scroll">
      <option>yes</option>
      <option>no</option>
      </select> &nbsp;<br>
      窗体名称 <input type="text" name="winname" size="10"> 显示弹出窗口<input type="checkbox" name="hidden" value="yes">
      </td>
    </tr>
    <tr>
      <td align="center" valign="top"><br>
      窗口布局：<br>
      （只能为数字）</td>
      <td>窗口宽度<input type="text" name="width" size="20"> 窗口高度<input type="text" name="height" size="20"><p>
      </p>
      <p>窗口位置上&nbsp;&nbsp;&nbsp;<input type="text" name="top" size="20">&nbsp; 窗口位置左&nbsp;&nbsp;<input type="text" name="left" size="20"></td>
    </tr>
    <tr>
      <td align="center" valign="top">广告地址：</td>
      <td><input type="text" name="href" size="69"></td>
    </tr>
    <tr height="30" align="center">
      <td colspan="2"><input type="submit" value="新 增 更 新">　　　<input type="reset" value="重新填写"></td>
    </tr>
  </form>
</table>
<%
end function

function news_addchk()
  dim topic
  topic=trim(request.form("topic"))
  if len(topic)<1 then
    response.write("<script language=javascript>" & _
		   vbcrlf & "alert(""更新标题 是必须要的！\n\n请返回输入。"");" & _
		   vbcrlf & "history.back(1)" & _
		   vbcrlf & "</script>")
  else
    set rs=server.createobject("adodb.recordset")
    rs.open sql,conn,1,3
    rs.addnew
    rs("sort")=nsort
    rs("topic")=topic
    rs("width")=request.form("width")
    rs("winname")=request.form("winname")
    rs("top")=request.form("top")
    rs("left")=request.form("left")
    rs("height")=request.form("height")
    rs("scroll")=request.form("scroll")
    rs("href")=request.form("href")
    rs("cheng")=request.form("cheng")
    rs("num")=request.form("num")
    rs("tim")=now
    if trim(request.form("hidden"))="yes" then
        rs("hidden")=1
      else
        rs("hidden")=0
      end if
    rs.update
    rs.close:set rs=nothing
    call main_update_gunjs("jtdog",4,13,1,1)
    call upload_note("update",first_id("popwin"))
    response.write("<script language=javascript>" & _
		   vbcrlf & "alert(""成功新增了更新！\n\n点击返回。"");" & _
		   vbcrlf & "location='?nsort="&nsort&"'" & _
		   vbcrlf & "</script>")
  end if
end function

function news_edit(id)
  sql=sql&" where id="&id
  set rs=conn.execute(sql)
  if rs.eof and rs.bof then
    response.write("<script language=javascript>" & _
		   vbcrlf & "alert(""您的操作有错误（error in edit）存在！\n\n点击返回。"");" & _
		   vbcrlf & "location='?nsort="&nsort&"'" & _
		   vbcrlf & "</script>")
  else
    dim msort:msort=rs("sort")
%>
<table border="1" cellpadding="1" cellspacing="1" style="border-collapse: collapse" bordercolor="#111111" width="98%">
  <form name="add_frm" action="?action=editchk&id=<%response.write id%>" method="post">
    <input type="hidden" name="upid" value>
    <tr>
      <td colspan="2" align="center" height="50"><font class="red">修改弹出窗口广告</font></td>
    </tr>
    <tr>
      <td width="15%" align="center">广告标题：</td>
      <td width="85%">
      <input type="text" name="topic" size="69" maxlength="255" value="<%response.write rs("topic")%>"></td>
    </tr>
    <tr>
      <td align="center" height="30">新增类型：</td>
      <td><input type="hidden" name="nsort" value="popwin">窗口弹出时间间隔&nbsp;<input type="text" name="num" size="4" value="<%response.write rs("num")%>">&nbsp;<select size="1" name="cheng">
      <option <%if rs("cheng")="1" then%>selected<%end if%> value="1">秒</option>
      <option <%if rs("cheng")="60" then%>selected<%end if%> value="60">分
      </option>
      <option <%if rs("cheng")="3600" then%>selected<%end if%> value="3600">时
      </option>
      <option <%if rs("cheng")="86400" then%>selected<%end if%> value="86400">天
      </option>
      </select> 显示滚动条<select size="1" name="scroll">
      <option <%if rs("scroll")="yes" then%>selected<%end if%>>yes</option>
      <option <%if rs("scroll")="no" then%>selected<%end if%>>no</option>
      </select> &nbsp;<br>
      窗体名称 
      <input type="text" name="winname" size="10" value="<%response.write rs("winname")%>"> 
      显示弹出窗口<input type="checkbox" name="hidden" value="yes" <%if int(rs("hidden"))=1 then response.write " checked"%>>
      </td>
    </tr>
    <tr>
      <td align="center" valign="top"><br>
      窗口布局：<br>
      （只能为数字）</td>
      <td>窗口宽度<input type="text" name="width" size="20" value="<%response.write rs("width")%>"> 
      窗口高度<input type="text" name="height" size="20" value="<%response.write rs("height")%>"><p>
      </p>
      <p>窗口位置上&nbsp;&nbsp;&nbsp;<input type="text" name="top" size="20" value="<%response.write rs("top")%>">&nbsp; 
      窗口位置左&nbsp;&nbsp;<input type="text" name="left" size="20" value="<%response.write rs("left")%>"></td>
    </tr>
    <tr>
      <td align="center" valign="top">广告地址：</td>
      <td>
      <input type="text" name="href" size="69" value="<%response.write rs("href")%>"></td>
    </tr>
    <tr height="30" align="center">
      <td colspan="2"><input type="submit" value="新 增 更 新">　　　<input type="reset" value="重新填写"></td>
    </tr>
  </form>
</table>

</body>
<%
  end if
  rs.close:set rs=nothing
end function

function news_editchk(id)
  dim topic:topic=trim(request.form("topic"))
  call upload_note("update",id)
  if len(topic)<1 then
    response.write("<script language=javascript>" & _
		   vbcrlf & "alert(""更新标题 是必须要的！\n\n请返回输入。"");" & _
		   vbcrlf & "history.back(1)" & _
		   vbcrlf & "</script>")
  else
    set rs=server.createobject("adodb.recordset")
    sql=sql&" where id="&id
    rs.open sql,conn,1,3
    if rs.eof and rs.bof then
      response.write("<script language=javascript>" & _
		     vbcrlf & "alert(""您的操作有错误（error in editchk）存在！\n\n点击返回。"");" & _
		     vbcrlf & "location='?nsort="&nsort&"'" & _
		     vbcrlf & "</script>")
    else
     rs("sort")=nsort
    rs("topic")=topic
    rs("width")=request.form("width")
    rs("winname")=request.form("winname")
    rs("top")=request.form("top")
    rs("left")=request.form("left")
    rs("height")=request.form("height")
    rs("scroll")=request.form("scroll")
    rs("href")=request.form("href")
    rs("cheng")=request.form("cheng")
    rs("num")=request.form("num")
    rs("tim")=now
    if trim(request.form("hidden"))="yes" then
        rs("hidden")=1
      else
        rs("hidden")=0
      end if
      rs.update
      rs.close:set rs=nothing
      call main_update_gunjs("jtdog",4,13,1,1)
      response.write("<script language=javascript>" & _
		     vbcrlf & "alert(""成功修改了广告！\n\n点击返回。"");" & _
		     vbcrlf & "location='?nsort="&nsort&"'" & _
		     vbcrlf & "</script>")
    end if
  end if
end function

sub main_update_gunjs(n_jt,n_num,c_num,et,timt)
  dim temp1,winname,href,cheng,num,filetemp,fileos,filepath,file_name,filetype
  file_name="js/popwin.js"
  set fileos=CreateObject("Scripting.FileSystemObject")
  filepath=server.mappath(file_name)
  set filetemp=fileos.createtextfile(filepath,true)
  temp1="function Get(){" & _
  vbcrlf&"var Then = new Date() "
  filetemp.writeline(""&temp1&"") 
  set rs=conn.execute("select * from popwin where sort='popwin' order by id desc")
  do while not rs.eof
  winname=rs("winname")
  num=rs("num")
  cheng=rs("cheng")
  href=rs("href")
  filetype="Then.setTime(Then.getTime() + "&num&" * "&cheng&" * 1000 ) //秒" & _
		     vbcrlf&"var cookieString = new String(document.cookie)" & _
		     vbcrlf&"var cookieHeader = ""Cookie1="" " & _
		     vbcrlf&"var beginPosition = cookieString.indexOf(cookieHeader)" & _
		     vbcrlf&"if (beginPosition != -1){ " & _
		     vbcrlf&"} " & _
		     vbcrlf&"else " & _
		     vbcrlf&"{ " & _
		     vbcrlf&"document.cookie = ""Cookie1=POPWIN;expires=""+ Then.toGMTString()  " & _
		     vbcrlf&"window.open('"&href&"','"&winname&"','width="&rs("width")&",height="&rs("height")&",top="&rs("top")&",left="&rs("left")&",scrollbars="&rs("scroll")&"')" & _
		     vbcrlf&"}" & _
		     vbcrlf&"}" & _
		     vbcrlf&"Get();"
   filetemp.writeline(""&filetype&"")
   rs.movenext
   loop
   rs.close:set rs=nothing
   temp1="//代码结束，海风科技"
   filetemp.writeline(""&temp1&"")
end sub
%></html>