示例#1
0
 protected function _add($post)
 {
     if ($_POST['title'] == '' || $_POST['text'] == '') {
         $this->error('标题或内容不能为空!');
     }
     $data = array('title' => Input::getVar($_POST['title']), 'date' => date('Y-m-d H:i:s'));
     //存入日志基本信息
     $db = new ArticlesModel();
     //dump($data);exit;
     $id = $db->add($data);
     if ($id === false || $id === null) {
         $this->error('保存文章基本信息时出现错误' . $db->getError());
     }
     //存入日志内容信息
     $db = new ArticlesContentModel();
     unset($data);
     $data = array('id' => $id, 'text' => str_replace('\\', '', str_replace(""", '', $_POST['text'])));
     $rs = $db->add($data);
     if ($rs === false || $rs === null) {
         $this->error('保存文章内容时出现错误' . $db->getError());
     }
     $c = $this->getConfig();
     $msg = '发表文章《' . Input::getVar($_POST['title']) . '》 详细:' . $c['domain'] . '/index.php/Note/view/id/' . $data['id'];
     //同步到本站微博
     $db = new WorldsModel();
     $data = array('text' => Input::makeLink($msg), 'time' => date('Y-m-d H:i:s'));
     $db->add($data);
     //同步到新浪微博
     $this->sina_update($msg);
     $this->redirect('Note/view/id/' . $id);
 }