<!--#include file="head.asp"-->
<style>body{background-color: #fff;}</style>

<%
call chkyanzheng("feikadaili")

rs.open "select ayjihuakamiday from ayquanju" ,conn,1,1
ayjihuakamiday=rs("ayjihuakamiday")
rs.close

set rsdl=server.CreateObject("adodb.recordset")

act=SafeRequest("act")
cact=SafeRequest("cact")
link="feikadaili?ct="
aygismka=1
if SafeRequest("act")="shou" then response.Cookies("shangid")=""
if SafeRequest("act")="shou" then response.Cookies("aykatel")=""

if cact="cha" then


if SafeRequestform("shangid")<>""then
shangid=SafeRequestform("shangid")
elseif SafeRequest("shangid")<>""then
shangid=SafeRequest("shangid")
end if

if SafeRequestform("aykatel")<>"" then
aykatel=SafeRequestform("aykatel")
elseif SafeRequest("aykatel")<>"" then
aykatel=SafeRequest("aykatel")
end if
'if shangid=0 and session("shangid")="" then call PopErr("请选择商品名称")

'if shangid=0 then session("shangid")=""
if aykatel<>"" then
response.Cookies("aykatel")=aykatel
sql2=sql2&" and aykatel='"&aykatel&"'"
else
response.Cookies("aykatel")=""
end if

if shangid<>0 then
response.Cookies("shangid")=shangid

	sql="select aygoodid,aygoodsuoyouid,aygsumid,aygismka,aygooddlid,aysjgid from aygood where aygoodid="&request.Cookies("shangid")&" and aygoodsuoyouid="&request.Cookies("aynameid")&"" 
	rs.open sql,conn,1,1
	if rs.bof and rs.eof then call PopErr("未找到代理产品，或权限不足")
	if clng(rs("aygismka"))=0 then call PopErr("上级代理商禁止查看该商品卖出卡密信息")
	aygooddlid=rs("aygooddlid")  '上级代理ID 默认0无代理
	aysjgid=rs("aysjgid") 		 '上级商品ID
	aygoodsuoyouid=request.Cookies("aynameid")
	rs.close
	
		if clng(aygooddlid)<>0 then '是代理商品 
			For dsum=1 To 10 '10层代理关系
			set rsd=server.CreateObject("adodb.recordset")
			
				'验证代理关系                                                                               '代理商 商户ID                        上级代理 商户ID 
				rsd.open "select aydluserid,aydlsjuserid,aydlistongguo from aydailishang where aydluserid='"&aygoodsuoyouid&"' and aydlsjuserid='"&clng(aygooddlid)&"' and aydlistongguo=1",conn,1,1
				if rsd.bof and rsd.eof then 
				call PopErr("代理关系失效")
				response.End()
				end if
				rsd.close
				 
				'获取代理商品ID                                                                                 '上级商品ID                          上级代理 商户ID 
				rsd.open "select aygismka,aygsumid,aygoodsuoyouid,aysjgid,aygooddlid,aygoodid from aygood where aygoodid="&clng(aysjgid)&" and aygoodsuoyouid="&clng(aygooddlid)&"",conn,1,1
				if not(rsd.bof and rsd.eof) then 
					if clng(rsd("aygooddlid"))=0 then '已是顶级代理
						if clng(rsd("aygismka"))=0 then 
						call PopErr("上级代理商禁止查看该商品已出卡密信息") 
						response.End()
						end if
					response.Cookies("sshangid")=aysjgid
					sjgoodid=aygooddlid
					aysjgid=aysjgid
					rsd.close
					exit for
					else
					aysjgid=rsd("aysjgid") 			    '上级商品ID 
					aygoodsuoyouid=rsd("aygoodsuoyouid") '代理商 商户ID  
					aygooddlid=rsd("aygooddlid")		    '上级代理 商户ID 
					end if
				else
				call PopErr("未找到代理商品")								'未找到代理商品
				end if
				rsd.close
			next 
		end if
	
	
	rs.open "select aynameid,kamiku from ayname where aynameid="&clng(sjgoodid)&"" ,conn,1,1
	kamiku=trim(rs("kamiku"))   '总代 代理卡密库
	rs.close

	sql2=sql2&" and aykagoodid='"&aysjgid&"'"

end if


link="feikadaili?cact=cha&shangid="&request.Cookies("shangid")&"&aykatel="&request.Cookies("aykatel")&""
end if


page=SafeRequest("page")


if act="down" then
Function RndNumber(Min,Max) 
Randomize 
RndNumber=Int((Max - Min + 1) * Rnd() + Min) 
End Function 
suiji=year(now())&Month(now())&day(now())&hour(now())&minute(now())&second(now())
mingcheng=suiji&RndNumber(1000,9999)&".txt"
strOut="商品名称    卡密信息     商品价格      购卡时间       联系方式"&CHR(13)

list1=SafeRequestform("list1")
if list1="" then call PopErr("未找到此项目")
	delid=split(list1,",")

	For dianka=0 To Ubound(delid) 
	'response.Write delid(dianka)
	sql="select * from "&request.Cookies("kamiku")&" where aykaid="&trim(delid(dianka))&" and aydailiid="&clng(request.Cookies("aynameid"))&"" 
	rs.open sql,conn,1,1
	if rs.bof and rs.eof then
	call PopErr("未找到此项目")
	else
		set rsgood=server.CreateObject("adodb.recordset")
		sqlgood="select * from aygood where aygoodid="&clng(rs("aykagoodid"))&"" 
		rsgood.open sqlgood,conn,1,1
		if not(rsgood.bof and rsgood.eof) then
		goodname=trim(rsgood("aygoodname"))
		goodjiage=Formatnumber(rsgood("ayjiage"),2,true,-1,0)&"元"
		else
		goodname="商品或已删除"
		goodjiage="商品或已删除"
		end if
	if trim(rs("aykapass"))="0" then 
	aykapass=" "
	else
	aykapass=trim(rs("aykapass"))
	end if
	strOut=strOut&goodname&"   "&trim(rs("ayka"))&" "&aykapass&"  "&goodjiage&"  "&rs("aykakai")&"  "&trim(rs("aykatel"))&CHR(13)
	rsgood.close
	rs.close
	end if
	next
	
	strOut=strOut&CHR(13)&CHR(13)&webname&CHR(13)&"创建时间 "&now()
	Set fso=Server.CreateObject("Scripting.FileSystemObject")
	set linkw=fso.createtextfile(server.mappath("\upka\"&mingcheng),true)
	linkw.writeline strOut
	linkw.close
	response.Redirect weburl&"show/downfeika.asp?url="&mingcheng
	'response.Redirect("feika?page="&page&"")
set linkw=Nothing
set fso=Nothing
end if
%>


<SCRIPT LANGUAGE="JavaScript">
var checkflag1 = "false";
function check1(field) {
if (checkflag1 == "false") {
for (i = 0; i < field.length; i++) {
field[i].checked = true;}
checkflag1 = "true";
return "false"; }
else {
for (i = 0; i < field.length; i++) {
field[i].checked = false; }
checkflag1 = "false";
return "true"; }
}

function unselectall1()
{
    if(document.myform.chkAll1.checked){
	document.myform.chkAll1.checked = document.myform.chkAll1.checked&0;
	checkflag1 = "false";
    } 	
}
</script>


<main>
<div  class="container">
<div class="ui-lrctnei">
<%call userleft()%>
<div class="r"> 
<div class="ui-content">
                        
					
                            
<div class="neiye">


            <!-------------------------------------- 开始 -------------------------------------->									
            <div class="neibiaoti"></div>
            <div class="neibiaoti2">卖出卡密(代理)</div>
           	<div class="gexian"></div>
   	 		<div class="neitablewu">
					<table>
                  		<tr>
                          <td>

	  <%
	  sql="select * from aygood where aygoodsuoyouid="&request.Cookies("aynameid")&" and aygooddlid<>0 and isptdx=0 order by aygoodsx asc" 
	  rs.open sql,conn,1,1
	  if rs.bof and rs.eof then 
	  call PopErr2("未查询到代理商品","feika")
	  else
	  %>
<form action="?cact=cha" method="post" name="chaxun" id="chaxun">
&nbsp;商品分类：
<select name="shangid" id="shangid" class="reginput">
	   <option value="0">请选择商品</option>
	  <%do while not rs.eof%>
	  <option value="<%=rs("aygoodid")%>" 
	  <%if request.Cookies("shangid")<>"" then
	  if clng(request.Cookies("shangid"))=clng(rs("aygoodid")) then response.Write("selected")
	  end if%>><%=rs("aygoodname")%></option>
	  <%
	  rs.movenext 
	  loop
	  rs.close
	  end if
	  'session("shangid")=""
	  %>
      </select>
&nbsp;
联系方式：
<input name="aykatel" type="text" id="aykatel" value="<%if trim(request.Cookies("aykatel"))<>"" then response.Write server.HTMLEncode(trim(request.Cookies("aykatel")))%>" size="20" class="reginputd" maxlength="15">
<input type="submit" name="Submit" value=" 查 询 " class="logindlregedit">
<a href="feika">[我的产品卖出卡密]</a>
<br>
</form>
                         </td>
                        </tr>
                    </table>
       		</div>
            <div class="gexian20"></div>

            <!-------------------------------------- 结束 -------------------------------------->
                   
                   
           
            
            
            
            <!-------------------------------------- 开始 -------------------------------------->									
                	<div class="neitable">
                    <form action="?act=down" method="post" name="myform" target="_blank" id="myform"> 
					<table>
                        <tr class="hd">
                        	<td width="30">&nbsp;</td>
        					<td>商品名称</td>
                            <td>卡密信息</td>
                            <td>商品价格</td>
                            <td>购卡时间</td>
                            <td>联系方式</td>
                      </tr>
                      
						<%
                        if kamiku="" then
						call PopErr("卡密库错误")
						end if

						benid=tocunid(request.Cookies("aynameid")) '补全

                        if SafeRequest("act")="shou" then
                        sql="select top 500 * from "&kamiku&" where aykadstr like '%"&benid&"%' and aykayesno=1 order by aykakai desc" 
                        else
                        sql="select top 500 * from "&kamiku&" where aykadstr like '%"&benid&"%' and aykayesno=1"&sql2&"  order by aykakai desc" 
                        end if
                        
						'response.Write sql
						'response.End()
						
                        rs.open sql,conn,1,1
                        rs.pagesize=50
                        pagecount=rs.pagecount 
                        if request("page")="" then 
                        page=1
                        else
                        page=int(request("page")) 
                        end if
                        if page<=0 then page=1 
                        if request("page")="" then page=1
                        
                        if not(rs.bof and rs.eof) then
                        rs.absolutepage=page
                        do while not rs.eof%>
                  		<tr onmouseover=this.bgColor='#FAFAFA' onmouseout=this.bgColor='#ffffff'>
                       	  <td><input name="list1" type="checkbox" id="list1" value="<%=rs("aykaid")%>" onClick="unselectall1()"></td>
                            <td>
							<%
                            set rsgood=server.CreateObject("adodb.recordset")
                            sqlgood="select aygoodid,aygsumid from aygood where aygoodid="&clng(rs("aykagoodid"))&"" 
                            rsgood.open sqlgood,conn,1,1
                            if not(rsgood.bof and rsgood.eof) then
                                set rsbg=server.CreateObject("adodb.recordset")
                                sqlbg="select aygoodname,aygoodid,aygsumid,ayjiage,aygismka from aygood where aygsumid='"&trim(rsgood("aygsumid"))&"' and aygoodsuoyouid="&request.Cookies("aynameid")&"" 
                                rsbg.open sqlbg,conn,1,1
                                if not(rsbg.bof and rsbg.eof) then
                                response.Write rsbg("aygoodname")
                                else
                                response.Write("商品或已删除")
                                end if
                            else
                            response.Write("商品或已删除")
                            end if
                            rsgood.close
                            %>
                            </td>
                          	<td>
							<%
                            if cint(rsbg("aygismka"))=0 then
                                response.Write "卡号："&left(trim(rs("ayka")),len(trim(rs("ayka")))-6)&"******<br>"
                                if trim(rs("aykapass"))<>"0"  then
                                response.Write "密码："&left(trim(rs("aykapass")),len(trim(rs("aykapass")))-6)&"******<br>"
                                end if
                            else
                                response.Write "卡号："&trim(rs("ayka"))&"<br>"
                                if trim(rs("aykapass"))<>"0"  then
                                response.Write "密码："&trim(rs("aykapass"))
                                end if
                            end if
                            %>
                            </td>
                			<td>
							<%if not(rsbg.bof and rsbg.eof) then
                            response.Write Formatnumber(rsbg("ayjiage"),2,true,-1,0)&"元"
                            else
                            response.Write("商品或已删除")
                            end if%>
                            </td>
                            <td><%=rs("aykakai")%></td>
                            <td>
							<%if trim(rs("aykatel"))<>"0" then 
							response.Write trim(rs("aykatel"))
							else
							response.Write "-"
							end if%>
                            </td>
                        </tr>
						<%		
						rsbg.close
                        n=n+1
						rs.movenext
						if n>=rs.pagesize then exit do  
						loop
						end if
						zongshu=rs.RecordCount
						rs.close
						%>
                        
                        <tr>
                        <td colspan="6" style="text-align:left">&nbsp;
                        <input name="chkAll1" type="checkbox" id="chkAll1" onClick="this.value=check1(this.form.list1)" value="checkbox">&nbsp;全选&nbsp;
                       <!-- <input type="submit" name="Submit" value="下载到本地" class="logindlregedit"> -->
						<%call pageye()
						response.Cookies("shangid")=""
						response.Cookies("aykatel")=""
						%>

                        </td>
                      </tr>

                    </table>
                    </form>
            		</div>
            <!-------------------------------------- 结束 -------------------------------------->
                        
            
            


                                                                 
                   
            <div class="gexian20"></div>
            <div class="mzsmbox2" style="padding-top:20px;">
            重要提示：已卖出卡密在本平台只保存<%=ayjihuakamiday%>天，请通知买家及时使用，或下载到电脑妥善保存，本平台不提供保管卖出卡密责任！
            </div>

            </div>
            
           




        <div class="clearfix"></div>



</div>








</div>
</div>
</div>
</div>
</main>


<footer>
<div class="container">
</div>
</footer>

</body>
</html>