| 1234567891011121314151617181920212223242526272829303132 |
- <?php
- class controller_main extends Controller
- {
- public function __construct()
- {
- parent::__construct();
- if(empty($_SESSION['user'])){
- header('Location: /user/login');
- }
- $this->model = new Model_main();
- }
- function index()
- {
- include 'app/models/model_user.php';
- $users_model = new Model_user();
- $data['users'] = $users_model->get_users();
- $data['posts'] = $this->model->get_posts();
- $this->view->generate('main_view.php', $data);
- }
- public function createpost(){
- if(isset($_POST['caption'], $_POST['post'])){
- $this->model->create_post($_POST['caption'], $_POST['post']);
- }
- header('Location: /');
- }
- }
|