<%
 data_path="../" 'ACC连接数据库路径，对SQL无效 
  numid="no"
 dir="no"
%>
<!--#include file="../conn/conn.asp"-->
<!--#include file="../inc/safe.asp"-->
  <%
if issession=0 then
%>
<!--#include file="inc.asp"-->

<%
	If boollogin=false then
              Response.write "<script language='javascript'>"
              Response.write"alert('对不起！请重新登陆！');parent.location.href='"&HOPE_InstallDir&"';</SCRIPT>" 
              Response.End
   End If
  else
	  if session("globalecmaster")="" and  session("masterflag")="" then
              Response.write "<script language='javascript'>"
              Response.write"alert('对不起！请重新登陆！');parent.location.href='"&HOPE_InstallDir&"';</SCRIPT>" 
              Response.End
   End If
 
 
   if   session("masterflag")<>"" then 
   '权限验证--------------------------------------------
  if numid<>"no" then 
  	'权限限制^^^^^^^^^^^^^^^^^^^^
	 dim ishavegantadmin
	 ishavegantadmin=false
	 in_str=split(session("masterflag"),",")
	 for each ins in in_str 
	 if trim(ins)=numid  then 
	 ishavegantadmin=true 
	 end if
	 next 
	 if ishavegantadmin=false then 
	 if dir<>"no" then 
	 response.redirect dir
	 response.end
	 end if
	 end if
  end if
   '--------------------------------------------------
 end if
 end if
%>


<%
	Dim ADID,HostURL,ScrCode,JsCode
	
	 ADID=Request.QueryString("id")

set rs1=server.CreateObject("adodb.recordset")
sql1 = "select * from [Websen_advertisement] where ADname='"&ADID&"'"
		rs1.open sql1,conn,1,3
	if  eof then	
	 Response.Write ("<script>alert('对不起，该广告类型不存在!');history.back();</script>")
	 else
       ADNote=rs1("ADNote") 
       ADSrc=rs1("ADSrc")
       ADLink=rs1("ADLink")
       ADAlt=rs1("ADAlt")
	  rs1("adreplace")=1
	 end if
rs1.update	 
rs1.close
set rs1=nothing
	   
	   set rs2=server.CreateObject("adodb.recordset")
