Exemple #1
0
             showmessage('此公众号已被绑定,不能作为推送号');
             gourl('wx_account.php?ac=pushedit');
             exit;
         }
         $ro->init($username, $password);
         $info = $ro->get_account_info();
         $setarr = array('ghid' => $info['ghid'], 'weixin_name' => $info['nickname'], 'username' => getstr($_POST['username']), 'password' => getstr($_POST['password']), 'signature' => $info['signature'], 'country' => $info['country'], 'province' => $info['province'], 'city' => $info['city'], 'verifyInfo' => $info['verifyInfo'], 'bindUserName' => $info['bindUserName'], 'account' => $info['account'], 'fakeid' => $info['fakeid'], 'state' => 1);
         if ($_SGLOBAL['db']->getone('select id from ' . tname('open_member_pushweixin') . ' where op_uid=' . $_SGLOBAL['uid'])) {
             updatetable(tname('open_member_pushweixin'), $setarr, array('op_uid' => $_SGLOBAL['uid']));
         } else {
             $setarr['op_uid'] = $_SGLOBAL['uid'];
             $Setarr['addtime'] = $_SGLOBAL['timestamp'];
             inserttable(tname('open_member_pushweixin'), $setarr);
         }
         updatetable(tname('open_member_user'), array('weixin_state' => 0), array('op_uid' => $_SGLOBAL['uid']));
         $ro->getheadimg($info['fakeid']);
         $ro->getqrcode($info['fakeid']);
         $ro->quick_set_api($_SC['push_api_token'], $_SC['push_api_url']);
     } else {
         showmessage('微信用户名或密码错误,或者此微信已被设置');
         gourl('wx_account.php?ac=pushedit');
         exit;
     }
     gourl('wx_account.php?ac=pushedit');
     exit;
     break;
 case "manage":
     $op_uid = $_SGLOBAL['uid'];
     $id = intval($_GET['id']) ? intval($_GET['id']) : 0;
     check_role($id);
     $query = $_SGLOBAL['db']->query('select * from ' . tname('open_member_weixin') . ' where op_uid=' . $_SGLOBAL['uid'] . ' and id=' . $id . ' and state>-1');
Exemple #2
0
 protected function save_weixin_member()
 {
     global $_SGLOBAL;
     $create_time = $this->timestamp;
     $wxid = $this->fromUsername;
     $op_wxid = $this->op_wxid;
     if ($wxid == '') {
         return false;
     }
     $return = false;
     $member['uid'] = $_SGLOBAL['db']->getone('select uid from ' . tname('weixin_member') . ' where op_wxid=' . $op_wxid . ' and wxid="' . $wxid . '"');
     $ro = new WX_Remote_Opera();
     $query = $_SGLOBAL['db']->query("select * from " . tname('open_member_weixin') . " where id=" . $op_wxid);
     if ($op_wx = $_SGLOBAL['db']->fetch_array($query)) {
         $token = $ro->init($op_wx['username'], $op_wx['password']);
         if ($member['uid'] > 0) {
             $member['province'] = $_SGLOBAL['db']->getone('select province from ' . tname('weixin_member') . ' where uid=' . $member['uid']);
             $member['nickname'] = $_SGLOBAL['db']->getone('select nickname from ' . tname('weixin_member') . ' where uid=' . $member['uid']);
         } else {
             $msglist = $ro->getmsglist();
             foreach ($msglist as $k => $v) {
                 if ($v['date_time'] == $create_time) {
                     $contactinfo = $ro->getcontactinfo($v['fakeid']);
                     $member['uid'] = inserttable(tname('weixin_member'), array('op_wxid' => $op_wxid, 'wxid' => $wxid, 'fakeid' => $v['fakeid'], 'nickname' => $contactinfo['nick_name'], 'username' => $contactinfo['user_name'], 'country' => $contactinfo['country'], 'province' => $contactinfo['province'], 'city' => $contactinfo['city'], 'sex' => $contactinfo['gender'], 'create_time' => $create_time), 1);
                     $member['province'] = $contactinfo['province'];
                     $member['nickname'] = $contactinfo['nick_name'];
                     break;
                 }
             }
         }
         //保存头像
         $member['fakeid'] = $_SGLOBAL['db']->getone('select fakeid from ' . tname('weixin_member') . ' where uid=' . $member['uid']);
         $ro->getheadimg($member['fakeid']);
         return $member;
     } else {
         return false;
     }
 }