コード例 #1
0
ファイル: C_Editor.php プロジェクト: Karginskiy/phpcourse2.ru
 protected function OnInput()
 {
     $mUsers = M_Users::Instance();
     parent::onInput();
     $this->mysql->Connect('localhost', 'root', '', 'liveblog');
     $mUsers->ClearSessions();
     $this->title = $this->title . ' :: Редактор статей';
     if ($this->IsPost()) {
         if ($mUsers->Login($_POST['login'], $_POST['password'])) {
             header('Location: index.php?c=editor');
             die;
         }
         $this->login = $_POST['login'];
     }
     if (empty($_GET['id'])) {
         $this->articles = $this->mysql->Select('SELECT * FROM articles');
         $this->articles = $this->m_articles->cut_contents($this->articles);
         $this->back = 0;
     } else {
         $this->articles = $this->m_articles->show_one_article($_GET['id']);
         $this->back = '1';
     }
     //  $vars = array('title' => $this->title, 'content' => $this->content);
     //  $page = $this->Template('views/v_main.php', $vars);
     //  echo $page;
 }
コード例 #2
0
ファイル: C_Edit.php プロジェクト: Karginskiy/phpcourse2.ru
 protected function OnInput()
 {
     parent::onInput();
     $this->m_articles = M_Articles::Instance();
     $this->mysql->Connect('localhost', 'root', '', 'liveblog');
     $result = $this->m_users->Get();
     if ($this->isPost()) {
         if (isset($_POST['save'])) {
             if ($this->m_articles->Edit($_GET['id'], $_POST['title'], $_POST['content'], $result['login'])) {
                 header('Location: index.php?c=editor');
                 die;
             }
         }
         if (isset($_POST['delete'])) {
             if ($this->m_articles->Delete($_GET['id'])) {
                 header('Location: index.php?c=editor');
                 die;
             }
         }
         $this->form_art['title'] = $_POST['title'];
         $this->form_art['content'] = $_POST['content'];
     } else {
         $this->form_art = $this->m_articles->show_one_article($_GET['id']);
     }
 }
コード例 #3
0
 protected function OnInput()
 {
     $mUsers = M_Users::Instance();
     parent::onInput();
     $this->mysql->Connect('localhost', 'root', '', 'liveblog');
     $result = $this->m_users->Get();
     $mUsers->ClearSessions();
     $this->title = $this->title . ' :: Добавить статью';
     if ($this->isPost()) {
         $now = date('Y-m-d H:i:s');
         $result = $this->m_articles->New_article($_POST['title'], $_POST['content'], $result['login'], $now);
         if ($result) {
             header('Location: index.php?c=editor');
         } else {
             $this->articles['title'] = $_POST['title'];
             $this->articles['content'] = $_POST['content'];
         }
     } else {
         $this->articles['title'] = '';
         $this->articles['content'] = '';
     }
 }