Guest User

Untitled

a guest
Jan 18th, 2014
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.34 KB | None | 0 0
  1. <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  2. //просмотр конкретного файла
  3. class File extends CI_Controller {
  4.     public $data;
  5.     public function index()
  6.     {
  7.         $this->data['menu'] = $this->main_m->menu(); //загрузка меню
  8.         $this->load->model('data_m');
  9.        
  10.         $file_id = $this->input->get('id');//id файла
  11.         $this->data['file_id'] = $this->input->get('id');
  12.         $this->data['comments'] = $this->data_m->get_comments($file_id); //выборка комментариев
  13.         $this->data['data'] = $this->data_m->get_file();//получение конкретного файла
  14.         $this->data['quant'] = $this->data_m->quant_comments($file_id);//кол-во коммент
  15.         $this->data['title'] = $this->data_m->get_title($file_id);
  16.         $this->data['author'] = $this->data_m->get_author($file_id);
  17.        
  18.         $this->load->view('file_v',$this->data);
  19.         //добавление комментария
  20.         if(isset($_POST['comment']) && isset($_POST['id'])){
  21.         $text = htmlspecialchars($this->input->post('comment'));
  22.         $id = $this->input->post('id');
  23.         $author = 'Test';
  24.         $date = date('d-m-Y H:i');
  25.         $this->data_m->add_comment($id,$author,$text,$date);
  26.         echo json_encode(array('author' => $author, 'text' => $text, 'date' => $date));
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment