wxcode.ctrl.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /**
  3. * [WeEngine System] Copyright (c) 2014 WE7.CC
  4. * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
  5. */
  6. defined('IN_IA') or exit('Access Denied');
  7. load()->library('qrcode');
  8. load()->func('communication');
  9. $dos = array('verifycode', 'image', 'qrcode');
  10. $do = in_array($do, $dos) ? $do : 'verifycode';
  11. $_W['uniacid'] = intval($_GPC['uniacid']);
  12. if($do == 'verifycode') {
  13. $username = trim($_GPC['username']);
  14. $response = ihttp_get("https://mp.weixin.qq.com/cgi-bin/verifycode?username={$username}&r=" . TIMESTAMP);
  15. if(!is_error($response)) {
  16. isetcookie('code_cookie', $response['headers']['Set-Cookie']);
  17. header('Content-type: image/jpg');
  18. echo $response['content'];
  19. exit();
  20. }
  21. } elseif($do == 'image') {
  22. $image = trim($_GPC['attach']);
  23. if(empty($image)) exit();
  24. if (!starts_with($image, array('http://mmbiz.qpic.cn/mmbiz_', 'https://mmbiz.qpic.cn/mmbiz_'))) {
  25. exit();
  26. }
  27. $content = ihttp_request($image, '', array('CURLOPT_REFERER' => 'http://www.qq.com'));
  28. header('Content-Type:image/jpg');
  29. echo $content['content'];
  30. exit();
  31. } elseif ($do == 'qrcode') {
  32. $errorCorrectionLevel = "L";
  33. $matrixPointSize = "8";
  34. $text = trim($_GPC['text']);
  35. QRcode::png($text, false, $errorCorrectionLevel, $matrixPointSize);
  36. exit();
  37. }