<!--#include file="../conn.asp"-->
<!--#include file="z_adv_conn.asp"-->
<!--#include file="../fun.asp"-->
<%
dim stats,sql_adv,rs_adv,myid,mymoney,myep,mysave,mylife,rs,sql,LxTelMB,BoardData,sys,fString,Integral,Credit

sys=sysinfo()
LxTelMB=LxTel_MB '读取模板
fString = replace(LxTelMB(2,0), "$Subject$", "广告公司")
fString = replace(fString, "$Url$", sys(5,0))
Response.Write fString '输出顶部内容
Menu
Response.Write "<table width="&LxTelMB(1,0)&" align=center border=1 class=table0 style=""border-collapse: collapse""><tr><td height=27>&nbsp;<img src=../images/sys/nav.gif>&nbsp;<a href=../index.asp>论坛首页</a>&nbsp;→&nbsp;广告公司</td></tr></table>"

if Request.Cookies(BBSInfo&"username")=empty then
Response.Write "<li>您还未<a href=login.asp>登录</a>社区"
else
    if not IsObject(conn) then
        LinkData
    end if
    sql="select * from LxTel_User where username='"&trim(Request.Cookies(BBSInfo&"username"))&"'"
    set rs=server.createobject("adodb.recordset")
    rs.Open sql,conn,1,1
    myid=rs("id")
    mymoney=rs("moneynum")
    myep=rs("Experience")
    Integral=rs("Integral")
    Credit=rs("Credit")
	dim action
	action=request("action")
	if action="save" then 
		call save()
	elseif action="update" then
		call update()
	else
		call main()
	end if
end if
sub main()
	set rs_adv=server.createobject("adodb.recordset")
	sql_adv="select * from [adv_config] where adv_type='默认'"
	rs_adv.Open sql_adv,conn_adv,1,1
	if rs_adv.eof and rs_adv.bof then
		error("广告公司尚未启用。")
		else
		dim adv_url
		dim adv_txt
		dim adv_img
		dim adv_cheat
		dim adv_wealth
		dim adv_ep
		dim myurl
		myurl=""&sys(5,0)&"/ad/"
		if mid(myurl,len(myurl),1)="/" then myurl=mid(myurl,1,len(myurl)-1)
		adv_url=rs_adv("adv_url")
		adv_txt=rs_adv("adv_txt")
		adv_img=rs_adv("adv_img")
		adv_cheat=rs_adv("adv_cheat")
		adv_wealth=rs_adv("adv_wealth")
		adv_ep=rs_adv("adv_ep")
		end if
	rs_adv.close
	set rs_adv=nothing
    Response.Write "<div align=center>"
	Response.Write "<table width="&LxTelMB(1,0)&" cellspacing=1 cellpadding=6><tr>"
	Response.Write "<TD width=220 valign=top>"
        Response.Write " <TABLE height=100% width=100% cellSpacing=1 cellPadding=3 border=0 class=a2>"
	Response.Write "<tr><td align=middle class=a1 colspan=4><b>广告经纪人排行</b></td></tr>"
	Response.Write "<tr class=a3 height=22><td align=middle>名次</td><td align=middle>姓名</td><td align=middle>反馈量</td></tr>"
	
	set rs_adv=server.createobject("adodb.recordset")
	sql_adv="select top 12 * from [adv_broker] where count_Z<>0 order by count_Z desc"
	rs_adv.Open sql_adv,conn_adv,1,2
	dim i
	i=1
	do while not rs_adv.eof
		Response.Write "<tr class=a3 height=22><td align=middle><img src='images/img_adv/level-1-"&i&".gif'></td>"
		Response.Write "<td align=middle><a href='Profile.asp?"&rs_adv("username")&"' target='_blank'>"&rs_adv("username")&"</a></td><td align=middle><b>"&rs_adv("count_z")&"</b></td></tr>"
		i=i+1
		rs_adv.movenext
	loop

	rs_adv.close
	Response.Write "</table><br><table align=center cellSpacing=1 cellPadding=3 border=0 class=a2><tr class=a3 height=22><td><a href=z_adv_admin.asp>广告公司管理</a>[非指定人员勿入]</td></tr></table></td><td width=530 valign=top><TABLE>"
	Response.Write "<tr><td><table width=100% cellspacing=1 cellpadding=1 class=a2 valign=top><tr><td class=a1 height=25 align=middle><b>您的业务统计</b>"
         Response.Write "</td></tr><tr><td class=a3>"
	sql_adv="select * from [adv_broker] where username='"&Request.Cookies(BBSInfo&"username")&"'"
	rs_adv.Open sql_adv,conn_adv,1,2
	if rs_adv.eof and rs_adv.bof then
               
                Response.Write "<table width='100%' border='0' cellpadding='3' cellspacing='1' class=a2><tr class=a3><td width=30% border=0>"
