ScanPushController.class.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: TianFeng
  5. * Date: 2019-03-18
  6. * Time: 15:38
  7. */
  8. namespace Home\Controller;
  9. use Think\Controller;
  10. include '../Common/function.php';
  11. class ScanPushController extends ComController {
  12. public function scan_push(){
  13. $ercode=I('post.data');
  14. $phone=$_SESSION['phone'];
  15. $log = "[时间".date("Y-m-d H:i:s")."]".$ercode."-----------".$phone."\r\n";
  16. $filename_log = "/var/www/html/jdxf/log/saoma".date("Y-m-d").".log";
  17. file_put_contents($filename_log, $log, FILE_APPEND|LOCK_EX);
  18. if(empty($phone)){
  19. echo 1;
  20. exit();
  21. }
  22. if(empty($ercode)){
  23. echo 1;
  24. exit();
  25. }
  26. // $data=array(
  27. // 'action'=>'wxercode',
  28. // 'phone'=>$phone,
  29. // 'ercode'=>$ercode,
  30. // );
  31. $data="{\"action\":\"wxercode\",\"phone\":\"".$phone."\",\"ercode\":\"".$ercode."\"}";
  32. $url='http://101.133.214.75:55125/report';
  33. // $url='http://39.98.37.17:8080/YtIoT/iot/admin/test';
  34. // $postData = http_build_query($data);
  35. // $curl = curl_init();
  36. // curl_setopt($curl, CURLOPT_URL, $url);
  37. // curl_setopt($curl, CURLOPT_USERAGENT,'Opera/9.80 (Windows NT 6.2; Win64; x64) Presto/2.12.388 Version/12.15');
  38. // curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); // stop verifying certificate
  39. // curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  40. // curl_setopt($curl, CURLOPT_POST, true);
  41. // curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
  42. // curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
  43. // curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
  44. // $result = curl_exec($curl);
  45. // curl_close($curl);
  46. $result = http_post_advertise($url,$data);
  47. $log = "[时间".date("Y-m-d H:i:s")."]".$result."\r\n";
  48. $filename_log = "/var/www/html/jdxf/log/ceshi".date("Y-m-d").".log";
  49. file_put_contents($filename_log, $log, FILE_APPEND|LOCK_EX);
  50. if ($result['action']=='wxercode'&&$result['result']=='1'){
  51. echo 2;
  52. }else{
  53. echo 1;
  54. }
  55. }
  56. // public function post_a(){
  57. //// $data=I();
  58. // $data = input('');
  59. //
  60. //// if (empty($data)){
  61. //// $data='空值';
  62. //// }
  63. // print_r("INSERT INTO a_ceshi ( data ) VALUES ( '".$data."' )");
  64. // addInt("INSERT INTO a_ceshi ( data ) VALUES ( '".$data."' )");
  65. // }
  66. }