public function index() { $blog_post = new BlogPostModel(); $blog_post->setAuthor('Hiran'); $blog_post->setBody('Adooo'); $blog_post->getSummary('this is the summary'); // var_dump($blog_post); // $post = new Models\PostModel(); $post = new PostModel(); $view = new ViewController(); if (isset($_GET['method'])) { if ($_GET['method'] == 'add') { return $view->theme('post', array('posts' => $post->savePost($_POST))); } else { if ($_GET['method'] == 'delete') { return $view->theme('post', array('posts' => $post->deletePost($_GET['post']))); } else { $posts = $post->get_post($_GET['post']); if (!empty($posts)) { foreach ($posts as $post) { return $view->theme('post', array('posts' => $post)); } } else { header('Location: ?action=admin'); } } } } else { return $view->theme('post', array('posts' => $post->defaultPost())); } }
public function index() { if (isset($_SESSION['admin'])) { session_destroy(); } $blog_post = new BlogPostModel(); $blog_post->setAuthor('Hiran'); $blog_post->setBody('Adooo'); $blog_post->getSummary('this is the summary'); // var_dump($blog_post); // $post = new Models\PostModel(); $post = new PostModel(); $view = new ViewController(); if (isset($_GET['post'])) { return $view->theme('home', array('posts' => $post->get_post($_GET['post']), 'date' => date('Y-m-d'))); } else { return $view->theme('home', array('posts' => $post->get_post(), 'date' => date('Y-m-d'))); } }
/** * */ public function index() { $post = new PostModel(); if (isset($_SESSION['admin']) && $_SESSION['admin'] == 'admin') { if (isset($_GET['post'])) { return $this->view->theme('home', array('posts' => $post->get_post($_GET['post']))); } else { return $this->view->theme('admin_home', array('posts' => $post->get_post())); } } else { if (isset($_POST['password'])) { $admin_array = array('username' => 'admin', 'password' => '0192023a7bbd73250516f069df18b500'); // admin123' if (md5($_POST['password']) == $admin_array['password']) { $_SESSION['admin'] = 'admin'; return $this->view->theme('admin_home', array('data' => '')); } else { return $this->view->theme('login', array('data' => '<div class="alert alert-danger" role="alert">error in login</div>')); } } return $this->view->theme('login', array('data' => '')); } }