kc.php 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <?
  2. include("../config/conn.php");
  3. include("../config/function.php");
  4. sesCheck();
  5. $bh=$_GET[bh];
  6. $sqluser="select * from yjcode_user where uid='".$_SESSION[SHOPUSER]."' and zfmm='".$_SESSION[SAFEPWD]."'";mysql_query("SET NAMES 'GBK'");$resuser=mysql_query($sqluser);
  7. if(!$rowuser=mysql_fetch_array($resuser)){Audit_alert("卡密信息操作需要先进行安全码验证!","safepwd.php");}
  8. $userid=$rowuser[id];
  9. //函数开始
  10. if($_GET[control]=="add"){
  11. zwzr();
  12. if($_POST[Rtjfs]=="txt"){
  13. $c=str_replace("\r","",($_POST[s1]));
  14. $d=preg_split("/\n/",$c);
  15. for($i=0;$i<=count($d);$i++){
  16. if(!empty($d[$i])){
  17. $e=preg_split("/\s/",$d[$i]);
  18. if(panduan("probh,userid,ka","yjcode_kc where probh='".$bh."' and ka='".$e[0]."' and userid=".$userid)==0){
  19. $mi="";
  20. if(count($e)>=2){for($ei=1;$ei<count($e);$ei++){$mi=$mi." ".$e[$ei];}}
  21. intotable("yjcode_kc","probh,userid,ka,mi,ifok","'".$bh."',".$userid.",'".$e[0]."','".$mi."',0");
  22. }
  23. }
  24. }
  25. }elseif($_POST[Rtjfs]=="one"){
  26. if(panduan("probh,userid,ka","yjcode_kc where probh='".$bh."' and ka='".sqlzhuru($_POST[tka])."' and userid=".$userid)==1){
  27. Audit_alert("卡号已存在,添加失败!","kc.php?bh=".$bh);
  28. }
  29. intotable("yjcode_kc","probh,userid,ka,mi,ifok","'".$bh."',".$userid.",'".sqlzhuru($_POST[tka])."','".sqlzhuru($_POST[tmi])."',0");
  30. }else{
  31. $up1=$_FILES["inp1"]["name"];
  32. if(!empty($up1)){
  33. $hz=returnhz($up1);
  34. if($hz!="xls"){Audit_alert("失败.只能上传导入.xls后缀的文件,返回重试","kc.php?bh=".$bh);}
  35. $mu="../upload/".$userid."/";
  36. inp_tp_upload(1,$mu,$bh,"xls");
  37. //导入开始
  38. require_once '../config/Excel/reader.php';
  39. $data = new Spreadsheet_Excel_Reader();
  40. $data->setOutputEncoding('CP936');
  41. $data->read($mu.$bh.".xls");
  42. error_reporting(E_ALL ^ E_NOTICE);
  43. for ($i = 1; $i <= $data->sheets[0]['numRows']; $i++) {
  44. $ka= $data->sheets[0]['cells'][$i][1]."";
  45. $mi= $data->sheets[0]['cells'][$i][2]."";
  46. if(panduan("probh,userid,ka","yjcode_kc where probh='".$bh."' and ka='".$ka."' and userid=".$userid)==0){
  47. intotable("yjcode_kc","probh,userid,ka,mi,ifok","'".$bh."',".$userid.",'".$ka."','".$mi."',0");
  48. }
  49. }
  50. //导入结束
  51. delFile($mu.$bh.".xls");
  52. }
  53. }
  54. kamikc($bh);
  55. php_toheader("kc.php?t=suc&bh=".$bh);
  56. }elseif($_GET[control]=="update"){
  57. zwzr();
  58. $id=$_GET[id];
  59. if(panduan("id,probh,userid,ka","yjcode_kc where probh='".$bh."' and ka='".sqlzhuru($_POST[tka])."' and id<>".$id." and userid=".$userid)==1){
  60. Audit_alert("卡号已存在,保存失败!","kc.php?bh=".$bh."&action=update&id=".$id);}
  61. updatetable("yjcode_kc","ka='".sqlzhuru($_POST[tka])."',mi='".sqlzhuru($_POST[tmi])."',ifok=".sqlzhuru($_POST[Rifok])." where id=".$id);
  62. kamikc($bh);
  63. php_toheader("kc.php?t=suc&bh=".$bh."&action=update&id=".$id);
  64. }
  65. ?>
  66. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  67. <html xmlns="http://www.w3.org/1999/xhtml">
  68. <head>
  69. <meta http-equiv="x-ua-compatible" content="ie=7" />
  70. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
  71. <title>用户管理面板 - <?=webname?></title>
  72. <? include("cssjs.html");?>
  73. <link href="css/sell.css" rel="stylesheet" type="text/css" />
  74. <style type="text/css">
  75. .userright .rproglo{margin-top:0;}
  76. </style>
  77. <script language="javascript">
  78. function tjfsonc(x){
  79. document.getElementById("tjfs1").style.display="none";
  80. document.getElementById("tjfs2").style.display="none";
  81. document.getElementById("tjfs3").style.display="none";
  82. document.getElementById("tjfs"+x).style.display="";
  83. }
  84. </script>
  85. </head>
  86. <body>
  87. <!--RB-->
  88. <div class="userright">
  89. <? include("protop.php");?>
  90. <!--白B-->
  91. <div class="rkuang">
  92. <? systs("恭喜您,操作成功!","kc.php?id=".$_GET[id]."&bh=".$bh."&action=".$_GET[action])?>
  93. <? if($_GET[action]==""){?>
  94. <script language="javascript">
  95. function tj(){
  96. layer.msg('正在提交', {icon: 16 ,time: 0,shade :0.25});
  97. tjwait();
  98. f1.action="kc.php?control=add&bh=<?=$bh?>";
  99. }
  100. </script>
  101. <form name="f1" method="post" onsubmit="return tj()" enctype="multipart/form-data">
  102. <input type="hidden" value="inf" name="jvs" />
  103. <ul class="uk">
  104. <li class="l1">添加方式:</li>
  105. <li class="l2">
  106. <label><input name="Rtjfs" type="radio" value="txt" onclick="tjfsonc(3)" checked="checked" /> 文本内容</label>
  107. <label><input name="Rtjfs" type="radio" value="one" onclick="tjfsonc(1)" /> 单一添加</label>
  108. <label><input name="Rtjfs" type="radio" value="more" onclick="tjfsonc(2)" /> 批量上传</label>
  109. </li>
  110. </ul>
  111. <ul class="uk uk0" id="tjfs3">
  112. <li class="l1">说明:</li>
  113. <li class="l21 red">导入格式为卡号+空格+密码(可跟上附加内容),一行一组,如AAAAA BBBBB</li>
  114. <li class="l9">卡密内容:</li>
  115. <li class="l10"><textarea name="s1"></textarea></li>
  116. </ul>
  117. <ul class="uk uk0" id="tjfs1" style="display:none;">
  118. <li class="l1">卡号:</li>
  119. <li class="l2"><input type="text" class="inp" size="80" name="tka" /></li>
  120. <li class="l1">密码:</li>
  121. <li class="l2"><input type="text" class="inp" size="80" name="tmi" /></li>
  122. </ul>
  123. <ul class="uk uk0" id="tjfs2" style="display:none;">
  124. <li class="l1">选择文件:</li>
  125. <li class="l2"><input type="file" name="inp1" id="inp1" size="25"></li>
  126. <li class="l5"></li>
  127. <li class="l6">
  128. 上传格式为xls文件,即excel,程序会自动识别,但必须保证符合规则,<strong class="red">第一列为卡号,第二列为密码</strong>,如下图<br>
  129. <img src="img/xls.gif" width="270" height="76" style="margin:10px 0 0 0;" />
  130. </li>
  131. </ul>
  132. <ul class="uk uk0">
  133. <li class="l3"><? tjbtnr("保存","kclist.php?bh=".$bh)?></li>
  134. </ul>
  135. </form>
  136. <?
  137. }else{
  138. while0("*","yjcode_kc where userid=".$userid." and id=".$_GET[id]);if(!$row=mysql_fetch_array($res)){php_toheader("kclist.php?bh=".$bh);}
  139. ?>
  140. <script language="javascript">
  141. function tj(){
  142. layer.msg('正在提交', {icon: 16 ,time: 0,shade :0.25});
  143. tjwait();
  144. f1.action="kc.php?control=update&bh=<?=$bh?>&id=<?=$_GET[id]?>";
  145. }
  146. </script>
  147. <form name="f1" method="post" onsubmit="return tj()">
  148. <input type="hidden" value="inf" name="jvs" />
  149. <ul class="uk">
  150. <li class="l1">卡号:</li>
  151. <li class="l2"><input type="text" class="inp" size="80" value="<?=$row[ka]?>" name="tka" /></li>
  152. <li class="l1">密码:</li>
  153. <li class="l2"><input type="text" class="inp" size="80" value="<?=$row[mi]?>" name="tmi" /></li>
  154. <li class="l1">使用情况:</li>
  155. <li class="l2">
  156. <label><input name="Rifok" type="radio" value="0"<? if(empty($row[ifok])){?> checked="checked"<? }?> /> 未使用</label>
  157. <label><input name="Rifok" type="radio" value="1"<? if(1==$row[ifok]){?> checked="checked"<? }?> /> 已使用</label>
  158. </li>
  159. <li class="l3"><? tjbtnr("保存","kclist.php?bh=".$bh)?></li>
  160. </ul>
  161. </form>
  162. <? }?>
  163. </div>
  164. <!--白E-->
  165. </div>
  166. <!--RE-->
  167. </body>
  168. </html>