<!--#include file="../inc/conn.asp"-->
<%
'============================================================
'插件名称：广告
'Website：http://www.sdcms.cn
'Author：sdcms.cn
'Date：2008-10-28
'============================================================
set sdcms_f=new sdcms_function
id=sdcms_f.Requestint(id)
dim ad_w,ad_h,ad_l

select case action
	case "0":get_ad
	case else:get_ad_group
	end select
set sdcms_f=nothing


Function js_b
	js_b="document.write('"
End Function

Function js_o
	js_o="');"
End Function

Sub get_ad
if isempty(application(sdcms_cookies&"ad"&t1)) then
sdcms_ad=""
set rs=conn.execute("select id,title,url,pic,ispic,ad_w,ad_h,ispass from sd_ad where id="&id&"")
if rs.eof then
	sdcms_ad=sdcms_ad& ""&js_b&"没有找到您要的广告信息"&js_o&""
else
	if rs(7)=0 then
		sdcms_ad=sdcms_ad& ""&js_b&"广告信息未启用"&js_o&"":Died
	end if
	select case rs(4)
	case "0"
		sdcms_ad=sdcms_ad& ""&js_b&"<a href="""&rs(2)&""" target=""_blank"">"&rs(1)&"</a>"&js_o&""
	case "1"
		sdcms_ad=sdcms_ad& ""&js_b&"<a href="""&rs(2)&""" target=""_blank""><img src="""&rs(3)&""" width="""&rs(5)&""" height="""&rs(6)&""" border=""0""></a>"&js_o&""
	case "2"
	sdcms_ad=sdcms_ad& ""&js_b&"<object classid=""clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"" codebase=""http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0"" width="""&rs(5)&""" height="""&rs(6)&""">"&js_o&""&vbLf
  sdcms_ad=sdcms_ad& ""&js_b&"<param name=""movie"" value="""&root&rs(3)&""" />"&js_o&""&vbLf
  sdcms_ad=sdcms_ad& ""&js_b&"<param name=""quality"" value=""high"" />"&js_o&""&vbLf
  sdcms_ad=sdcms_ad& ""&js_b&"<embed src="""&rs(3)&""" quality=""high"" pluginspage=""http://www.macromedia.com/go/getflashplayer"" type=""application/x-shockwave-flash"" width="""&rs(5)&""" height="""&rs(6)&"""></embed>"&js_o&""&vbLf
sdcms_ad=sdcms_ad& ""&js_b&"</object>"&js_o&""&vbLf
	end select
end if
create_app "ad"&id,sdcms_ad
end if
echo application(sdcms_cookies&"ad"&id)
End Sub

Sub get_ad_group
set rs_g=conn.execute("select id,ad_w,ad_h,ad_l,classid from sd_ad_group where id="&id&"")
if rs_g.eof then
	echo ""&js_b&"没有找到您要的广告组信息"&js_o&""
else
    ad_w=rs_g(1)
	ad_h=rs_g(2)
	ad_l=rs_g(3)
    get_ad_code rs_g(0),rs_g(4)
end if
End Sub

Sub get_ad_code(t0,t1)
	set rs=conn.execute("select title,url,pic from sd_ad where gid="&t0&"")
	if rs.eof then
		echo ""&js_b&"没有找到您要的广告信息"&js_o&""
	else
		select case t1
			case "1":ad_code 1,t0
			case "2":ad_code 2,t0
		end select
	end if
End Sub

Sub ad_code(t0,t1)
'增加的广告组方案均可放这里
if isempty(application(sdcms_cookies&"ad_group"&t1)) then
sdcms_ad_group=""
select case t0
	case "1"
		'============================================方案一
		set rs=conn.execute("select top 5 title,url,pic from sd_ad where gid="&t1&" and ispic=1 and right(pic,3)='jpg' order by id desc")
		while not rs.eof
			pics=pics+"|"&rs(2)&""
			links=links+"|"&rs(1)&""
			texts=texts+"|"&left(rs(0),clng(ad_l))&""
		rs.movenext
		wend
		
sdcms_ad_group=sdcms_ad_group& " var focus_width="&ad_w&vbLf
sdcms_ad_group=sdcms_ad_group& " var focus_height="&ad_h&vbLf
sdcms_ad_group=sdcms_ad_group& " var text_height="&ad_l&vbLf
sdcms_ad_group=sdcms_ad_group& " var swf_height = focus_height+text_height"&vbLf
sdcms_ad_group=sdcms_ad_group& " var pics='"&Mid(pics,2)&"'"&vbLf
sdcms_ad_group=sdcms_ad_group& " var links='"&Mid(links,2)&"'"&vbLf
sdcms_ad_group=sdcms_ad_group& " var texts='"&Mid(texts,2)&"' "&vbLf
sdcms_ad_group=sdcms_ad_group& " "&js_b&"<object ID=""focus_flash"" classid=""clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"" codebase=""http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"" width=""'+ focus_width +'"" height=""'+ swf_height +'"">"&js_o&""&vbLf
sdcms_ad_group=sdcms_ad_group& ""&js_b&" <param name=""allowScriptAccess"" value=""sameDomain""><param name=""movie"" value=""/plug/ad/01.swf""><param name=""quality"" value=""high""><param name=""bgcolor"" value=""#ffffff"">"&js_o&""&vbLf
sdcms_ad_group=sdcms_ad_group& ""&js_b&" <param name=""menu"" value=""false""><param name=wmode value=""opaque"">"&js_o&""&vbLf
sdcms_ad_group=sdcms_ad_group& ""&js_b&" <param name=""FlashVars"" value=""pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'"">"&js_o&""&vbLf
sdcms_ad_group=sdcms_ad_group& ""&js_b&" <embed ID=""focus_flash"" src=""/plug/ad/01.swf"" wmode=""opaque"" FlashVars=""pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'"" menu=""false"" bgcolor=""#ffffff"" quality=""high"" width=""'+ focus_width +'"" height=""'+ focus_height +'"" allowScriptAccess=""sameDomain"" type=""application/x-shockwave-flash"" pluginspage=""http://www.macromedia.com/go/getflashplayer""/>"&js_o&""&vbLf
sdcms_ad_group=sdcms_ad_group& ""&js_b&"</object>"&js_o&""&vbLf
		
	case "2"
	'============================================方案二
		set rs=conn.execute("select top 5 title,url,pic from sd_ad where gid="&t1&" and ispic=1 and right(pic,3)='jpg' order by id desc")
		while not rs.eof
			pics=pics+"|"&root&rs(2)&""
			links=links+"|"&rs(1)&""
			texts=texts+"|"&left(rs(0),clng(ad_l))&""
		rs.movenext
		wend
		
sdcms_ad_group=sdcms_ad_group& " var focus_width="&ad_w&vbLf
sdcms_ad_group=sdcms_ad_group& " var focus_height="&ad_h&vbLf
sdcms_ad_group=sdcms_ad_group& " var text_height="&ad_l&vbLf
sdcms_ad_group=sdcms_ad_group& " var swf_height = focus_height+text_height"&vbLf
sdcms_ad_group=sdcms_ad_group& " var pics='"&Mid(pics,2)&"'"&vbLf
sdcms_ad_group=sdcms_ad_group& " var links='"&Mid(links,2)&"'"&vbLf
sdcms_ad_group=sdcms_ad_group& " var texts='"&Mid(texts,2)&"' "&vbLf
sdcms_ad_group=sdcms_ad_group& " "&js_b&"<object ID=""focus_flash"" classid=""clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"" codebase=""http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"" width=""'+ focus_width +'"" height=""'+ swf_height +'"">"&js_o&""&vbLf
sdcms_ad_group=sdcms_ad_group& ""&js_b&" <param name=""allowScriptAccess"" value=""sameDomain""><param name=""movie"" value=""/plug/ad/02.swf""><param name=""quality"" value=""high""><param name=""bgcolor"" value=""#ffffff"">"&js_o&""&vbLf
sdcms_ad_group=sdcms_ad_group& ""&js_b&" <param name=""menu"" value=""false""><param name=wmode value=""opaque"">"&js_o&""&vbLf
sdcms_ad_group=sdcms_ad_group& ""&js_b&" <param name=""FlashVars"" value=""pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'"">"&js_o&""&vbLf
sdcms_ad_group=sdcms_ad_group& ""&js_b&" <embed ID=""focus_flash"" src=""/plug/ad/02.swf"" wmode=""opaque"" FlashVars=""pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'"" menu=""false"" bgcolor=""#ffffff"" quality=""high"" width=""'+ focus_width +'"" height=""'+ focus_height +'"" allowScriptAccess=""sameDomain"" type=""application/x-shockwave-flash"" pluginspage=""http://www.macromedia.com/go/getflashplayer""/>"&js_o&""&vbLf
sdcms_ad_group=sdcms_ad_group& ""&js_b&"</object>"&js_o&""&vbLf
end select
create_app "ad_group"&t1,sdcms_ad_group
end if
echo application(sdcms_cookies&"ad_group"&t1)
End Sub
%>