Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 

47 righe
1.7 KiB

  1. <?php
  2. require_once '../Common/Config.php';
  3. require_once '../Common/Function.php';
  4. $pdo = new PDO("sqlsrv:Server=".HOST.";Database=".DB, USER, PASSWORD);//5.6版本pdo连接sqlsrv
  5. if ($_POST){
  6. $method=htmlspecialchars($_POST['method']);
  7. if ($method =='shareTimeLine'){
  8. $sharTimeLine=htmlspecialchars($_POST['shareTimeLine']);
  9. if ($sharTimeLine ==0){
  10. $updateId=htmlspecialchars($_POST['updateId']);
  11. $openId=htmlspecialchars($_POST['openId']);
  12. $sql="SELECT sharTimeLine FROM lottery_user WHERE openId='".$openId."'";
  13. $result=$pdo->query($sql);
  14. $rowset = $result->fetchAll(PDO::FETCH_ASSOC);
  15. $sharTime=$rowset[0]['sharTimeLine'];
  16. if ($sharTime !=0){
  17. exit;
  18. }
  19. write_log("method:shareTimeLine有调用");
  20. $addCode="SELECT TOP 1 id,lotteryCode FROM lottery_code";
  21. $addResult=$pdo->query($addCode);
  22. $addRowset = $addResult->fetchAll(PDO::FETCH_ASSOC);
  23. $addErrinfo=$pdo->errorInfo();
  24. if ($addErrinfo[0] =="00000"){
  25. $addLotteryCode=$addRowset[0]['lotteryCode'];
  26. $addId=$addRowset[0]['id'];
  27. //$id=2;
  28. $updateSql="UPDATE lottery_user SET sharTimeLine=1 WHERE id=".$updateId;
  29. write_log($updateSql);
  30. $updateResult=$pdo->exec($updateSql);
  31. $insertSql="INSERT INTO lottery_friends(openId,lotteryCode,createtime) VALUES('".$openId."',".$addLotteryCode.",'".date("Y-m-d H:i:s",time())."')";
  32. $insertResult=$pdo->exec($insertSql);
  33. $delSql="DELETE FROM lottery_code WHERE id=".$addId;
  34. $delResult=$pdo->exec($delSql);
  35. $result= json_encode(array("errorcode"=>0,"errorcode"=>"分享朋友圈成功"));
  36. }
  37. }else{
  38. $result= json_encode(array("errorcode"=>0,"errorcode"=>"多次分享朋友圈只能获得一个抽奖码"));
  39. }
  40. }
  41. echo $result;
  42. }
  43. ?>