Exemple #1
0
    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;
        }
    }
Exemple #2
0
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<?php 
$CUR_NAE = 'msgnews';
?>
		<?php 
include "../static/res.php";
?>
		<script type="text/javascript" >
			var editor = simpleKindeditor("description");
		</script>
	</head>
	
	<?php 
if (isset($_GET['id']) && $_GET['id'] != '') {
    $sql = ' select b.id as baseId, b.inputCode, t.*  from  ' . ' t_wxcms_msg_base b,t_wxcms_msg_news t ' . ' where t.base_id = b.id and t.id = ' . $_GET['id'];
    $msgNews = new MsgNews();
    $rst = $msgNews->queryBySql($sql);
    if (isset($rst) && count($rst) > 0) {
        $msgNews = $rst[0];
    }
}
?>
	
	<body class="bg">
		<?php 
include "../static/top.php";
?>
		
		<div class="content">
			<div class="block-nav">
				<?php 
Exemple #3
0
<?php

include_once '../common/include-file.php';
$id = $_GET['id'];
$baseId = $_GET['baseId'];
$msgBase = new MsgBase();
$msgBase->delete(" id = " . $baseId);
$msgNews = new MsgNews();
$msgNews->delete(" id = " . $id);
header("Location:" . $CONTEXT_PATH . "/wxcms/msgnewsList.php");
    }
    $data = array('id' => $id, 'author' => $_POST['author'], 'title' => $_POST['title'], 'brief' => $_POST['brief'], 'showpic' => $showPic, 'description' => $_POST['description'], 'fromurl' => $_POST['fromurl']);
    if (isset($picPath) && !empty($picPath)) {
        $data['picPath'] = $picPath;
    }
    $msgNews->updateById($data);
} else {
    //添加
    //msgBase
    $msgBase = new MsgBase();
    $baseData = array('msgType' => 'news', 'inputCode' => $_POST['inputCode'], 'createTime' => date('Y-m-d'));
    $baseId = $msgBase->insert($baseData);
    //msgNews
    //上传图片
    $picPath = '';
    $uprst = uploadImg("imgFile");
    if ($uprst['flag']) {
        $picPath = $uprst['imgUrl'];
    }
    $msgNews = new MsgNews();
    $showPic = 0;
    if (!empty($_POST['showPic'])) {
        $showPic = 1;
    }
    $data = array('base_id' => $baseId, 'author' => $_POST['author'], 'title' => $_POST['title'], 'brief' => $_POST['brief'], 'showpic' => $showPic, 'description' => $_POST['description'], 'fromurl' => $_POST['fromurl'], 'picPath' => $picPath);
    $newsId = $msgNews->insert($data);
    $url = 'http://' . $_SERVER['HTTP_HOST'] . $CONTEXT_PATH . '/wxapi/newsread.php?id' . $newsId;
    $updata = array('id' => $newsId, 'url' => $url);
    $msgNews->updateById($updata);
}
header("Location:" . $CONTEXT_PATH . "/wxcms/msgnewsList.php");