Response.Write "<center>欢迎你，<b>"&Request.Cookies(BBSInfo&"username")&"</b></center>"              
Response.Write "<br><li>目前现金："&mymoney&""
Response.Write "<br><li>目前经验："&myep&""
Response.Write "<br><li>目前积分："&Integral&""
Response.Write "<br><li>目前声望："&Credit&""
Response.Write "</td><td width=70% border=0>"
		Response.Write "<li><b>业务介绍：</b>通过做社区的广告经纪人赚钱<br><br><li><b>办理费用：</b>完全免费<br><br><li><b>办理条件：</b>只要是会员均可，只要办理一张证书<br>　　　   　　<a href='?action=save'><img src='images/img_adv/adv_1.gif' border=0></a></td></tr>" 
	else
                Response.Write "<table width='100%' border='0' cellpadding='3' cellspacing='1' class=a2><tr class=a3><td>"
Response.Write "<center>欢迎你，<b>"&Request.Cookies(BBSInfo&"username")&"</b></center>"              
Response.Write "<br><li>目前现金："&mymoney&""
Response.Write "<br><li>目前经验："&myep&""
Response.Write "<br><li>目前积分："&Integral&""
Response.Write "<br><li>目前声望："&Credit&""
Response.Write "</td><td>"
		Response.Write "<li>总有效广告反馈量："&rs_adv("count_z")
		Response.Write "次<br><br><li>本次累积的反馈量："&rs_adv("count_b")
		Response.Write "次<br><br><li>本次共累积<br>　　　   佣金："&rs_adv("count_b")*adv_wealth
		Response.Write "元<br>　　　   经验："&rs_adv("count_b")*adv_ep
		Response.Write "点</td><td align=middle>"
                Response.Write "您上次领取佣金时间："&rs_adv("updatetime")		
Response.Write "<br><br><a href='?action=update'><img src='images/img_adv/adv_2.gif' border=0></a></td></tr>"
                end if
	rs_adv.close	
	Response.Write "</table></td></tr></table></td></tr><tr><td height=15></td></tr>"
	Response.Write "<tr><td><TABLE height=100% cellSpacing=1 cellPadding=3 border=0 class=a2><tr><td align=middle height=25 class=a1><b>宣传方式</b></td>"
	Response.Write "</tr><tr><td class=a3 height=25><font color=red><b>你的广告代码："
	Response.Write myurl&"/get.asp?get="&myid
	Response.Write "</b></font></td></tr><tr><td class=a3>"
	%>
          <table width="100%" border="0" cellspacing="0" cellpadding="3">
              

           <tr><td><b><br>方法一：在其他论坛或聊天室发带有以下链接的帖子</b><br><br>
            </td></tr>
              <tr> 
                <td>在支持UBB的论坛上可以是这样</td>
              </tr>
              <tr> 
                <td><input name="textarea" type="text" style="width:470px" style="border: 1px  solid #000000; height: 18px;" value="[url=<%=myurl%>/get.asp?get=<%=myid%>]<%=adv_txt%>[/url]
		"></td>
              </tr>
              <tr> 
                <td><font color="#FF0000">效果：</font><a target=_blank href=<%=myurl%>/get.asp?get=<%=myid%>><%=adv_txt%></a></td>
              </tr>
              <tr> 
                <td>在论坛上，还可以把图片链接放到签名里（在帖子里好像不行）</td>
              </tr>
              <tr> 
                <td><input name="textfield" type="text" style="width:470px" style="border: 1px  solid #000000; height: 18px;"  value="[url=<%=myurl%>/get.asp?get=<%=myid%>][IMG]<%=adv_img%>[/IMG][/URL]
		"></td>
              </tr>
              <tr> 
                <td><font color="#FF0000">效果：</font><a href=<%=myurl%>/get.asp?get=<%=myid%>><img border=0 src="<%=adv_img%>"></a></td>
              </tr>
            </table>
	<%
	Response.Write "</td></tr><tr><td class=a3>"
        Response.Write "<table width=100% cellspacing=0 cellpadding=3><td>"
       Response.Write "<tr><b><br>方法二：将此链接通过邮件或者QQ发给你的朋友</b></td></tr><tr><td>"
	Response.Write "<br><font color=red>代码："
	Response.Write myurl&"/get.asp?get="&myid
        response.Write "</font></td></tr></table><tr><td class=a3><table width=100% cellspacing=0 cellpadding=3><tr><td><br><b>广告公司说明：</b><br></td></tr><tr><td>"
	Response.Write "<li>将广告代码贴到其他论坛或主页等地方，别人通过这个链接进入本社区，您就能获得反馈。<br><br><li>您可根据反馈量获得奖励，交换比例暂定为：(<font color=red>"&adv_wealth&"</font>元现金+<font color=red>"&adv_ep&"</font>点经验/每反馈点。<br><br><li>为防止作弊，同一IP地址在<font color=red>"&adv_cheat&"</font>分钟内重复点击，只算一次点击。 </td></tr>"
	Response.Write "</table></td></tr></table></td></tr></table></td></tr></table></div>"