sql2 = "Select ADSrc,ADAlt,ADlink,ADNOte,ADStopDate from [Websen_ad] where ADID='" & ADID & "'"
		rs2.open sql2,conn,1,3
		
		rs2("ADsrc")=ADsrc
		rs2("ADAlt")=ADAlt
		rs2("ADLink")=ADLink
		rs2("ADnote")=ADNote

		rs2.update
		rs2.close
		set rs2=nothing



	
	Dim AD_Type,AD_Src,AD_Width,AD_Height,AD_Link,AD_Alt,AD_Views,ADViews,AD_Hits,ADHits,AD_Stop_Views,AD_Stop_Hits,AD_Stop_Date
		Response.Expires = 0

		ADID=Request.QueryString("ID")
		HostURL="http://"&Request.Servervariables("server_name")&replace(Request.Servervariables("url"),"/createjs.asp","")

	Set rs=server.createobject("adodb.recordset")
		sql = "Select ADType,ADSrc,ADWidth,ADHeight,ADAlt,ADViews,ADHits,ADStopViews,ADStopHits,ADStopDate from [Websen_ad] where ADID='" & ADID & "'"
		rs.open sql,conn,1,3
	If Not (rs.bof or rs.eof) Then
		AD_Type=rs("ADType")
		AD_Src=rs("ADSrc")
		AD_Width=rs("ADWidth")
		AD_Height=rs("ADHeight")
		AD_Alt=rs("ADAlt")
		AD_Views=rs("ADViews")
		AD_ADHits=rs("ADHits")
		AD_Stop_Views=rs("ADStopViews")
		AD_Stop_Hits=rs("ADStopHits")
		AD_Stop_Date=rs("ADStopDate")
		rs("ADViews")= AD_Views + 1
		rs.Update
	Else
		response.write "document.write('<! -- 没有找到您要浏览的广告 -->');"
	End If
		rs.Close
	Set rs=nothing
		conn.Close
	Set conn=nothing

	If ( AD_Stop_Views <> 0 and AD_Views > AD_Stop_Views) Then AD_Type = 0
	If ( AD_Stop_Hits <> 0 and AD_Hits > AD_Stop_Hits) Then AD_Type = 0
	If ( NOW() > AD_Stop_Date) Then AD_Type = 0

	If InStr(1,AD_Src,".swf",1)>0 Then
		ScrCode="<EMBED src="""& AD_Src &""" quality=high WIDTH="""& AD_Width &""" HEIGHT="""& AD_Height &""" TYPE=""application/x-shockwave-flash"" PLUGINSPAGE=""http://www.macromedia.com/go/getflashplayer""></EMBED>"
	Else
		ScrCode="<a href="""& HOPE_InstallDir &"ads/openad.asp?adid="& ADID &""" target=_blank><img src="""& AD_Src &""" border=0 width="""& AD_Width &""" height="""& AD_Height &""" alt="""& AD_Alt &""" align=top></a>"
	End If


	Select Case AD_Type
	Case 0
		JsCode= "document.write('<!-- 过期广告 ID"&ADID&" -->')"
	Case 1
		JsCode= "document.write('"& ScrCode &"');"
	Case 2
		JsCode= "ns4=(document.layers)?true:false;" & vbCrLf & _
				"ie4=(document.all)?true:false;" & vbCrLf & _
				"if(ns4){document.write('<layer id=DGbanner2 width="& AD_Width &" height="& AD_Height &" onmouseover=stopme(""DGbanner2"") onmouseout=movechip(""DGbanner2"")>"& ScrCode &"</layer>');}" & vbCrLf & _
				"else{document.write('<div id=DGbanner2 style=""position:absolute; width:"& AD_Width &"px; height:"& AD_Height &"px; z-index:9; filter: Alpha(Opacity=90)"" onmouseover=stopme(""DGbanner2"") onmouseout=movechip(""DGbanner2"")>"& ScrCode &"</div>');}" & vbCrLf & _
				"document.write('<script language=javascript src="& HostURL &"/images/ad_float_fullscreen.js></script>');"
	Case 3
		JsCode= "if (navigator.appName == 'Netscape')" & vbCrLf & _
				"{document.write('<layer id=DGbanner3 top=150 width="& AD_Width &" height="& AD_Height &">"& ScrCode &"</layer>');}" & vbCrLf & _
				"else{document.write('<div id=DGbanner3 style=""position: absolute;width:"& AD_Width &";top:150;visibility: visible;z-index: 1"">"& ScrCode &"</div>');}" & vbCrLf & _
				"document.write('<script language=javascript src="& HostURL &"/images/ad_float_upanddown.js></script>');"
	Case 4
		JsCode= "if (navigator.appName == 'Netscape')" & vbCrLf & _
				"{document.write('<layer id=DGbanner10 top=150 width="& AD_Width &" height="& AD_Height &">"& ScrCode &"</layer>');}" & vbCrLf & _
				"else{document.write('<div id=DGbanner10 style=""position: absolute;width:"& AD_Width &";top:150;visibility: visible;z-index: 1"">"& ScrCode &"</div>');}" & vbCrLf & _
				"document.write('<script language=javascript src="& HostURL &"/images/ad_float_upanddown_L.js></script>');"
	Case 5
		JsCode= "ns4=(document.layers)?true:false;" & vbCrLf & _
				"if(ns4){document.write('<layer id=DGbanner4Cont onLoad=""moveToAbsolute(layer1.pageX-160,layer1.pageY);clip.height="& AD_Height &";clip.width="& AD_Width &"; visibility=show;""><layer id=DGbanner4News position:absolute; top:0; left:0>"& ScrCode &"</layer></layer>');}" & vbCrLf & _
				"else{document.write('<div id=DGbanner4 style=""position:absolute;top:0; left:0;""><div id=DGbanner4Cont style=""position:absolute; width:"& AD_Width &"; height:"& AD_Height &";clip:rect(0,"& AD_Width &","& AD_Height &",0)""><div id=DGbanner4News style=""position:absolute;top:0; left:0; right:820"">"& ScrCode &"</div></div></div>');} " & vbCrLf & _
				"document.write('<script language=javascript src="& HostURL &"/images/ad_fullscreen.js></script>');"
	Case 6
		JsCode= "window.showModalDialog('"& AD_Src &"','','dialogWidth:"& AD_Width &"px;dialogHeight:"& AD_Height &"px;scroll:no;status:no;help:no');"
	Case 7
		JsCode= "document.write('<script language=javascript src="& HostURL &"/images/ad_dialog.js></script>'); " & vbCrLf & _
				"document.write('<div style=""position:absolute;left:300px;top:150px;width:"& AD_Width &"; height:"& AD_Height &";z-index:1;solid;filter:alpha(opacity=90)"" id=DGbanner5 onmousedown=""down1(this)"" onmousemove=""move()"" onmouseup=""down=false""><table cellpadding=0 border=0 cellspacing=1 width="& AD_Width &" height="& AD_Height &" bgcolor=#000000><tr><td height=18 bgcolor=#5A8ACE align=right style=""cursor:move;""><a href=# style=""font-size: 9pt; color: #eeeeee; text-decoration: none"" onClick=clase(""DGbanner5"") >关闭>>><img border=""0"" src="""&HostURL&"/images/close_o.gif""></a>&nbsp;</td></tr><tr><td bgcolor=f4f4f4 >&nbsp;"& ScrCode &"</td></tr></table></div>');"
	Case 8
		JsCode= "window.open('"& AD_Src &"','_blank');"
	Case 9
		JsCode= "window.open('"& AD_Src &"','DGBANNER7','width="& AD_Width &",height="& AD_Height &",scrollbars=1')"
	Case 10
	
		JsCode= "var left_img='"&ScrCode&"';"& vbCrLf & _
				"var right_img='"&ScrCode&"';"& vbCrLf & _
				"document.write('<script language=javascript src="& HostURL &"/images/piaofu.js></script>');"
	End Select

	If JsCode<>"" Then
	On Error Resume Next
		JsFileName = Server.MapPath("JS\"&ADID&".js")
		JsCode = "<!--" & vbCrLf & JsCode & vbCrLf &"//-->"  
	set objStream = Server.CreateObject("ADODB.Stream")
	With objStream
		.Open
		.Type = 2
		.Charset = "GB2312"
		.WriteText JsCode
		.SaveToFile JsFileName, 2
		.Close
	End With
	Set objStream = Nothing
    If Err <> 0 Then
		Response.Write ("<script>alert(' 生成JS代码失败! \n\n "& Err.Description &"');history.back();</script>")
	Else
		Response.Write ("<form name='form1' method='post' action='timesave.asp'>")
		Response.Write("<table width='98%' border='0' align=center cellpadding=3 cellspacing=1 bgcolor='#CEE0FF'>")
       
        Response.Write("<tr bgcolor='#c0c0c0'> ")
          Response.Write("<td height=25 bgcolor=#DEEEFE><div align=center> 请输入该广告的到期时间：")
         
            
          Response.Write("<input type='hidden' name='adid'")
		  Response.Write(" value='"&adid&"'>")
		

          Response.Write(" <input type='text' name='ADStopDate'>")
           Response.Write("<span class='STYLE1'>*格式如2007-11-22</span></div></td>")
        Response.Write("</tr>")	
				Response.Write("<tr  bgcolor='#c0c0c0'>")
		Response.Write("<td height='25' bgcolor='#DEEEFE'><label>")
		Response.Write("<div align='center'>")
		Response.Write("<input type='submit' name='Submit2' value='提交'>")
	      Response.Write("<input type='button' name='Submit3' value='重填'>")
Response.Write("</div>")
	Response.Write("	</label></td>")
		Response.Write("</tr></table>")
    
Response.Write("</form>	")
	End If
	
	Else
		Response.Write ("<script>alert(' 生成JS代码失败! \n\n 广告类型不正确!');history.back();</script>")
	End If
%>