/** * check whether the current post is a valid post * @return boolean */ public static function is_token_post() { $token = self::post('token', ''); return empty($token) || $token != sess_token() ? FALSE : TRUE; }
/** * 显示在html head 里的全局js */ function headscript() { global $user; // Global data $wxVer = Weixin::browserVer(); $wxVer = $wxVer ? "'" . $wxVer . "'" : 0; $isWxBro = $wxVer ? 'true' : 'false'; $wxConf = C('api.weixin_fxmgou'); $wxAppId = $wxConf['appId']; $appName = L('appname'); $currUri = Request::uri(); $ctxpath = C('env.contextpath'); $sesstoken = sess_token(); $script = '<script type="text/javascript">'; $script .= "var wxData={isWxBrowser:{$isWxBro},browserVer:{$wxVer},isReady:false,appId:'{$wxAppId}'},gData={appName:'{$appName}',currURI:'{$currUri}',referURI:'',contextpath:'{$ctxpath}',token:'{$sesstoken}'},gUser={};"; foreach ((array) $user as $k => $v) { if (in_array($k, ['uid', 'openid', 'unionid', 'subscribe', 'username', 'nickname', 'sex', 'logo', 'ec_user_id'])) { $v = is_numeric($v) && $k != 'username' ? $v : "'" . $v . "'"; $script .= 'gUser.' . $k . "={$v};"; } } $script .= '</script>'; // Share info js echo $script; }