Example #1
0
     }
     gourl('wx_account.php');
     exit;
     break;
 case "pushedit":
     $query = $_SGLOBAL['db']->query('select * from ' . tname('open_member_pushweixin') . ' where op_uid=' . $_SGLOBAL['uid']);
     if ($account = $_SGLOBAL['db']->fetch_array($query)) {
         $smarty->assign('account', $account);
     }
     $smarty->display('wx_account_pushedit.dwt');
     break;
 case "pusheditprofile":
     $username = getstr($_POST['username']);
     $password = getstr($_POST['password']);
     include_once S_ROOT . './source/class_weixin.php';
     $ro = new WX_Remote_Opera();
     $token = $ro->test_login($username, $password);
     if ($token != '') {
         $beenadd = getcount(tname('open_member_weixin'), array('username' => $username, 'state' => 1));
         if ($beenadd > 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'];
Example #2
0
 protected function send_reply($msg)
 {
     global $_SGLOBAL;
     $create_time = $this->timestamp;
     $wxid = $this->fromUsername;
     list($question_id, $content) = explode('#', $msg, 2);
     $uid = $_SGLOBAL['db']->getone('select uid from ' . tname('open_member_user') . ' where op_uid=' . $this->op_uid . ' and weixin_state=1 and weixin_wxid="' . $wxid . '"');
     if ($uid > 0) {
         $query = $_SGLOBAL['db']->query("select * from " . tname('open_member_user') . " where op_uid=" . $this->op_uid . " and uid=" . $uid);
         $member = $_SGLOBAL['db']->fetch_array($query);
         $member['province'] = $_SGLOBAL['db']->getone("SELECT region_name FROM " . tname('region') . " WHERE region_id = " . $member['province']);
         $asker_uid = $_SGLOBAL['db']->getone('select uid from ' . tname('weixin_question') . ' where id=' . $question_id);
         $op_wxid = $_SGLOBAL['db']->getone('select op_wxid from ' . tname('weixin_member') . ' where uid=' . $asker_uid);
         $query = $_SGLOBAL['db']->query("select * from " . tname('open_member_weixin') . " where id='" . $op_wxid . "' and op_uid='" . $this->op_uid . "'");
         if ($op_wx = $_SGLOBAL['db']->fetch_array($query)) {
             $fakeid = $_SGLOBAL['db']->getone('select fakeid from ' . tname('weixin_member') . ' where uid=' . $asker_uid);
             if ($fakeid) {
                 $replyed = $_SGLOBAL['db']->getone('select replyed from ' . tname('weixin_question') . ' where id=' . $question_id);
                 if ($replyed == 0) {
                     $reply_id = inserttable(tname('weixin_reply'), array('uid' => $uid, 'question_id' => $question_id, 'content' => $content, 'addtime' => $create_time), 1);
                     updatetable(tname('weixin_question'), array('replyed' => 1), array('id' => $question_id));
                     $ro = new WX_Remote_Opera();
                     $token = $ro->init($op_wx['username'], $op_wx['password']);
                     $replymsg = $this->reply_tpl($member, $reply_id, $content);
                     $ro->sendmsg($replymsg, $fakeid, $token);
                     return 1;
                 } else {
                     return 2;
                 }
             } else {
                 return -3;
             }
         } else {
             return -2;
         }
     } else {
         return -1;
     }
 }
Example #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;
     $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['fakeid'] = $v['fakeid'];
                     $member['province'] = $contactinfo['province'];
                     $member['nickname'] = $contactinfo['nick_name'];
                     break;
                 }
             }
         }
         //保存头像
         $ro->getheadimg($member['fakeid']);
         return $member;
     } else {
         return false;
     }
 }
Example #4
0
 protected function send_to_member($msg, $question_id = '', $province = '', $nickname = '', $to_uid = 0, $op_wx = array())
 {
     global $_SGLOBAL, $wx;
     $return = false;
     $op_wxid = $wx->weixin['op_wxid'];
     $op_uid = $wx->weixin['op_uid'];
     $count = 0;
     $newmsg = $this->question_tpl($msg, $question_id, $province, $nickname);
     $query = $_SGLOBAL['db']->query("select * from " . tname('open_member_weixin') . " where id='" . $op_wxid . "'");
     $op_wx = $_SGLOBAL['db']->fetch_array($query);
     $ro = new WX_Remote_Opera();
     $ro->init($op_wx['username'], $op_wx['password']);
     $memberlist = $_SGLOBAL['db']->getall('select * from ' . tname('open_member_user') . ' where weixin_state=1 and op_uid="' . $op_uid . '"');
     foreach ($memberlist as $k => $v) {
         $ro->sendmsg($newmsg, $v['weixin_fakeid']);
         $count++;
     }
     $return = $count;
     return $return;
 }
Example #5
0
             $data['button'][$k]['sub_button'][$key]['name'] = urlencode($value['btn_name']);
             if ($value['btn_type'] == 1) {
                 $data['button'][$k]['sub_button'][$key]['type'] = 'click';
                 $data['button'][$k]['sub_button'][$key]['key'] = urlencode($value['keyword']);
             }
             if ($value['btn_type'] == 2) {
                 $data['button'][$k]['sub_button'][$key]['type'] = 'view';
                 $data['button'][$k]['sub_button'][$key]['url'] = urlencode($value['url']);
             }
         }
     }
     //print_r(urldecode(json_encode($data)));
     $appid = $_SGLOBAL['db']->getone('select appid from ' . tname('open_member_weixin') . ' where id=' . $id);
     $appsecret = $_SGLOBAL['db']->getone('select appsecret from ' . tname('open_member_weixin') . ' where id=' . $id);
     include_once S_ROOT . './source/class_weixin.php';
     $ro = new WX_Remote_Opera();
     $return = $ro->create_menu($appid, $appsecret, urldecode(json_encode($data)));
     echo json_encode($return);
     //print_r($return);
     break;
 default:
     $id = intval($_GET['id']) ? intval($_GET['id']) : 0;
     check_role($id);
     $smarty->assign('id', $id);
     $total = getcount(tname('open_member_weixin_custommenu'), array('wxid' => $id));
     $smarty->assign('total', $total);
     $list = $_SGLOBAL['db']->getall('select * from ' . tname('open_member_weixin_custommenu') . ' where parent_id=0 and wxid=' . $id . ' order by sort_order');
     foreach ($list as $k => $v) {
         if ($v['btn_type'] == 1) {
             $list[$k]['btn_type_show'] = '关键词';
         }