membercomfun.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. //--------------- 会员相关处理函数 ---------------
  3. //点卡冲值
  4. function CardGetFen($username,$reusername,$card_no,$password){
  5. global $empire,$dbtbpre;
  6. $card_no=RepPostVar($card_no);
  7. $password=RepPostVar($password);
  8. $username=RepPostVar($username);
  9. if(!trim($username)||!trim($card_no)||!trim($password))
  10. {
  11. printerror("EmptyGetCard","history.go(-1)",1);
  12. }
  13. if($username!=$reusername)
  14. {
  15. printerror("DifCardUsername","history.go(-1)",1);
  16. }
  17. $user=$empire->fetch1("select ".eReturnSelectMemberF('userid,userdate,username,groupid')." from ".eReturnMemberTable()." where ".egetmf('username')."='$username' limit 1");
  18. if(!$user['userid'])
  19. {
  20. printerror("ExiestCardUsername","history.go(-1)",1);
  21. }
  22. $num=$empire->gettotal("select count(*) as total from {$dbtbpre}enewscard where card_no='".$card_no."' and password='".$password."' limit 1");
  23. if(!$num)
  24. {
  25. printerror("CardPassError","history.go(-1)",1);
  26. }
  27. //是否过期
  28. $buytime=date("Y-m-d H:i:s");
  29. $r=$empire->fetch1("select cardfen,money,endtime,carddate,cdgroupid,cdzgroupid from {$dbtbpre}enewscard where card_no='$card_no' limit 1");
  30. if($r[endtime]<>"0000-00-00")
  31. {
  32. $endtime=to_date($r[endtime]);
  33. if($endtime<time())
  34. {
  35. printerror("CardOutDate","history.go(-1)",1);
  36. }
  37. }
  38. //充值
  39. eAddFenToUser($r[cardfen],$r[carddate],$r[cdgroupid],$r[cdzgroupid],$user);
  40. $sql1=$empire->query("delete from {$dbtbpre}enewscard where card_no='$card_no'");//删除卡号
  41. //备份购买记录
  42. BakBuy($user['userid'],$username,$card_no,$r[cardfen],$r[money],$r[carddate],0);
  43. printerror("CardGetFenSuccess","../member/card/",1);
  44. }
  45. ?>