end sub

'领取证书
sub save()
	set rs_adv=server.createobject("adodb.recordset")
	sql_adv="select * from [adv_broker] where username='"&Request.Cookies(BBSInfo&"username")&"'"
	rs_adv.Open sql_adv,conn_adv,1,2
	if rs_adv.eof and rs_adv.bof then
		rs_adv.addnew
		rs_adv("userid")=myid
		rs_adv("username")=Request.Cookies(BBSInfo&"username")
		rs_adv("addtime")=now()
		rs_adv.update
		rs_adv.close
		set rs_adv=nothing
		conn_adv.close
		Response.Write "广告经纪人证书领取成功，请返回刷新一下吧！"
		else
		rs_adv.close
		set rs_adv=nothing
		conn_adv.close
		Response.Write "你已经领取证书了，请不要重复申领。"
		end if
end sub

'领取佣金
sub update()
	set rs_adv=server.createobject("adodb.recordset")
	sql_adv="select * from [adv_broker] where userid="&myid
	rs_adv.Open sql_adv,conn_adv,1,2
	if rs_adv.eof and rs_adv.bof then
		rs_adv.close
		set rs_adv=nothing
		conn_adv.close
		
		Response.Write "你尚未办理广告经纪人证书，请到<a href=z_adv.asp>广告公司</a>去申请吧。"
		
	else
		if rs_adv("updatetime")=date() then
			rs_adv.close
			set rs_adv=nothing
			conn_adv.close	
			Response.Write "你今天已经领取佣金了，明天再来吧。"
			
		else
			rs_adv("updatetime")=date()
			dim dianshu
			dianshu=rs_adv("count_b")
			rs_adv("count_b")=0
			rs_adv.update
			rs_adv.close

			set rs_adv=server.createobject("adodb.recordset")
			sql_adv="select * from [adv_config] where adv_type='默认'"
			rs_adv.Open sql_adv,conn_adv,1,1
			if rs_adv.eof and rs_adv.bof then
				Response.Write "出现故障了，数据找不到了，请联系管理员。"
			else
				dim adv_wealth
				dim adv_ep
				dim myurl
				adv_wealth=rs_adv("adv_wealth")
				adv_ep=rs_adv("adv_ep")
				end if
			rs_adv.close
	        if not IsObject(conn) then
                LinkData
            end if
			sql= "select Experience,MoneyNum from [lxtel_user] where username='"&trim(Request.Cookies(BBSInfo&"username"))&"'"
			set rs=server.createobject("adodb.recordset")
			rs.open sql,conn,1,3
			if not rs.eof then
				rs("MoneyNum")=rs("MoneyNum")+dianshu*adv_wealth
				rs("Experience")=rs("Experience")+dianshu*adv_ep
				rs.update
			end if
			rs.close
			set rs=nothing
			Response.Write "你已成功领取佣金：金钱"&dianshu*adv_wealth&"，经验"&dianshu*adv_ep&"。"
			end if
	end if
end sub
tom
%>