Ejemplo n.º 1
0
 protected function kefu_reg($msg)
 {
     global $_SGLOBAL, $wx, $_SC;
     $op_wxid = $wx->weixin['op_wxid'];
     $op_uid = $wx->weixin['op_uid'];
     $create_time = $wx->message['time'];
     $wxid = $wx->message['from'];
     list($mobile, $weixin_code) = explode('@', $msg, 2);
     $mobile = getstr($mobile);
     $weixin_code = getstr($weixin_code);
     $kefu = $_SGLOBAL['db']->fetch_array($_SGLOBAL['db']->query('select * from ' . tname('open_member_user') . ' where op_uid="' . $op_uid . '" and state=1 and mobile="' . $mobile . '" and weixin_code="' . $weixin_code . '"'));
     if (!$kefu) {
         $uid = 0;
     } elseif ($kefu['weixin_state'] == 1) {
         $uid = -1;
     } else {
         $uid = $kefu['uid'];
     }
     if ($uid > 0) {
         $query = $_SGLOBAL['db']->query('select uid,fakeid,province,nickname from ' . tname('weixin_member') . ' where op_wxid=' . $op_wxid . ' and wxid="' . $wxid . '"');
         $member = $_SGLOBAL['db']->fetch_array($query);
         if (!$member) {
             $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)) {
                 $ro->init($op_wx['username'], $op_wx['password']);
             }
             $msglist = $ro->getmsglist();
             foreach ($msglist as $k => $v) {
                 if ($v['date_time'] == $create_time) {
                     updatetable(tname('open_member_user'), array('weixin_state' => 1, 'weixin_fakeid' => $v['fakeid']), array('uid' => $uid, 'op_uid' => $op_uid));
                     break;
                 }
             }
         } else {
             updatetable(tname('open_member_user'), array('weixin_state' => 1, 'weixin_fakeid' => $member['fakeid']), array('uid' => $uid, 'op_uid' => $op_uid));
         }
     }
     return $uid;
 }
Ejemplo n.º 2
0
 protected function ck_wx($msg)
 {
     global $_SGLOBAL;
     $create_time = $this->timestamp;
     $wxid = $this->fromUsername;
     list($mobile, $weixin_code) = explode('@', $msg, 2);
     $mobile = getstr($mobile);
     $weixin_code = getstr($weixin_code);
     $uid = $_SGLOBAL['db']->getone('select uid from ' . tname('open_member_user') . ' where op_uid=' . $this->op_uid . ' and state=1 and weixin_state=0 and mobile="' . $mobile . '" and weixin_code="' . $weixin_code . '"');
     if (!$uid) {
         $uid = 0;
     }
     if ($uid > 0) {
         $ro = new WX_Remote_Opera();
         $query = $_SGLOBAL['db']->query("select * from " . tname('open_member_pushweixin') . " where id=" . $this->op_wxid);
         if ($op_wx = $_SGLOBAL['db']->fetch_array($query)) {
             $ro->init($op_wx['username'], $op_wx['password']);
         }
         $msglist = $ro->getmsglist();
         foreach ($msglist as $k => $v) {
             if ($v['date_time'] == $create_time) {
                 updatetable(tname('open_member_user'), array('weixin_state' => 1, 'weixin_wxid' => $wxid, 'weixin_fakeid' => $v['fakeid']), array('uid' => $uid, 'op_uid' => $this->op_uid));
                 break;
             }
         }
     }
     return $uid;
 }
Ejemplo n.º 3
0
 protected function save_weixin_member()
 {
     global $_SGLOBAL, $wx;
     $create_time = $wx->message['time'];
     $wxid = $wx->message['from'];
     $op_wxid = $wx->weixin['op_wxid'];
     if ($wxid == '') {
         return false;
     }
     $return = false;
     $query = $_SGLOBAL['db']->query('select uid,fakeid,province,nickname from ' . tname('weixin_member') . ' where op_wxid=' . $op_wxid . ' and wxid="' . $wxid . '"');
     $member = $_SGLOBAL['db']->fetch_array($query);
     $query = $_SGLOBAL['db']->query("select * from " . tname('open_member_weixin') . " where id='" . $op_wxid . "'");
     if ($op_wx = $_SGLOBAL['db']->fetch_array($query)) {
         $ro = new WX_Remote_Opera();
         $token = $ro->init($op_wx['username'], $op_wx['password']);
         if (!$member) {
             $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['fakeid'] = $v['fakeid'];
                     $member['province'] = $contactinfo['province'];
                     $member['nickname'] = $contactinfo['nick_name'];
                     //保存头像
                     $ro->getheadimg($member['fakeid']);
                     break;
                 }
             }
         }
         return $member;
     } else {
         return false;
     }
 }