コード例 #1
0
ファイル: class_weixin.php プロジェクト: hugolong/weixiao
 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;
     }
 }
コード例 #2
0
ファイル: processor.php プロジェクト: hugolong/weixiao
 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;
 }