public function index($enc_str) { $app_define = utils::decrypt($enc_str); $action_url = urldecode($action_url); $obj_wstage = vmc::singleton('wechat_stage'); $access_token = $obj_wstage->get_access_token(false, $app_define); $app_id = $app_define['app_id']; vmc::singleton('base_session')->start(); $session_str = utils::encrypt(array('session_id' => vmc::singleton('base_session')->sess_id() . '|' . time())); $session_str = app::get('mobile')->router()->encode_args($session_str); $redirect_uri = vmc::openapi_url('openapi.toauth', 'callback', array('wechat_toauth_pam' => 'callback')) . '?qrlp=' . $session_str; $forward = $_GET['forward']; $state = app::get('mobile')->router()->gen_url(array('app' => 'wechat', 'ctl' => 'mobile_wxqrlogin', 'act' => 'dologin')); $long_url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={$app_id}&redirect_uri={$redirect_uri}&response_type=code&scope=snsapi_userinfo&state={$state}#wechat_redirect"; if (!$access_token) { $this->splash('error', '', '二维码生成失败'); } if ($surl = $obj_wstage->gen_surl($long_url, $access_token, $msg)) { $this->pagedata['surl'] = $surl; } else { $this->splash('error', '', '二维码生成失败:' . $msg); } // if($this->_reqeust->is_ajax()){ // $qrcode = vmc::singleton('wechat_qrcode')->create($surl); // $qrcode_url = base_storager::inmage_path($qrcode['image_id']); // $this->splash('success','',array('qrcode_url'=>$qrcode_url)); // } $this->pagedata['forward'] = $forward; $this->page('site/loginqrcode.html'); }
public function preview($theme, $theme_root_dir_cookie) { $theme_preview_cookie = utils::encrypt($theme); setcookie('CURRENT_THEME_M', $theme_preview_cookie); $_COOKIE['CURRENT_THEME_M'] = $theme_preview_cookie; if ($theme_root_dir) { $theme_root_dir_cookie = utils::encrypt($theme_root_dir); setcookie('THEME_M_DIR', $theme_root_dir_cookie); $_COOKIE['THEME_M_DIR'] = $theme_root_dir_cookie; } $this->redirect(array('app' => 'mobile', 'ctl' => 'index')); }
public function authorize_url() { $app_id = $this->getConf('app_id', __CLASS__); $app_secret = $this->getConf('app_secret', __CLASS__); $redirect_uri = $this->callback_url; //state=STATE 在前台会被跟踪替换成state=$forward; $url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={$app_id}&redirect_uri={$redirect_uri}&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect"; //微信里 if (base_mobiledetect::is_wechat()) { return $url; } //手机中,微信外 if (base_mobiledetect::is_mobile()) { return false; } //适合扫码登录 return app::get('site')->router()->gen_url(array('app' => 'wechat', 'ctl' => 'site_wxqrlogin', 'act' => 'index', 'args' => array(utils::encrypt(array('app_id' => $app_id, 'app_secret' => $app_secret))))); }