Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- defined('BASEPATH') OR exit('No direct script access allowed');
- class C_video extends CI_Controller {
- public function __construct(){
- parent::__construct();
- $this->load->model('Model_upload_video');
- if(!$this->session->userdata('username'))
- {
- redirect('Ctr_login');
- }
- }
- public function index()
- {
- $data['nav'] = 1;
- $data['js'] = $this->js();
- $data['v_video'] = $this->Model_upload_video->view_video();
- $data['ar_video'] = $this->Model_upload_video->view_nm_video();
- $this->load->view('admin/head');
- $this->load->view('admin/nav',$data);
- $this->load->view('admin/body_video',$data);
- $this->load->view('admin/footer');
- }
- public function add_video(){
- if (isset($_FILES['video']['name']) && $_FILES['video']['name'] != '') {
- unset($config);
- $date = date("ymd");
- $configVideo['upload_path'] = './assets/video';
- $configVideo['max_size'] = '100000';
- $configVideo['allowed_types'] = 'avi|flv|wmv|mp3|mp4';
- $configVideo['overwrite'] = FALSE;
- $configVideo['remove_spaces'] = FALSE;
- $video_name = $_FILES['video']['name'];
- $configVideo['file_name'] = $video_name;
- $this->load->library('upload', $configVideo);
- $this->upload->initialize($configVideo);
- if(!$this->upload->do_upload('video')) {
- echo $this->upload->display_errors();
- }/*elseif($this->Model_upload_video->cek_nm_video($video_name) == true){
- $msg='<div class="alert alert-success">
- <button class="close" data-close="alert"></button> <b>Upload</b> Video Gagal! </div>';
- $this->index($msg);
- $this->session->set_flashdata('message', $msg);
- redirect('C_video');
- }*/else{
- $data=array(
- 'nama_video'=> $configVideo['file_name'],
- 'tgl_upload'=> date("Y:m:d H:m:s"),
- 'tampil' => 0
- );
- $this->Model_upload_video->insert_video($data);
- $msg='<div class="alert alert-success">
- <button class="close" data-close="alert"></button> <b>Upload</b> Video Sukses! </div>';
- $this->index($msg);
- $this->session->set_flashdata('message', $msg);
- redirect('C_video');
- }
- }else{
- echo "Please select a file";
- }
- }
- public function edit_video($id_v)
- {
- $status = $this->Model_upload_video->view_status_by_id($id_v);
- if ($status->tampil == "1") {
- $data['update_video'] = $this->Model_upload_video->update_status_by_id($id_v,"0");
- $msg='<div class="alert alert-success">
- <button class="close" data-close="alert"></button> <b>Menyembunyikan</b> Video Sukses! </div>';
- $this->index($msg);
- $this->session->set_flashdata('message', $msg);
- redirect('C_video');
- }else{
- $data['update_video'] = $this->Model_upload_video->update_status_by_id($id_v,"1");
- $msg='<div class="alert alert-success">
- <button class="close" data-close="alert"></button> <b>Menampilkan</b> Video Sukses! </div>';
- $this->index($msg);
- $this->session->set_flashdata('message', $msg);
- redirect('C_video');
- }
- }
- function delete_video($id)
- {
- $video = $this->Model_upload_video->cek_nm_video($id);
- $this->Model_upload_video->delete($id, $video->nama_video);
- $msg='<div class="alert alert-warning">
- <button class="close" data-close="alert"></button> <b>Hapus</b> Data Sukses! </div>';
- $this->index($msg);
- $this->session->set_flashdata('message', $msg);
- redirect('C_video');
- }
- function js()
- {
- $js = '
- function confirm_del(id)
- {
- bootbox.confirm({
- size: "small",
- message: "Anda akan menghapus data ini?",
- callback: function(result){
- if (result)
- {
- document.location.href = "'.base_url().'C_video/delete_video/"+id;
- }
- }
- })
- }';
- return $js;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement