Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
- //просмотр конкретного файла
- class File extends CI_Controller {
- public $data;
- public function index()
- {
- $this->data['menu'] = $this->main_m->menu(); //загрузка меню
- $this->load->model('data_m');
- $file_id = $this->input->get('id');//id файла
- $this->data['file_id'] = $this->input->get('id');
- $this->data['comments'] = $this->data_m->get_comments($file_id); //выборка комментариев
- $this->data['data'] = $this->data_m->get_file();//получение конкретного файла
- $this->data['quant'] = $this->data_m->quant_comments($file_id);//кол-во коммент
- $this->data['title'] = $this->data_m->get_title($file_id);
- $this->data['author'] = $this->data_m->get_author($file_id);
- $this->load->view('file_v',$this->data);
- //добавление комментария
- if(isset($_POST['comment']) && isset($_POST['id'])){
- $text = htmlspecialchars($this->input->post('comment'));
- $id = $this->input->post('id');
- $author = 'Test';
- $date = date('d-m-Y H:i');
- $this->data_m->add_comment($id,$author,$text,$date);
- echo json_encode(array('author' => $author, 'text' => $text, 'date' => $date));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment