Example #1
0
 $data['info_desc'] = isset($_POST['info_desc']) ? str_inmysql($_POST['info_desc']) : '';
 $data['info_intro'] = isset($_POST['info_intro']) ? str_inmysql($_POST['info_intro']) : '';
 $data['info_url'] = isset($_POST['info_url']) ? str_inmysql($_POST['info_url']) : '';
 $data['create_date'] = date('Y-m-d H:i:s', $_WGT['TIME']);
 if (!$data['keyword']) {
     ajax_feedback(0, '1201');
 }
 if (!$data['info_intro']) {
     ajax_feedback(0, '1202');
 }
 if (!$data['cate_id']) {
     $data['cate_id'] = Model_Table::get('InfoCate')->saveDefaultCate($customer_id, $info_type);
 }
 //关键词过滤
 $keyArray = explode(',', $data['keyword']);
 $keyTable = new Model_KeywordList();
 foreach ($keyArray as $v) {
     $filter['where'] = "customer_id='{$customer_id}' and keyword='{$v}'";
     $nums = $keyTable->count($filter);
     if ($nums > 0 && !$_POST['id']) {
         ajax_feedback(0, '', "关键词 \"" . $v . '" 已存在,请更换');
         die;
     } elseif ($_POST['id']) {
         $num = $keyTable->fetchRow("select * from keyword_list where info_id!='{$_POST['id']}' and keyword='{$v}' and customer_id='{$customer_id}'");
         if ($num == true) {
             ajax_feedback(0, '', "关键词 \"" . $v . '" 已存在,请更换!');
             die;
         }
     }
 }
 //save-infocommon
Example #2
0
 public function getInfo()
 {
     $KeywordlistModel = new Model_KeywordList();
     $keyword = $this->post_data['Keyword'];
     $filter['where'] = " customer_id='{$this->customer_id}' and keyword='{$keyword}' ";
     $filter['order'] = " rand() ";
     $sql = $KeywordlistModel->select($filter, 'info_id,info_type');
     $keywordinfo = $KeywordlistModel->fetchRow($sql);
     $base_infoarray = array('text', 'single', 'multi', 'pic', 'music', 'video');
     if ($keywordinfo['info_type']) {
         if (in_array($keywordinfo['info_type'], $base_infoarray)) {
             $class = 'base_info';
         } else {
             $class = $keywordinfo['info_type'] . '_info';
         }
         $classFile = $class . '.php';
         if (file_exists($classFile)) {
             include "{$classFile}";
             $infoobj = new $class();
             $result['info_id'] = $keywordinfo['info_id'];
             $result['info_type'] = $keywordinfo['info_type'];
             $result['customer_id'] = $this->customer_id;
             $result['fromuser'] = $this->post_data['FromUserName'];
             $result['timesign'] = $this->post_data['timesign'];
             $data = $infoobj->getData($result);
             $xmlcontent = $this->create_xmlcontent($data['msgtype'], $data['content'], $data['title'], $data['description'], $data['picurl'], $data['url'], $data['bodystr']);
             return $xmlcontent;
         }
     } else {
         include "special_info.php";
         $infoobj = new special_info();
         $result['info_id'] = $keywordinfo['info_id'];
         $result['info_type'] = $keywordinfo['info_type'];
         $result['customer_id'] = $this->customer_id;
         $result['fromuser'] = $this->post_data['FromUserName'];
         $result['timesign'] = $this->post_data['timesign'];
         $result['keyword'] = $this->post_data['Keyword'];
         $data = $infoobj->getData($result);
         if ($data['msgtype'] != '') {
             return $this->create_xmlcontent($data['msgtype'], $data['content'], $data['title'], $data['description'], $data['picurl'], $data['url'], $data['bodystr']);
         } else {
             //无匹配回复
             $replyModel = new Model_AutoReply();
             $replyRow = $replyModel->findByCustomerId($this->customer_id, '2');
             if (!$replyRow['id'] or $replyRow['state'] != '1') {
                 return false;
             } else {
                 return $this->create_xmlcontent('text', $replyRow['reply_content']);
             }
         }
     }
 }