wxlogin.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. //换成自己的接口信息
  3. //$appid = 'wxe30d2c612847beeb';
  4. //print_r($_sys[siteurl].HOME_PAGE."?c=home&ruid=");
  5. //header('location:https://open.weixin.qq.com/connect/oauth2/authorize?appid='.$appid.'&redirect_uri=http://qmyx.lyfz.net/wzyx/oauth.php&response_type=code&scope=snsapi_userinfo&state=123&connect_redirect=1#wechat_redirect');
  6. class wxlogin_c extends Control
  7. {
  8. function __construct()
  9. {
  10. parent::Control();
  11. }
  12. function wxlogin_c()
  13. {
  14. $this->__construct();
  15. }
  16. function index_f()
  17. {
  18. $appid = '';
  19. if($this->sys_config[Appid]&&strlen($this->sys_config[Appid])>1){
  20. $appid=$this->sys_config[Appid];
  21. }else if($this->STCModel->Appid)
  22. {
  23. $appid=$this->STCModel->Appid;
  24. }
  25. $_SESSION["appid"]=$appid;
  26. $serverPort=$_SERVER["SERVER_PORT"];
  27. $retUrl="http://".$_SERVER['SERVER_NAME'];
  28. /*if($serverPort==80){
  29. $retUrl.=$_SERVER["REQUEST_URI"];
  30. }else{
  31. $retUrl.=':'.$serverPort.$_SERVER["REQUEST_URI"];
  32. }*/
  33. $retUrl.=$_SERVER["REQUEST_URI"];
  34. $retUrl=str_replace('wxlogin',"oauth",$retUrl);
  35. //$retUrl=str_replace('index.php?c=wxlogin',"oauth.php",$retUrl);
  36. $retUrl='location:https://open.weixin.qq.com/connect/oauth2/authorize?appid='.$appid.'&redirect_uri='.$retUrl.'&response_type=code&scope=snsapi_userinfo&state=123&connect_redirect=1#wechat_redirect';
  37. //print_r($retUrl);
  38. header($retUrl);
  39. //header('location:https://open.weixin.qq.com/connect/oauth2/authorize?appid='.$appid.'&redirect_uri='.$retUrl.'&response_type=code&scope=snsapi_userinfo&state=123&connect_redirect=1#wechat_redirect');
  40. //print_r($retUrl);
  41. //print_r($_SERVER["HTTP_REFERER"].$this->tpl->_sys[siteurl].HOME_PAGE."?c=home&ruid=11");
  42. }
  43. }
  44. ?>