public function respond() { global $_W; $rid = $this->rule; $sql = "SELECT * FROM " . tablename('weisrc_audio_reply') . " WHERE `rid`=:rid LIMIT 1"; $row = pdo_fetch($sql, array(':rid' => $rid)); if (empty($row['id'])) { return array(); } $title = pdo_fetchcolumn("SELECT name FROM " . tablename('rule') . " WHERE id = :rid LIMIT 1", array(':rid' => $rid)); $url = $_W['siteroot'] . createMobileUrl('index', array('rid' => $row['rid'], 'from_user' => base64_encode(authcode($this->message['from'], 'ENCODE')))); return $this->respNews(array('Title' => $title, 'Description' => $row['description'], 'PicUrl' => !strexists($row['picture'], 'http://') ? $_W['attachurl'] . $row['picture'] : $row['picture'], 'Url' => $url)); }
public function receive() { //这里定义此模块进行消息订阅时的, 消息到达以后的具体处理过程, 请查看微擎文档来编写你的代码 global $_W; $rid = $this->rule; $sql = "SELECT * FROM " . tablename('message_reply') . " WHERE `rid`=:rid LIMIT 1"; $row = pdo_fetch($sql, array(':rid' => $rid)); $response['FromUserName'] = $this->message['to']; $response['ToUserName'] = $this->message['from']; $response['MsgType'] = 'news'; $response['ArticleCount'] = 1; $response['Articles'] = array(); $response['Articles'][] = array('Title' => $row['title'], 'Description' => $row['description'], 'PicUrl' => empty($row['thumb']) ? '' : $_W['attachurl'] . $row['thumb'], 'Url' => createMobileUrl('stubind', array('name' => 'stubind', 'id' => $rid, 'weid' => $_W['weid'], 'from_user' => base64_encode(authcode($this->message['from'], 'ENCODE')))), 'TagName' => 'item'); return $response; }
public function doMobileAnnouncement() { global $_GPC, $_W; $member = $this->checkAuth(); $title = $this->getMobileTitle('announcement'); $op = empty($_GPC['op']) ? 'display' : $_GPC['op']; $op = in_array($op, array('display', 'detail')) ? $op : 'display'; if ($op == 'display') { $pindex = max(1, intval($_GPC['page'])); $psize = 50; $where = " WHERE `weid` = :weid AND `regionid`=:regionid AND `status`=:status AND `starttime`<=:starttime AND `endtime`>:endtime"; $paras = array(':weid' => $member['weid'], ':regionid' => $member['regionid'], ':starttime' => TIMESTAMP, ':endtime' => TIMESTAMP, ':status' => 1); $total = pdo_fetchcolumn("SELECT COUNT(*) FROM " . tablename('community_announcement') . $where, $paras); $list = pdo_fetchall("SELECT * FROM " . tablename('community_announcement') . "{$where} ORDER BY id DESC LIMIT " . ($pindex - 1) * $psize . ',' . $psize, $paras); $pager = pagination($total, $pindex, $psize); } else { if ($op == 'detail') { $id = intval($_GPC['id']); if (!empty($id)) { $item = pdo_fetch("SELECT * FROM " . tablename('community_announcement') . " WHERE `id`=:id AND `weid`=:weid AND `regionid`=:regionid", array(':id' => $id, ':weid' => $_W['weid'], ':regionid' => $member['regionid'])); } if (empty($item)) { message('未找到指定的公告.', createMobileUrl('announcement')); } } } include $this->template('announcement'); }