public function processMsg() { $postStr = $GLOBALS["HTTP_RAW_POST_DATA"]; if (!empty($postStr)) { $requestMsg = WxProcess::getRequestMsg($postStr); //订阅消息(subscribe),返回一条文本消息 if ($requestMsg->MsgType == MsgType::$Event && $requestMsg->EventKey == MsgType::$SUBSCRIBE) { $msgText = new MsgText(); $sql = ' select b.inputCode, t.content from t_wxcms_msg_base b,t_wxcms_msg_text t where t.base_id = b.id and b.inputCode = "' . MsgType::$SUBSCRIBE . '"'; $querySet = $msgText->queryBySql($sql); $msgContent = "欢迎订阅,请回复 1 "; //默认 if (!empty($querySet)) { $msgContent = $querySet[0]['content']; } echo WxProcess::responseText($requestMsg, $contentMsg); } else { $keyword = null; if (!empty($requestMsg->Content)) { //返回图文消息 $keyword = $requestMsg->Content; } $sql = 'select t.* from t_wxcms_msg_base b,t_wxcms_msg_news t where t.base_id = b.id '; if (!empty($keyword)) { $sql .= " and b.inputCode like '%{$keyword}%' "; } $msgNews = new MsgNews(); $querySet = $msgNews->queryBySql($sql); $newsArr = array(); if (!empty($querySet)) { $wxAccount = new Account(); $wxAccount = $wxAccount->getSingleAccount(); $msgCount = $wxAccount['msgCount']; //消息条数 if ($msgCount > count($querySet)) { $msgCount = count($querySet); } for ($i = 0; $i < $msgCount; $i++) { $item = $querySet[$i]; $news = array("Title" => $item['title'], "Description" => $item['brief'], "PicUrl" => $item['picPath'], "Url" => $item['url']); array_push($newsArr, $news); } } echo WxProcess::responseNews($requestMsg, $newsArr); } } else { echo ""; exit; } }
var inputCode = $('#id_inputCode').val(); inputCode = inputCode.replace(/(\s*$)/g, ''); if(inputCode == ''){ alert('请填写关键字'); return false; }else{ return true; } } </script> </head> <?php if (isset($_GET['id']) && $_GET['id'] != '') { //修改 $sql = ' select b.id as baseId, b.inputCode,t.content ,t.id from ' . ' t_wxcms_msg_base b,t_wxcms_msg_text t ' . ' where t.base_id = b.id and t.id = ' . $_GET['id']; $msgText = new MsgText(); $rst = $msgText->queryBySql($sql); if (isset($rst) && count($rst) > 0) { $msgText = $rst[0]; } } ?> <body class="bg"> <?php include "../static/top.php"; ?> <div class="content"> <div class="block-nav"> <?php include "../static/nav.php"; ?>
<?php include_once '../common/include-file.php'; $inputCode = $_POST['inputCode']; $id = $_POST['id']; $baseId = $_POST['baseId']; if (isset($id) && $id != '') { //更新 //msgBase $msgBase = new MsgBase(); $baseData = array('id' => $baseId, 'inputCode' => $_POST['inputCode']); $msgBase->updateById($baseData); //msgText $msgText = new MsgText(); $data = array('id' => $id, 'content' => $_POST['content']); $msgText->updateById($data); } else { //msgBase $msgBase = new MsgBase(); $baseData = array('msgType' => 'text', 'inputCode' => $_POST['inputCode'], 'createTime' => date('Y-m-d')); $baseId = $msgBase->insert($baseData); //msgText $msgText = new MsgText(); $data = array('base_id' => $baseId, 'content' => $_POST['content']); $msgText->insert($data); } header("Location:" . $CONTEXT_PATH . "/wxcms/msgtextList.php");
<?php include_once '../common/include-file.php'; $id = $_GET['id']; $baseId = $_GET['baseId']; $msgBase = new MsgBase(); $msgBase->delete(" id = " . $baseId); $msgText = new MsgText(); $msgText->delete(" id = " . $id); header("Location:" . $CONTEXT_PATH . "/wxcms/msgtextList.php");