private static function init_user_info()
 {
     $userinit = WxuserApi::get_infos_openid(self::$weixin_post['fromusername']);
     if (empty($userinit['id'])) {
         //注册用户
         if (empty(self::$weixin_post['fromusername'])) {
             wx_error('Sorry!用户标识为空');
         } else {
             $regStatus = WxuserApi::register_weixin(true, self::$weixin_post['fromusername']);
             if (false === $regStatus[0]) {
                 wx_error($regStatus[1]);
             } else {
                 $userinit = $regStatus[1];
             }
             //新关注用户
             Credits::ag_weixin_newregister($userinit['id']);
         }
     }
     //判断用户公众号归属
     if (empty($userinit['tousername'])) {
         WxuserApi::update_info_openid($userinit['fromusername'], array('account_union' => self::$weixin_post['tousername']));
     }
     //用户调试状态
     if (in_array($userinit['followercate_title'], self::$admin_group)) {
         defined('WEIXIN_TRACE', TRUE);
     }
     //用户关注状态
     if (empty($userinit['follow'])) {
         WxuserApi::update_follow($userinit['fromusername']);
     }
     //注册用户昵称
     if (preg_match("/^我叫/", self::$weixin_post['content'])) {
         $nickname = str_replace('我叫', '', str_replace(" ", '', self::$weixin_post['content']));
         //set_nickname(self::$weixin_post['fromusername'],$nickname );
         $setStatus = WxuserApi::set_nickname(array(self::$weixin_post['fromusername'] => $nickname));
         if ($setStatus) {
             wx_success($nickname . '小主,更新昵称成功!');
         } else {
             wx_error('更新昵称失败!');
         }
     }
     //强制绑定昵称
     if (empty($userinit['nickname'])) {
         wx_success('发送“我叫”+您的昵称,交朋友更方便哦~');
     }
     if ($userinit['status'] == 0) {
         wx_error('Sorry!您的账号已被冻结,请联系管理员......');
     }
     if ($userinit['followercate_status'] == 0) {
         wx_error('Sorry!您所在的用户组【' . $userinit['followercate_title'] . '】已被冻结,请联系管理员......');
     }
     /*用户资料初始化*/
     global $_P;
     $_P = $userinit;
     //用户自动升级
     Credits::init($userinit['id']);
 }
Esempio n. 2
0
 /**
  * 关键词点击量自增
  * @return true 
  */
 private function amangolog()
 {
     global $_K;
     global $_P;
     $map['id'] = $_K['id'];
     D('KeywordView')->where($map)->setInc('keyword_click');
     //用户自动升级
     Credits::init($_P['id']);
     return true;
 }