model('mc'); load()->model('account'); if(!empty($_W['member']) && (!empty($_W['member']['mobile']) || !empty($_W['member']['email']))) { return true; } if(!empty($_W['openid'])) { $fan = mc_fansinfo($_W['openid'], $_W['acid'], $_W['uniacid']); if (empty($fan) && $_W['account']['level'] == ACCOUNT_SERVICE_VERIFY) { $fan = mc_oauth_userinfo(); if (!empty($fan['openid'])) { $fan = mc_fansinfo($fan['openid']); } } if (empty($fan['uid'])) { $setting = uni_setting($_W['uniacid'], array('passport')); if (!isset($setting['passport']) || empty($setting['passport']['focusreg'])) { $reg_members = mc_init_fans_info($_W['openid'], true); $fan['uid'] = $reg_members['uid']; } } if(_mc_login(array('uid' => intval($fan['uid'])))) { return true; } if (defined('IN_API')) { $GLOBALS['engine']->died("抱歉,您需要先登录才能使用此功能,点击此处 【登录】"); } } $forward = base64_encode($_SERVER['QUERY_STRING']); if($_W['isajax']) { $result = array(); $result['url'] = url('auth/login', array('forward' => $forward), true); $result['act'] = 'redirect'; exit(json_encode($result)); } else { header("location: " . url('auth/login', array('forward' => $forward)), true); } exit; } function __buildSiteUrl($url) { global $_W, $engine; $mapping = array( '[from]' => $engine->message['from'], '[to]' => $engine->message['to'], '[uniacid]' => $_W['uniacid'], ); $url = str_replace(array_keys($mapping), array_values($mapping), $url); $pass = array(); $pass['openid'] = $engine->message['from']; $pass['acid'] = $_W['acid']; $sql = 'SELECT `fanid`,`salt`,`uid` FROM ' . tablename('mc_mapping_fans') . ' WHERE `acid`=:acid AND `openid`=:openid'; $params = array(); $params[':acid'] = $_W['acid']; $params[':openid'] = $pass['openid']; $fan = pdo_fetch($sql, $params); if(empty($fan) || !is_array($fan) || empty($fan['salt'])) { $fan = array('salt' => ''); } $pass['time'] = TIMESTAMP; $pass['hash'] = md5("{$pass['openid']}{$pass['time']}{$fan['salt']}{$_W['config']['setting']['authkey']}"); $auth = base64_encode(json_encode($pass)); $vars = array(); $vars['uniacid'] = $_W['uniacid']; $vars['__auth'] = $auth; $vars['forward'] = base64_encode($url); return $_W['siteroot'] . 'app/' . url('auth/forward', $vars); } function register_jssdk($debug = false){ global $_W; if (defined('HEADER')) { echo ''; return; } $sysinfo = array( 'uniacid' => $_W['uniacid'], 'acid' => $_W['acid'], 'siteroot' => $_W['siteroot'], 'siteurl' => $_W['siteurl'], 'attachurl' => $_W['attachurl'], 'cookie' => array('pre'=>$_W['config']['cookie']['pre']) ); if (!empty($_W['acid'])) { $sysinfo['acid'] = $_W['acid']; } if (!empty($_W['openid'])) { $sysinfo['openid'] = $_W['openid']; } if (defined('MODULE_URL')) { $sysinfo['MODULE_URL'] = MODULE_URL; } $sysinfo = json_encode($sysinfo); $jssdkconfig = json_encode($_W['account']['jssdkconfig']); $debug = $debug ? 'true' : 'false'; $script = << EOF; echo $script; } function tourl($url) { $reg = '/^tel:(\d+)$/'; if (preg_match($reg, $url)) { return $url; } return $url . '&wxref=mp.weixin.qq.com#wechat_redirect'; }