db->query("UPDATE `post` SET `view`=`view`+'1' WHERE `id`=?", array($id)); $_SESSION['view_blog_'.$id] = md5(rand(10000000000,2929929299)); } $this->model->loadModel('model_post'); $post = new model_post(); $h = array ('title'=>$post->data($id)['title']); $this->view->generate('header',$h); $postViev =$post->data($id); $this->view->generate('post_view',$postViev); } function action_like($id) { if (isset($_SESSION['like_'.$id])) { $this->db->query("UPDATE `post` SET `like`=`like`-'1' WHERE `id`=?", array($id)); unset($_SESSION['like_'.$id]); } elseif (!$_SESSION['like_'.$id]) { $this->db->query("UPDATE `post` SET `like`=`like`+'1' WHERE `id`=?", array($id)); //setcookie('like_'.$id,1,time()+(84600+365)); $_SESSION['like_'.$id] = 1; } header("Location:/post/view/".$id); exit; } function action_index () { return $this->action_view(1); } function action_all() { self::load('pagination'); $pagination = new pagination(); $h = array ('title'=>'Все записи'); $this->view->generate('header',$h); $pagination->set('pages','5'); $pagination->show(); } }