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/Beauty_tips.php
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');



class Beauty_tips extends Admin_Controller
{



    private $beauty_tips_current_id = NULL;

    private $image1_filename = NULL;

    private $image2_filename = NULL;



    function __construct()
    {

        parent::__construct();

        $this->load->model('beauty_tips_m');

        $this->load->helper('form');

        $this->load->library('upload');
    }



    //this is to list all blog

    public function index()
    {



        if (isset($_POST['submit'])) {



            //check & processing image banner upload files	

            if ($_FILES['userfile']['size'] !== 0) {



                $beautytips_config['upload_path']     = './uploads/beauty_tips/';

                $beautytips_config['allowed_types']    = 'jpg|png';

                $beautytips_config['max_size']         = '400';

                $beautytips_config['max_width']     = '1200';

                $beautytips_config['max_height']     = '300';



                $this->upload->initialize($beautytips_config);



                if (!$this->upload->do_upload()) {

                    $error = array('error' => $this->upload->display_errors());

                    var_dump($error);
                    die();



                    $this->session->set_flashdata('banner_error', '<br>

						<p style="background:orange; color:white; padding:5px; font-weight:bold;">Image Upload Error. Wrong format or size.</p>');

                    redirect('admin/beauty_tips');
                } else {

                    $image             = $this->upload->data();

                    $image_filename = $image['file_name'];



                    $data = array(

                        'beauty_tips_landingpage_image' => $image['file_name'],

                    );

                    $this->db->where('id_configuration', 1);

                    $this->db->update('configuration', $data);
                }
            }



            $data = array(

                'beauty_tips_landingpage_title' => $this->security->xss_clean($this->input->post('beauty_tips_landingpage_title'))

            );

            $this->db->where('id_configuration', 1);

            $this->db->update('configuration', $data);



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



        //get landingpage banner image, description and link

        $this->db->select('beauty_tips_landingpage_image, beauty_tips_landingpage_title')->from('configuration')->where('id_configuration', 1);

        $this->data['beauty_tips_landingpage'] = $this->db->get()->row();



        //get all activity

        $this->data['beauty_tips'] = $this->db->select('*')->from('beauty_tips')->order_by('priority', 'ASC')->get()->result();

        //load view

        $this->data['subview'] = 'admin/beauty_tips/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 delete blog landingpage banner image file from server, and from database

    public function delete_landingpage_image()
    {



        //get image file name for deletion

        $this->db->select('beauty_tips_landingpage_image')->from('configuration')->where('id_configuration', 1);

        $image = $this->db->get()->row()->beauty_tips_landingpage_image;



        //Delete the actual image file from server. FCPATH is codeigniter base path

        unlink(FCPATH . '/uploads/beauty_tips/' . $image);



        //Delete image field from database

        $data = array(

            'beauty_tips_landingpage_image' => '',

        );



        $this->db->where('id_configuration', 1);

        $this->db->update('configuration', $data);



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



        redirect('admin/beauty_tips');
    }



    //to add a new blog 

    public function add()
    {



        $this->data['beauty_tips'] = $this->beauty_tips_m->get_new();

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

        //validation in action

        //validation check in action 

        $config = $this->beauty_tips_m->rules;



        $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



        $this->form_validation->set_rules($config);

        $this->form_validation->set_error_delimiters('<div class="error">', '</div>');



        if ($this->form_validation->run($this) == TRUE) {



            //get max image width and height from configuration table

            $this->db->select('blog_image_width, blog_image_height, blog_thumbnail_width, blog_thumbnail_height')->from('configuration')->where('id_configuration', 1);

            $image_dimension = $this->db->get()->row();



            //check & processing IMAGE INTRO

            if ($_FILES['image1']['size'] !== 0) {

                $config1['upload_path']     = './uploads/beauty_tips/';

                $config1['allowed_types']     = 'jpg|png';

                $config1['max_size']        = '400';

                $config1['max_width']         = $image_dimension->blog_thumbnail_width;

                $config1['max_height']         = $image_dimension->blog_thumbnail_height;

                $this->upload->initialize($config1);

                if (!$this->upload->do_upload('image1')) {

                    // return the error message and kill the script

                    // echo $this->upload->display_errors();

                    $this->session->set_flashdata('image1-error', '<br>

						<p style="background:red; color:white; padding:5px; font-weight:bold;">Image Upload Error. Wrong format or size.</p>');

                    redirect('admin/beauty_tips/add');
                } else {

                    $image1 = $this->upload->data();

                    $this->image1_filename = $image1['file_name'];
                }
            }

            //check & processing IMAGE TOP BANNER

            if ($_FILES['image2']['size'] !== 0) {

                $config2['upload_path']     = './uploads/beauty_tips/';

                $config2['allowed_types']    = 'jpg|png';

                $config2['max_size']        = '400';

                $config2['max_width']         = $image_dimension->blog_image_width;

                $config2['max_height']         = $image_dimension->blog_image_height;

                $this->upload->initialize($config2);

                if (!$this->upload->do_upload('image2')) {

                    // return the error message and kill the script

                    // echo $this->upload->display_errors();

                    $this->session->set_flashdata('image2-error', '<br>

						<p style="background:red; color:white; padding:5px; font-weight:bold;">Image Upload Error. Wrong format or size.</p>');

                    redirect('admin/beauty_tips/add');
                } else {

                    $image2 = $this->upload->data();

                    $this->image2_filename = $image2['file_name'];
                }
            }

            $data = $this->table_data_processing(

                $this->input->post('beauty_tips'),

                $this->input->post('author'),

                $this->input->post('status'),

                $this->input->post('beauty_tips_type'),

                $this->input->post('description'),

                $this->image1_filename,

                $this->image2_filename,

                $this->input->post('meta_description'),

                $this->input->post('meta_keywords'),

                $this->input->post('publish_date')

            );



            $this->beauty_tips_m->add_beauty_tips($data);

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

            redirect('admin/beauty_tips');
        }

        $this->data['subview'] = 'admin/beauty_tips/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 blog in admin

    public function edit($id = NULL)
    {

        if ($id == NULL) {
            show_404();
        }

        //check if id exist. If not exist, show 404.

        $count = $this->beauty_tips_m->count_exist($id);

        if ($count == 0) {

            //page not exist

            show_404();
        }

        $this->data['beauty_tips'] = $this->beauty_tips_m->get($id);

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

        //validation check in action

        $config = $this->beauty_tips_m->rules;

        $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

        $this->form_validation->set_rules($config);

        $this->form_validation->set_error_delimiters('<div class="error">', '</div>');

        if ($this->form_validation->run($this) == TRUE) {

            //get max image width and height from configuration table

            $this->db->select('blog_image_width, blog_image_height, blog_thumbnail_width, blog_thumbnail_height')->from('configuration')->where('id_configuration', 1);

            $image_dimension = $this->db->get()->row();

            //check & processing IMAGE INTRO

            if ($_FILES['image1']['size'] !== 0) {

                $config1['upload_path']     = './uploads/beauty_tips/';

                $config1['allowed_types']    = 'jpg|png';

                $config1['max_size']        = '400';

                $config1['max_width']         = $image_dimension->blog_thumbnail_width;

                $config1['max_height']         = $image_dimension->blog_thumbnail_height;

                $this->upload->initialize($config1);

                if (!$this->upload->do_upload('image1')) {

                    // return the error message and kill the script

                    // echo $this->upload->display_errors(); 

                    $this->session->set_flashdata('image1-error', '<br>

						<p style="background:red; color:white; padding:5px; font-weight:bold;">Image Upload Error. Wrong format or size.</p>');

                    redirect('admin/beauty_tips/edit/' . $id);
                } else {

                    $image1 = $this->upload->data();

                    $this->image1_filename = $image1['file_name'];
                }
            }

            //check & processing IMAGE TOP BANNER

            if ($_FILES['image2']['size'] !== 0) {

                $config2['upload_path']     = './uploads/beauty_tips/';

                $config2['allowed_types']     = 'jpg|png';

                $config2['max_size']        = '400';

                $config2['max_width']         = $image_dimension->blog_image_width;

                $config2['max_height']         = $image_dimension->blog_image_height;

                $this->upload->initialize($config2);

                if (!$this->upload->do_upload('image2')) {

                    // return the error message and kill the script

                    //echo $this->upload->display_errors(); 

                    $this->session->set_flashdata('image2-error', '<br>

					<p style="background:red; color:white; padding:5px; font-weight:bold;">Image Upload Error. Wrong format or size.</p>');

                    redirect('admin/beauty_tips/edit/' . $id);
                } else {

                    $image2 = $this->upload->data();

                    $this->image2_filename = $image2['file_name'];
                }
            }

            $data = $this->table_data_processing(

                $this->input->post('beauty_tips'),

                $this->input->post('author'),

                $this->input->post('status'),

                $this->input->post('beauty_tips_type'),

                $this->input->post('description'),

                $this->image1_filename,

                $this->image2_filename,

                $this->input->post('meta_description'),

                $this->input->post('meta_keywords'),

                $this->input->post('publish_date')

            );

            $this->beauty_tips_m->edit_beauty_tips($id, $data);

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

            redirect('admin/beauty_tips/edit/' . $id);
        }



        $this->data['subview'] = 'admin/beauty_tips/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 blog

    public function delete($id)
    {



        //check if id exist. If not exist, show 404.

        $count = $this->beauty_tips_m->count_exist($id);



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

            show_404();
        }



        //delete image from server

        //check if there is an existing image

        $this->db->select('image1, image2')->from('beauty_tips')->where('id', (int) $id);

        $image = $this->db->get()->row();



        if ($image->image1 != '') {

            //Delete the actual image file from server. FCPATH is codeigniter base path

            unlink(FCPATH . '/uploads/beauty_tips/' . $image->image1);
        }



        if ($image->image2 != '') {

            //Delete the actual image file from server. FCPATH is codeigniter base path

            unlink(FCPATH . '/uploads/beauty_tips/' . $image->image2);
        }



        //delete blog

        $this->beauty_tips_m->delete($id);



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

        redirect('admin/beauty_tips');
    }



    private function table_data_processing($beauty_tips, $author, $status, $beauty_tips_type, $description, $image1_filename, $image2_filename, $meta_description, $meta_keywords, $publish_date)
    {



        $publish_date = explode('-', $publish_date);

        $publish_date = $publish_date[2] . '-' . $publish_date[1] . '-' . $publish_date[0];



        $data = array(

            'beauty_tips'         => $this->security->xss_clean($beauty_tips),

            'author'              => $author,

            'alias'               => url_title($beauty_tips),

            'status'              => $status,

            'beauty_tips_type'    => $beauty_tips_type,

            'description'         => $description,

            'description_en'      => $this->security->xss_clean($this->input->post('description_en')),

            'publish_date'        => $publish_date,

            'priority'            => $this->input->post('priority'),

        );

        //image upload

        if (isset($image1_filename)) {

            $data['image1'] = $image1_filename;
        }

        //image upload

        if (isset($image2_filename)) {

            $data['image2'] = $image2_filename;
        }

        return $data;
    }



    //callback function validation add new blog

    //make it private by adding _

    public function _cek_existing_beauty_tips_title($str)
    {



        $num_rows = $this->beauty_tips_m->cek_existing_beauty_tips_title($str, $this->beauty_tips_current_id);

        if ($num_rows != 0) {

            $this->form_validation->set_message('_cek_existing_beauty_tips_title', 'beauty tips title already exist !');

            return FALSE;
        } else {

            return TRUE;
        }
    }



    //To delete blog image file from server, and from database

    public function delete_image($id = NULL, $image_type = NULL)
    {



        $count = $this->beauty_tips_m->count_exist($id);



        if ($id == NULL || $count == 0) {
            redirect('admin/beauty_tips');
        }



        if ($image_type == NULL) {
            redirect('admin/beauty_tips');
        }



        //get image file name for deletion

        $this->db->select('image1, image2')->from('beauty_tips')->where('id', (int) $id);

        $image = $this->db->get()->row();



        if ($image_type == 'image1') {

            //Delete the actual image file from server. FCPATH is codeigniter base path

            unlink(FCPATH . '/uploads/beauty_tips/' . $image->image1);



            //Delete image field from database

            $data = array(

                'image1' => '',

            );
        } elseif ($image_type == 'image2') {

            //Delete the actual image file from server. FCPATH is codeigniter base path

            unlink(FCPATH . '/uploads/beauty_tips/' . $image->image2);



            //Delete image field from database

            $data = array(

                'image2' => '',

            );
        }



        $this->db->where('id', (int) $id);

        $this->db->update('beauty_tips', $data);



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



        redirect('admin/beauty_tips/edit/' . $id);
    }
}

https://t.me/RX1948 - 2025