<!--#include virtual="/show/userhead.asp"-->
<script>document.getElementById('o_2').setAttribute("class", "ed"); document.getElementById("t_2").style.display="";document.getElementById('s_2_4').setAttribute("class", "ed4");</script>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title><%=webname%>-添加卡密</title>
<%Server.ScriptTimeOut = 999999%>
<%
On error resume next 

sid=SafeRequest("sid")

if sid<>""then
sql="select aygoodid,aygoodsuoyouid,aygooddlid from aygood where aygoodid="&sid&" and aygoodsuoyouid="&request.Cookies("aynameid")&"" 
rs.open sql,conn,1,1
if not(rs.bof and rs.eof) then
if clng(rs("aygooddlid"))<>0 then call PopErr("代理商品无法添加卡密，请联系代理商")
end if
rs.close
end if

'rs.open "select kamiku,aynameid from ayname where aynameid="&request.Cookies("aynameid")&"",conn,1,1
'if not(rs.bof and rs.eof) then
'if trim(request.Cookies("kamiku"))<>trim(rs("kamiku")) then call PopErr2("系统数据已更新，请重新登录","/index/exit")
'end if
'rs.close



act=SafeRequestform("act")
if act="add" then

	shangid=SafeRequestform("shangid")
	url=SafeRequestform("url")
	jiancha=SafeRequestform("jiancha")
	if jiancha="" then jiancha=0
	if trim(url)="" then call PopErr("未找到文件")
	

	if shangid<>""then
	sql="select aygoodid,aygoodsuoyouid,aygooddlid,aygoodname from aygood where aygoodid="&shangid&" and aygoodsuoyouid="&request.Cookies("aynameid")&"" 
	rs.open sql,conn,1,1
	if not(rs.bof and rs.eof) then
		if clng(rs("aygooddlid"))<>0 then call PopErr("代理商品无法添加卡密，请联系代理商")
		aygoodname=trim(rs("aygoodname"))
	else
	call PopErr("未找到商品")
	end if
	rs.close
	end if



	'--老版开始----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
