Esempio n. 1
0
 public function new_thread($id = null)
 {
     $ide = new IDE();
     $ide->requireLogin();
     if (empty($id)) {
         $ide->criticalRedirect(WEBSITE . "/index.php/forum");
     }
     $this->load->model("forum_model");
     $this->load->library("form_validation");
     $data = array();
     $data['board'] = $this->forum_model->getBoardInfo($id);
     if (count($data['board']) == 0) {
         $ide->redirect(WEBSITE . "/index.php/forum");
     }
     if ($data['board'][0]['closed'] == 1) {
         if (!$ide->isAdmin()) {
             $ide->redirect(WEBSITE . "/index.php/forum/board/" . $data['board']['id']);
         }
     }
     if ($data['board'][0]['access'] > $_SESSION['access'] && $ide->isAdmin() == false) {
         $ide->redirect(WEBSITE . "/index.php/forum/board/" . $data['board']['id']);
     }
     if ($_POST) {
         $this->form_validation->set_rules('character', 'Character', 'required|callback__checkCharacter');
         $this->form_validation->set_rules('title', 'Title', 'required|min_lenght[3]|max_lenght[64]|callback__checkTimer');
         $this->form_validation->set_rules('post', 'Post', 'required|min_lenght[3]|max_lenght[3000]');
         if ($this->form_validation->run() == true) {
             $_SESSION['lastPost'] = time();
             $this->forum_model->postThread($id, $_POST['character'], $_POST['title'], $_POST['post']);
             $ide->redirect(WEBSITE . "/index.php/forum/thread/" . $board['0']['id']);
         }
     }
     $data['id'] = $id;
     $data['characters'] = $this->forum_model->getCharacters();
     $this->load->helper("form_helper");
     $this->load->view("forum_new_thread", $data);
 }