12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <?php
- /**
- *
- * 用户在微信里面授权回跳页
- */
- $param = array(
- 'code' =>trim( $_GET['code'] ),
- 'state'=>trim( $_GET['state'] ),
- );
- $referer = trim( $_GET['appreferer'] );
- $weixinObj = new weixinApp();
- $weixinObj->getWeixinParam( $param,$referer );
- class weixinApp {
-
- /**
- * 安全key
- * @var string
- */
- private $securityKey = 'W61E8753YZUDMG2Q0KVFH4NAOSPLIJ9CBXTR';
-
- private $login_cookie_name = 'TM_PASSPORT_MEMBER';
-
- private $host = 'http://passport.vogue.com.cn/';
-
- private $urlParm = "front/otherCallback?type=weixinapp&site=vogue";
-
- private $logName = "wechatVogueLog";
-
- public function __construct() {}
-
- /**
- * @desc 实例化日志类
- */
- public function logObj(){
-
- include(dirname(__FILE__) . '/log.php');
- $logObj = new Log();
- return $logObj;
- }
- /**
- * 获取微信code
- */
- public function getWeixinParam( $param,$referer ) {
-
- if( $param ){
- if( $param['state'] != $this->securityKey ){
- ErrorLog::addLog( "weixinapp签名不一致,ip:".$_SERVER['REMOTE_ADDR'].",state:".$param['state'], $this->logName );
- //$this->writeLog("weixinapp签名不一致,ip:".$_SERVER['REMOTE_ADDR'].",state:".$param['state'] );
- exit('1006'); //签名不一致
- }
- $url = $this->host.$this->urlParm.'&appreferer='.$referer.'&'. http_build_query( $param );
- $this->common_location( $url );
- }else{
- ErrorLog::addLog( "weixinapp没有参数,ip:".$_SERVER['REMOTE_ADDR'], $this->logName );
- //$this->writeLog("weixinapp没有参数,ip:".$_SERVER['REMOTE_ADDR'] );
- exit('1007'); //参数为空
- }
- }
-
- /**
- * @desc 在跳转到passport里面
- *
- */
- public function common_location( $url, $js = false )
- {
- if($js == true)
- {
- common_output('<script>location.href="'.$url.'"</script>');
- }
- else
- {
- header('Location: ' . $url);
- }
- exit;
- }
- /**
- * @desc 写入日志
- */
- public function writeLog( $log_message,$type='log' ){
- if( $log_message ){
- $logObj = $this->logObj();
- $logObj->write( $log_message,$type ); //写入日志
- }else{
- return true;
- }
- }
- }
|