'	url=Replace(url,"/", "\")
'	jishu=0
'	set fs=server.createobject("scripting.filesystemobject") 
'	file=server.mappath(url) 
'	set txt=fs.opentextfile(file,1,true) 
'	do While not txt.atendofstream
'		strka=""
'		strmi=0
'		kstr=""
'		kstr=Replace(trim(txt.readline),CHR(9)," ")
'		kstr=trim(kstr)
'		if trim(kstr)<>"" then	
'			kstr=Replace(kstr,"     ","~~")
'			kstr=Replace(kstr,"    ","~~")
'			kstr=Replace(kstr,"   ","~~")
'			kstr=Replace(kstr,"  ","~~")
'			kstr=Replace(kstr," ","~~")
'			mimastr=split(trim(kstr),"~~")
'			if Ubound(mimastr)=0 then
'			strka=trim(mimastr(0))
'			strmi="0"
'			elseif Ubound(mimastr)>0 then
'			strka=trim(mimastr(0))
'			if trim(mimastr(1))<>"" then strmi=trim(mimastr(1))
'			end if
'			if trim(strka)<>"" and cint(jiancha)=1 then	
'				set rsnum=conn.execute("select count(*) as num from "&request.Cookies("kamiku")&" where ayka='"&strka&"' and aykapass='"&strmi&"' and aykagoodid="&shangid&" and aykayesno=0 and aykaisdel=0")
'				if cint(rsnum("num"))=0 then 
'				jishu=jishu+1	
'				conn.Execute("Insert Into "&request.Cookies("kamiku")&"(ayka,aykapass,aykasuoyou,aykagoodid) values('"&strka&"','"&strmi&"','"&request.Cookies("aynameid")&"','"&shangid&"')")
'				end if
'			end if
'			if trim(strka)<>"" and cint(jiancha)=0 then
'			jishu=jishu+1	
'			conn.Execute("Insert Into "&request.Cookies("kamiku")&"(ayka,aykapass,aykasuoyou,aykagoodid) values('"&strka&"','"&strmi&"','"&clng(request.Cookies("aynameid"))&"','"&shangid&"')")	
'			end if
'		end if
'	loop
'	call logadd(request.Cookies("aynameid"),""&shangid&"@#"&aygoodname&"-TXT加卡"&jishu&"张",3,0)
'	call PopErr2("成功添加卡密'"&jishu&"'张",url1&"kucunka?shangid="&shangid&"&cact=cha")
	'--老版END----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
	
	
	'--新版开始----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
	if Application("hostshibie")="" then call PopErr("缺少系统标识")
	url=Replace(url,"/", "\")
	conn.Execute("Insert Into aytxtka(aytxtuid,aytxtgid,aytxthost,aytxtname,aytxtjc) values('"&request.Cookies("aynameid")&"','"&shangid&"','"&Application("hostshibie")&"','"&url&"','"&jiancha&"')")
	call logadd(request.Cookies("aynameid"),""&shangid&"@#-TXT加卡张",3,0)
	call PopErr2("已添加到后台队列，预计1-5分钟完成上传",url1&"kucunka?shangid="&shangid&"&cact=cha")
	'--新版END----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------




end if
%>


<script language=javascript>
function check_add()
{
   if(form1.shangid.value=="0")
   {alert("请选择商品");return false}
   if(form1.url.value=="")
   {alert("请先上传TXT文件");return false}
   document.form1.tijiao.disabled="disabled";
   document.form1.tijiao.value="提交中,请勿刷新或关闭此页";
     
}
</script>
<style>
table{font-size:14px; font-weight:normal;line-height:27px;}
.regts{width:440px; height:36px; border:#CCC solid 1px; background:#f1f1f1; color:#666666; line-height:36px; padding-left:10px}
.reginput{width:290px; height:36px; border:#CCC solid 1px; color:#949494; text-indent:10px; line-height:36px}
.gexian20{float:left;width:100%;height:20px;}
.mzsmbox2{width:90%; height:auto; overflow:hidden; background:#fcf8e2; border-left:#edd28a solid 5px; color:#956825; line-height:22px; padding:20px;margin-left:40px; margin-bottom:60px; font-size:13px;padding-top:20px;}
.neitable table{border: 1px solid #E8E8E8;width: 100%;}
.neitable table tr{border-bottom: 1px solid #E8E8E8;}
.neitable table tr td{line-height: 42px;text-align: center;color: #1b1b1b;font-size: 14px;}
.neitable table tr.hd td{line-height: 35px;background-color: #F7F7F7;}
.btnFn1 {cursor:pointer!important;cursor:hand;  height:40px; width:101px; padding:0px 0px 0 0; }
.btnFn2 {cursor:pointer!important;cursor:hand;  height:40px; width:101px; padding:0px 0px 0 0; font-weight:bold; }
.logindlreg2{cursor:pointer;margin-left:5px; padding:7px;font-family:"Microsoft YaHei",Verdana,Arial; font-size:13px; text-align:center; color:#505050; font-weight:bold; background:#F2F2F2; border:#C3C3C3 solid 1px; border-radius:2px; }
.logindlreg2:hover{color:#505050;border:#999999 solid 1px; border-radius:2px; }
.logindlregedit{ margin-top:3px;height:36px;font-family:"Microsoft YaHei",Verdana,Arial; line-height:30px; font-size:13px; text-align:center; color:#505050; font-weight:bold; background:#F2F2F2;  border:#C3C3C3 solid 1px; border-radius:2px; }
.logindlregedit:hover{color:#505050;border:#999999 solid 1px; border-radius:2px; }
.logindlreg2tj{ margin-top:4px;height:36px;font-family:"Microsoft YaHei",Verdana,Arial; line-height:30px; font-size:13px; text-align:center; color:#ffffff; font-weight:bold; background:#F79740; border:0; border-radius:2px; }
.logindlreg2tj:hover{background:#F99C48; }
.reginputd{ width:190px; height:36px; border:#CCC solid 1px; text-indent:10px; line-height:36px}
.reginputdd{ width:110px; height:36px; border:#CCC solid 1px; text-indent:10px; line-height:36px}
.reginputddd{ width:40px; height:36px; border:#CCC solid 1px; text-indent:10px; line-height:36px}
.reginputdddd{ width:50px; height:36px; border:#CCC solid 1px; text-indent:10px; line-height:36px}
.regt3{ width:650px; height:36px; border:#CCC solid 1px; background:#F9F9F9; color:#999999; line-height:36px; padding-left:10px}
</style>
<br>
<DIV id=main2> 
<DIV style="PADDING-LEFT:0px">
<DIV id=main_right_content>

<H2><SPAN>添加卡密</SPAN></H2>
<DIV class=main4>
                            <link rel="stylesheet" href="/kindeditor/themes/default/default.css" />
                            <script charset="utf-8" src="/kindeditor/kindeditor.js"></script>
                            <script charset="utf-8" src="/kindeditor/lang/zh-CN.js"></script>
                            <script>
                                        KindEditor.ready(function(K) {
                                            var uploadbutton = K.uploadbutton({
                                                button : K('#uploadButton')[0],
                                                fieldName : 'imgFile',
                                                url : '/kindeditor/asp/upload_upka.asp?dir=file',
                                                afterUpload : function(data) { 
                                                    if (data.error === 0) {
                                                        var url = K.formatUrl(data.url, 'absolute');
														//空为不修改URL  "relative" 相对路径  "absolute" 绝对路径   "domain" 带域名的绝对路径
                                                        //urlcon=url.replace("/kindeditor/asp/../../","/"); 
                                                        K('#url').val(url);
														urlok.innerHTML="<span style=color:#3C0>上传成功！</span>";
                                                    } else {
                                                        alert(data.message);
                                                    }
                                                },
                                                afterError : function(str) {
                                                    alert('自定义错误信息: ' + str);
                                                }
                                            });
                                            uploadbutton.fileBox.change(function(e) {
                                                uploadbutton.submit();
                                            });
                                        });
                                    </script>
<form name="form1" method="post" action="" onSubmit="return check_add()">
                        <table class="neitableanquan" width="1080">
                        
           		  		<tr>
                            <td colspan="2" align="center" >商品名称</td>
                            <td colspan="2"  >
                             <select name="shangid" id="shangid" class="reginput">
                               <option value="0">请选择商品</option>
                              <%
                              nogood="no"
                              set rsf=server.CreateObject("adodb.recordset")
                              sqlf="select * from aykafenlei where aykanamesuoyou="&request.Cookies("aynameid")&" and ayshangjiid=0 and ayfenleidlfid=0 order by aykafenleisx asc" 
                              rsf.open sqlf,conn,1,1
                              if rsf.bof and rsf.eof then call PopErr2("请先添加商品分类","fenlei")
                              do while not rsf.eof
                              
                                                  sql="select * from aygood where aygoodsuoyouid="&request.Cookies("aynameid")&" and aygoodfl="&rsf("aykafenleiid")&" and aysjgid=0 order by aygoodsx asc" 
                                                  rs.open sql,conn,1,1
                                                  if not(rs.bof and rs.eof) then 
                                                  nogood="yes"
                                                      do while not rs.eof%>
                                                      <option value="<%=rs("aygoodid")%>" 
                                                      <%
                                                      if sid<>"" then
                                                      if clng(sid)=clng(rs("aygoodid")) then response.Write("selected")
                                                      end if%>><%=trim(rsf("aykafenleiname"))%>>><%=rs("aygoodname")%></option>
                                                      <%	
                                                      rs.movenext 
                                                      loop
                                                  else%>
                                                  <option value="0"><%=trim(rsf("aykafenleiname"))%>>>暂无商品</option>
                                                  <%end if
                                                  rs.close
                              
                                      set rsf2=server.CreateObject("adodb.recordset")
                                      sqlf2="select * from aykafenlei where aykanamesuoyou="&request.Cookies("aynameid")&" and ayshangjiid="&rsf("aykafenleiid")&" and ayfenleidlfid=0 order by aykafenleisx asc" 
                                      rsf2.open sqlf2,conn,1,1
                                      if not(rsf2.bof and rsf2.eof) then
                                      do while not rsf2.eof
                              
                              
                                                  sql="select * from aygood where aygoodsuoyouid="&request.Cookies("aynameid")&" and aygoodfl="&rsf2("aykafenleiid")&" and aysjgid=0 order by aygoodsx asc" 
                                                  rs.open sql,conn,1,1
                                                  if not(rs.bof and rs.eof) then 
                                                  nogood="yes"
                                                      do while not rs.eof%>
                                                      <option value="<%=rs("aygoodid")%>" 
                                                      <%
                                                      if sid<>"" then
                                                      if clng(sid)=clng(rs("aygoodid")) then response.Write("selected")
                                                      end if%>><%=trim(rsf("aykafenleiname"))%>>><%=trim(rsf2("aykafenleiname"))%>>><%=rs("aygoodname")%></option>
                                                      <%	
                                                      rs.movenext 
                                                      loop
                                                  else%>
                                                  <option value="0"><%=trim(rsf("aykafenleiname"))%>>><%=trim(rsf2("aykafenleiname"))%>>>暂无商品</option>
                                                  <%end if
                                                  rs.close
                                              
                                      rsf2.movenext 
                                      loop	 
                                      end if
                                      rsf2.close
                                      
                                      
                              rsf.movenext 
                              loop 
                              rsf.close
                              %>
                              </select>
                              <%if nogood="no" then call PopErr2("请先添加商品","goodadd")%>
                            </td>
                          	<td width="651"><div class="regt3" > 请选择卡密所属商品</div></td>
                        </tr>
           		  		<tr>
                            <td colspan="2" align="center"  >添加方式</td>
                            <td colspan="2"  >
<input name="fangshi" id="fangshi" type="radio" onClick="javascript:window.top.location.href='kaadd?sid=<%=sid%>'" value="0" ><label for="fangshi" style="cursor:pointer;font-weight:lighter;">使用输入框添加 </label>&nbsp;
<input name="fangshi" id="fangshi2" type="radio" value="1" onClick="javascript:window.location.href='kaaddtxt?sid=<%=sid%>'" checked><label for="fangshi2" style="cursor:pointer;font-weight:lighter;">使用TXT文件导入</label>
                            </td>
                          	<td><div class="regt3" > 请选择一种添加卡密的方式</div></td>
                        </tr>
           		  		<tr>
                            <td colspan="2" align="center"  >选择文件</td>
                            <td width="136"  ><div style="width:10px; height:13px;"></div>
                            <input name="url" type="hidden" class="ke-input-text" id="url" value=""/> <input type="button" id="uploadButton" value="上传TXT文件" />
                          </td>
                            <td width="175"  ><span id="urlok"></span></td>
                          	<td><div class="regt3" > 选择要添加卡密的TXT文本文件</div></td>
                        </tr>
           		  		<tr>
                            <td colspan="2" align="center"  >检查重复</td>
                            <td colspan="2"  ><input name="jiancha" type="checkbox" value="1">添加成功后删除重复卡密</td>
                          	<td><div class="regt3" > <span style="color:#F30">卡密成功添加后，将检测并删除该商品下重复卡密，重复卡密只保留最近添加的一条卡密</span></td>
                        </tr>
           		  		<tr>
                            <td colspan="2" align="center"  ><input name="act" type="hidden" value="add"></td>
                            <td colspan="3"><input class="logindlreg" type="submit" name="Submit" id="tijiao" value=" 添 加 卡 密 " onSubmit="return check_add()"></td>
                       	  </tr>

                    </table>
                    </form>
                    
                    <br>
            <div class="mzsmbox2" style="padding-top:20px;">
			卡密格式1(有卡号也有密码的)：卡号+空格+密码  &nbsp;&nbsp;一行一张卡，如：KAsdf2d3d4dg5d8 &nbsp;MI9876543210 <br>
	  		卡密格式2(有卡号没有密码的)：卡号 一行一张卡，如：KAsdf2d3d4dg5d8 <br>
            注意事项：输入框添加卡密最多一次添加1000张(1000行)，TXT文件上传最多支持1MB。<br>
            </div>
</DIV>


</DIV></DIV>
<DIV class=clear></DIV></DIV>
</DIV>

<br>

	<!--#include virtual="/show/foot.asp"-->


