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/blue-sky.co.id/public_html/application/controllers/admin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

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

class Hotel_pages extends Admin_Controller {

	//this property is used for validating existing page title on call back edit page
	private $page_current_id = NULL;

	//this property is to mark whether we are uploading image in the index page
    private $imageupload_indexpage = FALSE;
		
	function __construct() {

		parent::__construct();	

		//admin role module check
		$this->check_admin_role('halaman statis'); //method from Admin_controller
		
		$this->load->model('hotel_page_m'); 
	}
		
	//this is to list all hotel_pages

    public function index() {

		//fetch all hotel_pages
   		$this->data['hotel_pages'] = $this->hotel_page_m->get_all_hotel_pages(); 
	
		//load view
		$this->data['subview'] = 'admin/hotel_pages/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_page_banner() { 

        //get image file name for deletion
        $this->db->select('page_banner')->from('configuration')->where('id_configuration', 1);
        $image = $this->db->get()->row()->page_banner;

        //Delete the actual image file from server. FCPATH is codeigniter base path
        unlink(FCPATH .'/uploads/blog/'. $image);

        //Delete image field from database
        $data = array( 
            'page_banner' => '',
        );

        $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;">Hapus Banner Berhasil</p>');
        
        redirect('admin/hotel_pages/index'); 
    }

    function changeStatusAct(){
    	$this_id = $this->input->post('this_id');
    	$toStat = $this->input->post('toStat');

    	$codeStat = null;
    	if ($toStat == "Ya") {
    		$codeStat = '1';
    	}else{
    		$codeStat = '0'; 
    	}

    	$data = array(
    		"status"=>$codeStat,
    	);

    	$upd = $this->db->update('hotel_pages', $data, array('id_hotel_pages' => $this_id));

    	if ($upd) {
	    	echo json_encode(array(
	    		"res"=>"sukses",
	    	));
    	}

    }
	
	//to add a new page 
	public function add() {
	
		$this->data['hotel_pages'] = $this->hotel_page_m->get_new();
		$this->data['parent_hotel_pages'] = $this->hotel_page_m->get_parent_hotel_pages();	 

		//get ordering number and display at add form
		$this->db->select_max('priority')->from('hotel_pages')->where('parent', NULL);
		$current_priority = $this->db->get()->row()->priority;
		if($current_priority == NULL) {
			$this->data['hotel_pages']->priority = 1;	
		} else {
			$this->data['hotel_pages']->priority = $current_priority + 1;
		} 
		
		//validation in action
		//validation check in action
		$config = $this->hotel_page_m->rules;

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

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

			if($_POST) {
				$data = array();
				//check & processing image banner upload files	
				if ($_FILES['image1']['size'] !== 0) {  	
 
					$config['upload_path'] = './uploads/banners/'; 
					$config['allowed_types'] = 'jpg|png'; 
					$config['max_size']	= '600';
					$config['max_width']  = '1670';
					$config['max_height'] = '800';
					$this->load->library('upload', $config);
              		$this->upload->initialize($config);

					if ( ! $this->upload->do_upload('image1')) { 
						$this->session->set_flashdata('error1', '<br>
							<p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>');
						redirect('admin/hotel_pages/edit/'.$id);
					} else {
						$image1 = $this->upload->data();
						$image1_filename = $image1['file_name']; 
						// $this->resize_single_image('580','500','home_about/',$image1_filename);	 
					}	
                }
                
				if ($_FILES['image2']['size'] !== 0) { 
					$config['upload_path'] = './uploads/banners/'; 
					$config['allowed_types'] = 'jpg|png'; 
					$config['max_size']	= '600';
					$config['max_width']  = '1670';
					$config['max_height'] = '800';
					$this->load->library('upload', $config);
              		$this->upload->initialize($config);

					if ( ! $this->upload->do_upload('image2')) { 
						$this->session->set_flashdata('error2', '<br>
							<p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>');
						redirect('admin/hotel_pages/edit/'.$id);
					} else {
						$image2 = $this->upload->data();
						$image2_filename = $image2['file_name']; 
						// $this->resize_single_image('580','500','home_about/',$image2_filename);	 
					}	
                }
                
				if ($_FILES['image3']['size'] !== 0) {
					$config['upload_path'] = './uploads/banners/'; 
					$config['allowed_types'] = 'jpg|png'; 
					$config['max_size']	= '600';
					$config['max_width']  = '1670';
					$config['max_height'] = '800';
					$this->load->library('upload', $config);
              		$this->upload->initialize($config);

					if ( ! $this->upload->do_upload('image3')) { 
						$this->session->set_flashdata('error3', '<br>
							<p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>');
						redirect('admin/hotel_pages/edit/'.$id);
					} else {
						$image3 = $this->upload->data();
						$image3_filename = $image3['file_name']; 
						// $this->resize_single_image('580','500','home_about/',$image3_filename);	 
					}	
				} 
 

				$data = $this->table_data_processing($this->input->post('page_title'), $this->input->post('page_title_en'), $this->input->post('status'), $this->input->post('body_text'), $this->input->post('body_text_en'), $this->input->post('meta_description'), $this->input->post('meta_keywords')); 

				//image upload
				if (isset($image1_filename)) {
					$data['img_name'] = $image1_filename;
				}else{
					$data['img_name'] = @explode(' | ', $this->data['hotel_pages']->img_name)[0];
				}

				//image upload
				if (isset($image2_filename)) {
					$data['img_name'] .= ' | '.$image2_filename;
				}else{
					$data['img_name'] .= ' | '.@explode(' | ', $this->data['hotel_pages']->img_name)[1];
				}

				//image upload
				if (isset($image3_filename)) {
					$data['img_name'] .= ' | '.$image3_filename;
				}else{
					$data['img_name'] .= ' | '.@explode(' | ', $this->data['hotel_pages']->img_name)[2];
				}

				if ($_FILES['image_center1']['size'] !== 0) {
					$config['upload_path'] = './uploads/image_center/'; 
					$config['allowed_types'] = 'jpg|png'; 
					$config['max_size']	= '300';
					$config['max_width']  = '570';
					$config['max_height'] = '290'; 
					
					$this->load->library('upload', $config);
              		$this->upload->initialize($config);

					if ( ! $this->upload->do_upload('image_center1')) { 
						$this->session->set_flashdata('image_center1', '<br>
							<p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>');
						redirect('admin/hotel_pages/edit/'.$id);
					} else {
						$image_center1 = $this->upload->data();
						$image_center1_filename = $image_center1['file_name'];	 
					}	
				}
				if (isset($image_center1)) {
					$data['img_center1'] = $image_center1_filename;
				}

				if ($_FILES['image_center2']['size'] !== 0) {
					$config['upload_path'] = './uploads/image_center/'; 
					$config['allowed_types'] = 'jpg|png'; 
					$config['max_size']	= '300';
					$config['max_width']  = '570';
					$config['max_height'] = '290'; 
					
					$this->load->library('upload', $config);
              		$this->upload->initialize($config);

					if ( ! $this->upload->do_upload('image_center2')) { 
						$this->session->set_flashdata('image_center2', '<br>
							<p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>');
						redirect('admin/hotel_pages/edit/'.$id);
					} else {
						$image_center2 = $this->upload->data();
						$image_center2_filename = $image_center2['file_name'];	 
					}	
				}
				if (isset($image_center2)) {
					$data['img_center2'] = $image_center2_filename;
				}

				if ($_FILES['image_center3']['size'] !== 0) {
					$config['upload_path'] = './uploads/image_center/'; 
					$config['allowed_types'] = 'jpg|png'; 
					$config['max_size']	= '300';
					$config['max_width']  = '570';
					$config['max_height'] = '290';  
					
					$this->load->library('upload', $config);
              		$this->upload->initialize($config);

					if ( ! $this->upload->do_upload('image_center3')) { 
						$this->session->set_flashdata('image_center3', '<br>
							<p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>');
						redirect('admin/hotel_pages/edit/'.$id);
					} else {
						$image_center3 = $this->upload->data();
						$image_center3_filename = $image_center3['file_name'];	 
					}	
				}
				if (isset($image_center3)) {
					$data['img_center3'] = $image_center3_filename;
				}

				if ($_FILES['image_center4']['size'] !== 0) {
					$config['upload_path'] = './uploads/image_center/'; 
					$config['allowed_types'] = 'jpg|png'; 
					$config['max_size']	= '300';
					$config['max_width']  = '570';
					$config['max_height'] = '290';  
					
					$this->load->library('upload', $config);
              		$this->upload->initialize($config);

					if ( ! $this->upload->do_upload('image_center4')) { 
						$this->session->set_flashdata('image_center4', '<br>
							<p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>');
						redirect('admin/hotel_pages/edit/'.$id);
					} else {
						$image_center4 = $this->upload->data();
						$image_center4_filename = $image_center4['file_name'];	 
					}	
				}
				if (isset($image_center4)) {
					$data['img_center4'] = $image_center4_filename;
				}
				if ($_FILES['image_center5']['size'] !== 0) {
					$config['upload_path'] = './uploads/image_center/'; 
					$config['allowed_types'] = 'jpg|png'; 
					$config['max_size']	= '300';
					$config['max_width']  = '570';
					$config['max_height'] = '290';  
					
					$this->load->library('upload', $config);
              		$this->upload->initialize($config);

					if ( ! $this->upload->do_upload('image_center5')) { 
						$this->session->set_flashdata('image_center5', '<br>
							<p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>');
						redirect('admin/hotel_pages/edit/'.$id);
					} else {
						$image_center5 = $this->upload->data();
						$image_center5_filename = $image_center5['file_name'];	 
					}	
				}
				if (isset($image_center5)) {
					$data['img_center5'] = $image_center5_filename;
				}

				if ($_FILES['image_banner']['size'] !== 0) {
					$config['upload_path'] = './uploads/banners/'; 
					$config['allowed_types'] = 'jpg|png'; 
					$config['max_size']	= '600';
					$config['max_width']  = '1670';
					$config['max_height'] = '800'; 
					
					$this->load->library('upload', $config);
              		$this->upload->initialize($config);

					if ( ! $this->upload->do_upload('image_banner')) { 
						$this->session->set_flashdata('image_banner', '<br>
							<p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>');
						redirect('admin/hotel_pages/edit/'.$id);
					} else {
						$image_banner = $this->upload->data();
						$image_banner_filename = $image_banner['file_name'];	 
					}	
				}
				if (isset($image_banner)) {
					$data['img_banner'] = $image_banner_filename;
				}

				$data['header_text'] = $this->input->post('header_text'); 
				$data['header_text_en'] = $this->input->post('header_text_en'); 
				if ($this->input->post('active_banner_slider')) {
					$data['active_banner_slider'] = $this->input->post('active_banner_slider');  
				} 
				if ($this->input->post('active_content')) {
					$data['active_content'] = $this->input->post('active_content');  
				} 
				if ($this->input->post('active_gallery')) {
					$data['active_gallery'] = $this->input->post('active_gallery');  
				} 
				if ($this->input->post('active_all_product')) {
					$data['active_all_product'] = $this->input->post('active_all_product');  
				}    
				if ($this->input->post('active_map')) {
					$data['active_map'] = $this->input->post('active_map');  
				}   
				if ($this->input->post('active_contact')) {
					$data['active_contact'] = $this->input->post('active_contact');  
				}  
				if ($this->input->post('active_center_img')) {
					$data['active_center_img'] = $this->input->post('active_center_img');  
				}
				if ($this->input->post('active_3_contents_texts')) {
					$data['active_3_contents_texts'] = $this->input->post('active_3_contents_texts');  
				}
				
				$data['img_center_text1'] = $this->input->post('img_center_text1');
				$data['img_center_text1_en'] = $this->input->post('img_center_text1_en'); 
				$data['img_center_text2'] = $this->input->post('img_center_text2');
				$data['img_center_text2_en'] = $this->input->post('img_center_text2_en'); 
				$data['img_center_text3'] = $this->input->post('img_center_text3');
				$data['img_center_text3_en'] = $this->input->post('img_center_text3_en'); 
				$data['img_center_text4'] = $this->input->post('img_center_text4');
				$data['img_center_text4_en'] = $this->input->post('img_center_text4_en'); 
				$data['img_center_text5'] = $this->input->post('img_center_text5');
				$data['img_center_text5_en'] = $this->input->post('img_center_text5_en');

				$body_text1 = $this->input->post('body_text1');
				$body_text1_en = $this->input->post('body_text1_en');  
				$body_text2 = $this->input->post('body_text2');
				$body_text2_en = $this->input->post('body_text2_en');   
				$body_text3 = $this->input->post('body_text3');
				$body_text3_en = $this->input->post('body_text3_en');
				$header_body_text1 = $this->input->post('header_body_text1');
				$header_body_text1_en = $this->input->post('header_body_text1_en');
				$header_body_text2 = $this->input->post('header_body_text2');
				$header_body_text2_en = $this->input->post('header_body_text2_en');
				$header_body_text3 = $this->input->post('header_body_text3');
				$header_body_text3_en = $this->input->post('header_body_text3_en');
				// if ($body_text1) {
					$data['body_text1'] = $body_text1; 
					$data['body_text1_en'] = $body_text1_en;
					$data['body_text2'] = $body_text2; 
					$data['body_text2_en'] = $body_text2_en;
					$data['body_text3'] = $body_text3; 
					$data['body_text3_en'] = $body_text3_en; 
					$data['header_body_text1'] = $header_body_text1; 
					$data['header_body_text1_en'] = $header_body_text1_en;  
					$data['header_body_text2'] = $header_body_text2; 
					$data['header_body_text2_en'] = $header_body_text2_en;  
					$data['header_body_text3'] = $header_body_text3; 
					$data['header_body_text3_en'] = $header_body_text3_en; 
				}   
				$this->hotel_page_m->add_hotel_page($data); 
			// }

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

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

	function ajax_addnew_hotel_pages_static(){

		$page_title = $this->input->post('inp_page_title');
		$page_title_en = $this->input->post('inp_page_title_en');
		$body_text = $this->input->post('body_text');
		$body_text_en = $this->input->post('body_text_en');

		$current_priority = $this->db->select_max('priority')->from('hotel_pages')
		->where('parent', NULL)->get()->row()->priority;

		$priority = null;
		if($current_priority == NULL) {
			$priority = 1;	
		} else {
			$priority = $current_priority + 1;
		} 

		$data = array(
			'page_title' => $this->security->xss_clean($page_title),
			'page_title_en' => $this->security->xss_clean($page_title_en),
			'alias' => url_title($this->security->xss_clean($page_title)),
			'alias_en' => url_title($this->security->xss_clean($page_title_en)), 
			'body_text' => $body_text,
			'body_text_en' => $body_text_en, 
			'priority' => $this->security->xss_clean($priority),
		);
		
		$this->hotel_page_m->add_page($data); 

		$this_option_out = 
		'<option value="" data-title_idn="" data-title_eng="">
			-- Pilih --
		</option>'; 

		$query_hotel_pages = $this->db->get("hotel_pages")->result();
		foreach ($query_hotel_pages as $key) { 
			$this_option_out .= 
			"<option value='".$key->id_hotel_pages."' 
			  data-title_idn='".$key->page_title."' 
			  data-title_eng='".$key->page_title_en."'>".
			  ucwords($key->page_title.' / '.$key->page_title_en)
			."</option>"; 
		} 

		echo json_encode(array(
			"result"=>"sukses",
			"option_output"=>$this_option_out, 
		));
	}

	public function edit_gallery_image($hotel_pages_id = NULL,$id = NULL){
		$quer_hotel_pages_gallery = $this->db->get_where("hotel_pages_gallery",array(
			"id"=>$id,
			"id_pages"=>$hotel_pages_id,
		));
		
		if ($quer_hotel_pages_gallery->num_rows() == 0 && $hotel_pages_id != '24') { 
			show_404();
		}
		$quer_hotel_pages_gallery = $quer_hotel_pages_gallery->row();
		$this->data['hotel_pages_gallery'] = $quer_hotel_pages_gallery;
		$this->data['id_hotel_pages'] = $hotel_pages_id; 
		$this->data['id_gallery'] = $id;

		$config = array( 
				array(
				 'field'   => 'priority',
				 'label'   => 'Urutan Tampilan',
				 'rules'   => 'trim|required'
				),
				array(
				 'field'   => 'status',
				 'label'   => 'Status',
				 'rules'   => 'trim|required'
				),    
            );

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

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

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

				if ($_FILES['image1']['size'] !== 0) {  	
 
					$config['upload_path'] = './uploads/gallery/'; 
					$config['allowed_types'] = 'jpg|png'; 
					$config['max_size']	= '300';
					$config['max_width']  = '1000';
					$config['max_height'] = '700';
					$this->load->library('upload', $config);
              		$this->upload->initialize($config);

					if ( ! $this->upload->do_upload('image1')) { 
						$this->session->set_flashdata('image_error', '<br>
							<p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>');
						redirect('admin/hotel_pages/edit_gallery_image/'.$hotel_pages_id.'/'.$id);
					} else {
						$image1 = $this->upload->data();
						$image1_filename = $image1['file_name']; 
						$this->load->library('image_lib'); 
						
						//image resizing (SMALL IMAGE)
						$config2['image_library'] = 'gd2';
						$config2['source_image'] = './uploads/gallery/' . $image1_filename;
						$config2['new_image'] = './uploads/gallery/small/';
						$config2['create_thumb'] = FALSE;
						$config2['maintain_ratio'] = TRUE;
						$config2['width'] = '270';
						$config2['height'] = '189';
						$this->image_lib->initialize($config2);  //firstly autoload image_lib, then initialize it. Dont repeatly load it.
						$this->image_lib->resize();	
					}	
				}  

				$data = array(
					"priority"=>$this->security->xss_clean($this->input->post('priority')),
					"is_active"=>$this->security->xss_clean($this->input->post('status')),
				);

				//image upload
				if (isset($image1_filename)) {
					$data['img_name'] = $image1_filename;
				}else{
					$data['img_name'] = $this->data['hotel_pages_gallery']->img_name;
				} 

				$data['header_text'] = $this->security->xss_clean($this->input->post('header_text'));
				$data['header_text_en'] = $this->security->xss_clean($this->input->post('header_text_en'));
				$data['body_text'] = $this->input->post('body_text');
				$data['body_text_en'] = $this->input->post('body_text_en');

				$this->db->where("id_pages",$hotel_pages_id)
				->where('id', $id)->update('hotel_pages_gallery', $data); 
			} 

			$this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Edit Gallery Berhasil</p>');
			
			redirect('admin/hotel_pages/edit_gallery_image/'. $hotel_pages_id . '/' . $id);
		} 

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

	public function delete_all_gallery(){

		$checkbox_for_del = $this->input->post('checkbox_del');
		$id_hotel_pages = $this->input->post('id_hotel_pages');

		if (empty($checkbox_for_del)) {
			redirect('admin/hotel_pages/hotel_pages_gallery/' . $id_hotel_pages); 
		}

		for ($i=0; $i<count($checkbox_for_del) ; $i++) { 
			
			$id = $checkbox_for_del[$i];
			$this->db->where('id', $id);
			$this->db->delete('hotel_pages_gallery');
		}

		$this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Foto Gallery berhasil dihapus</p>');
		echo json_encode(array(
			'result'=>'sukses',
		));
	}

	function changeStatusActImages(){

    	$this_id = $this->input->post('this_id');
    	$toStat = $this->input->post('toStat');

    	$codeStat = null;
    	if ($toStat == "Ya") {
    		$codeStat = 'yes';
    	}else{
    		$codeStat = 'no'; 
    	}

    	$data = array(
    		"is_active" => $codeStat,
    	);

    	$upd = $this->db->update('hotel_pages_gallery', $data, array('id' => $this_id));

    	if ($upd) {
	    	echo json_encode(array(
	    		"res"=>"sukses",
	    	));
    	}

    }

	function refreshDisplayPriority_Gallery(){
    	$this_data = $this->input->post('this_data');

    	foreach ($this_data as $key) {
    		$u_data = array(
    			'priority'=>$key['val'],
    		);
    		$this->db->update('hotel_pages_gallery', $u_data, array('id' => $key['id']));
    	}

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

    	echo json_encode(array(
	    	"res"=>"sukses",
    		// "data"=>$this_data,
    	));
    }

    public function delete_gallery_image($id_hotel_pages = NULL, $id = NULL){
    	if (empty($id_hotel_pages) || empty($id)) {
			redirect('admin/hotel_pages/hotel_pages_gallery/' .$id_hotel_pages.'/'. $id); 
		}

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

		$this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Foto Gallery berhasil dihapus</p>');
		redirect('admin/hotel_pages/hotel_pages_gallery/' .$id_hotel_pages.'/'. $id); 
    }

	public function add_gallery_image($hotel_pages_id = NULL){

		$quer_hotel_pages_gallery = $this->db->get_where("hotel_pages_gallery",array( 
			"id_pages"=>$hotel_pages_id,
		));
		
		// if ($quer_hotel_pages_gallery->num_rows() == 0 && $hotel_pages_id != '24') { 
		// 	show_404();
		// }

		// $quer_hotel_pages_gallery = new stdClass();
		// $quer_hotel_pages_gallery->img_name = ''; 
		// $quer_hotel_pages_gallery->status = 'yes';
		// $quer_hotel_pages_gallery->priority = ''; 
		$this->data['hotel_pages_gallery'] = $this->hotel_page_m->get_new();

		// $this->data['hotel_pages_gallery'] = $quer_hotel_pages_gallery;
		$this->data['id_hotel_pages'] = $hotel_pages_id;  

		$config = array( 
				array(
				 'field'   => 'status',
				 'label'   => 'Status',
				 'rules'   => 'trim|required'
				),    
            );

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

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

			if($_POST) {

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

					$config['upload_path'] = './uploads/gallery/'; 
					$config['allowed_types'] = 'jpg|png'; 
                    $config['max_size']	= '500';
                    $config2['width'] = '1170';
                    $config2['height'] = '600';
					
					$this->load->library('upload', $config);
              		$this->upload->initialize($config);

					if ( ! $this->upload->do_upload('image1')) { 
						$this->session->set_flashdata('image_error', '<br>
							<p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>');
						redirect('admin/hotel_pages/add_gallery_image/'.$hotel_pages_id);
					} else {
						$image1 = $this->upload->data();
						$image1_filename = $image1['file_name']; 

						$this->load->library('image_lib'); 
						
						//image resizing (SMALL IMAGE)
						$config2['image_library'] = 'gd2';
						$config2['source_image'] = './uploads/gallery/' . $image1_filename;
						$config2['new_image'] = './uploads/gallery/small/';
						$config2['create_thumb'] = FALSE;
						$config2['maintain_ratio'] = TRUE;
						$config['max_width']  = '270';
					    $config['max_height'] = '191';
						$this->image_lib->initialize($config2);  //firstly autoload image_lib, then initialize it. Dont repeatly load it.
						$this->image_lib->resize();	
					}	
				}  

				$data = array(
					"priority"=>$this->security->xss_clean($this->input->post('priority')),
					"is_active"=>$this->security->xss_clean($this->input->post('status')),
					"id_pages"=>$hotel_pages_id,
				);

				//image upload
				if (isset($image1_filename)) {
					$data['img_name'] = $image1_filename;
				}else{
					$data['img_name'] = $this->data['hotel_pages_gallery']->img_name;
				} 

				$data['header_text'] = $this->security->xss_clean($this->input->post('header_text'));
				$data['header_text_en'] = $this->security->xss_clean($this->input->post('header_text_en'));
				$data['body_text'] = $this->input->post('body_text');
				$data['body_text_en'] = $this->input->post('body_text_en');

				$this->db->insert('hotel_pages_gallery', $data); 
			} 

			$this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Edit Gallery Berhasil</p>');
			
			redirect('admin/hotel_pages/hotel_pages_gallery/'. $hotel_pages_id);
		} 

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

	public function hotel_pages_gallery($id = NULL) {

		//check if id exist. If not exist, show 404.
		$count = $this->hotel_page_m->count_exist($id);
		
		if ($count == 0 && $id != '24') {
			//page not exist
			show_404();
		}
		$this->data['hotel_pages'] = $this->hotel_page_m->get($id);

		//pagination in action. 100 results per page
		$this->load->library('pagination');
		$config['base_url'] = base_url() . 'admin/hotel_pages/edit_gallery';
		$config['per_page'] = 100;
		$config['uri_segment'] = 3; 

		$this->db->select('id')->from('hotel_pages_gallery')->where('id_pages', $id);
		$config['total_rows'] = $this->db->get()->num_rows();
		$this->pagination->initialize($config);

		$this->db->select('*');
		$this->db->from('hotel_pages_gallery');
		$this->db->where('id_pages', $id);
		$this->db->order_by('priority', 'ASC');
		$this->db->limit($config['per_page'], $this->uri->segment($config['uri_segment']));

		$this->data['hotel_pages_gallery'] = $this->db->get()->result();	

		$this->data['id_hotel_pages'] = $id; 

		//load view
		$this->data['subview'] = 'admin/hotel_pages/hotel_pages_gallery';
		$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 page in admin
	public function edit($id = NULL) {

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

		$this->data['hotel_pages'] = $this->hotel_page_m->get($id);
		$this->data['parent_hotel_pages'] = $this->hotel_page_m->get_parent_hotel_pages();
		$this->page_current_id = (int) $id;	
		
		//validation check in action 
		$config = $this->hotel_page_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) {
			
			$data = $this->table_data_processing($this->input->post('page_title'), $this->input->post('page_title_en'), $this->input->post('status'), $this->input->post('body_text'), $this->input->post('body_text_en'), $this->input->post('meta_description'), $this->input->post('meta_keywords'));

			$this->hotel_page_m->edit_hotel_page($id, $data);

			if($_POST) {

				//check & processing image banner upload files	
				if ($_FILES['image1']['size'] !== 0) {  	
 
					$config['upload_path'] = './uploads/banners/'; 
					$config['allowed_types'] = 'jpg|png'; 
					$config['max_size']	= '600';
					$config['max_width']  = '1670';
					$config['max_height'] = '800';
					
					$this->load->library('upload', $config);
              		$this->upload->initialize($config);

					if ( ! $this->upload->do_upload('image1')) { 
						$this->session->set_flashdata('error1', '<br>
							<p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>');
						redirect('admin/hotel_pages/edit/'.$id);
					} else {
						$image1 = $this->upload->data();
						$image1_filename = $image1['file_name']; 
						// $this->resize_single_image('580','500','home_about/',$image1_filename);	 
					}	
				}
				if ($_FILES['image2']['size'] !== 0) { 
					$config['upload_path'] = './uploads/banners/'; 
					$config['allowed_types'] = 'jpg|png'; 
					$config['max_size']	= '600';
					$config['max_width']  = '1670';
					$config['max_height'] = '800';
					
					$this->load->library('upload', $config);
              		$this->upload->initialize($config);

					if ( ! $this->upload->do_upload('image2')) { 
						$this->session->set_flashdata('error2', '<br>
							<p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>');
						redirect('admin/hotel_pages/edit/'.$id);
					} else {
						$image2 = $this->upload->data();
						$image2_filename = $image2['file_name']; 
						// $this->resize_single_image('580','500','home_about/',$image2_filename);	 
					}	
				}
				if ($_FILES['image3']['size'] !== 0) {
					$config['upload_path'] = './uploads/banners/'; 
					$config['allowed_types'] = 'jpg|png'; 
					$config['max_size']	= '600';
					$config['max_width']  = '1670';
					$config['max_height'] = '800';
					
					$this->load->library('upload', $config);
              		$this->upload->initialize($config);

					if ( ! $this->upload->do_upload('image3')) { 
						$this->session->set_flashdata('error3', '<br>
							<p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>');
						redirect('admin/hotel_pages/edit/'.$id);
					} else {
						$image3 = $this->upload->data();
						$image3_filename = $image3['file_name']; 
						// $this->resize_single_image('580','500','home_about/',$image3_filename);	 
					}	
				} 
 

				$data = array();

				//image upload
				if (isset($image1_filename)) {
					$data['img_name'] = $image1_filename;
				}else{
					$data['img_name'] = @explode(' | ', $this->data['hotel_pages']->img_name)[0];
				}

				//image upload
				if (isset($image2_filename)) {
					$data['img_name'] .= ' | '.$image2_filename;
				}else{
					$data['img_name'] .= ' | '.@explode(' | ', $this->data['hotel_pages']->img_name)[1];
				}

				//image upload
				if (isset($image3_filename)) {
					$data['img_name'] .= ' | '.$image3_filename;
				}else{
					$data['img_name'] .= ' | '.@explode(' | ', $this->data['hotel_pages']->img_name)[2];
				}

				if ($_FILES['image_center1']['size'] !== 0) {
					$config['upload_path'] = './uploads/image_center/'; 
					$config['allowed_types'] = 'jpg|png'; 
					$config['max_size']	= '300';
					$config['max_width']  = '570';
					$config['max_height'] = '290';  
					
					$this->load->library('upload', $config);
              		$this->upload->initialize($config);

					if ( ! $this->upload->do_upload('image_center1')) { 
						$this->session->set_flashdata('image_center1', '<br>
							<p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>');
						redirect('admin/hotel_pages/edit/'.$id);
					} else {
						$image_center1 = $this->upload->data();
						$image_center1_filename = $image_center1['file_name'];	 
					}	
				}
				if (isset($image_center1)) {
					$data['img_center1'] = $image_center1_filename;
				}

				if ($_FILES['image_center2']['size'] !== 0) {
					$config['upload_path'] = './uploads/image_center/'; 
					$config['allowed_types'] = 'jpg|png'; 
					$config['max_size']	= '300';
					$config['max_width']  = '570';
					$config['max_height'] = '290';  
					
					$this->load->library('upload', $config);
              		$this->upload->initialize($config);

					if ( ! $this->upload->do_upload('image_center2')) { 
						$this->session->set_flashdata('image_center2', '<br>
							<p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>');
						redirect('admin/hotel_pages/edit/'.$id);
					} else {
						$image_center2 = $this->upload->data();
						$image_center2_filename = $image_center2['file_name'];	 
					}	
				}
				if (isset($image_center2)) {
					$data['img_center2'] = $image_center2_filename;
				}

				if ($_FILES['image_center3']['size'] !== 0) {
					$config['upload_path'] = './uploads/image_center/'; 
					$config['allowed_types'] = 'jpg|png'; 
					$config['max_size']	= '300';
					$config['max_width']  = '570';
					$config['max_height'] = '290';  
					
					$this->load->library('upload', $config);
              		$this->upload->initialize($config);

					if ( ! $this->upload->do_upload('image_center3')) { 
						$this->session->set_flashdata('image_center3', '<br>
							<p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>');
						redirect('admin/hotel_pages/edit/'.$id);
					} else {
						$image_center3 = $this->upload->data();
						$image_center3_filename = $image_center3['file_name'];	 
					}	
				}
				if (isset($image_center3)) {
					$data['img_center3'] = $image_center3_filename;
				}
				if ($_FILES['image_center4']['size'] !== 0) {
					$config['upload_path'] = './uploads/image_center/'; 
					$config['allowed_types'] = 'jpg|png'; 
					$config['max_size']	= '300';
					$config['max_width']  = '570';
					$config['max_height'] = '290'; 
					
					$this->load->library('upload', $config);
              		$this->upload->initialize($config);

					if ( ! $this->upload->do_upload('image_center4')) { 
						$this->session->set_flashdata('image_center4', '<br>
							<p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>');
						redirect('admin/hotel_pages/edit/'.$id);
					} else {
						$image_center4 = $this->upload->data();
						$image_center4_filename = $image_center4['file_name'];	 
					}	
				}
				if (isset($image_center4)) {
					$data['img_center4'] = $image_center4_filename;
				}
				if ($_FILES['image_center5']['size'] !== 0) {
					$config['upload_path'] = './uploads/image_center/'; 
					$config['allowed_types'] = 'jpg|png'; 
					$config['max_size']	= '300';
					$config['max_width']  = '570';
					$config['max_height'] = '290';  
					
					$this->load->library('upload', $config);
              		$this->upload->initialize($config);

					if ( ! $this->upload->do_upload('image_center5')) { 
						$this->session->set_flashdata('image_center5', '<br>
							<p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>');
						redirect('admin/hotel_pages/edit/'.$id);
					} else {
						$image_center5 = $this->upload->data();
						$image_center5_filename = $image_center5['file_name'];	 
					}	
				}
				if (isset($image_center5)) {
					$data['img_center5'] = $image_center5_filename;
				}

				if ($_FILES['image_banner']['size'] !== 0) {
					$config['upload_path'] = './uploads/banners/'; 
					$config['allowed_types'] = 'jpg|png'; 
					$config['max_size']	= '600';
					$config['max_width']  = '1670';
					$config['max_height'] = '800'; 
					
					$this->load->library('upload', $config);
              		$this->upload->initialize($config);

					if ( ! $this->upload->do_upload('image_banner')) { 
						$this->session->set_flashdata('image_banner', '<br>
							<p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>');
						redirect('admin/hotel_pages/edit/'.$id);
					} else {
						$image_banner = $this->upload->data();
						$image_banner_filename = $image_banner['file_name'];	 
					}	
				}
				if (isset($image_banner)) {
					$data['img_banner'] = $image_banner_filename;
				}

				$data['header_text'] = $this->input->post('header_text'); 
				$data['header_text_en'] = $this->input->post('header_text_en'); 
				if ($this->input->post('active_banner_slider')) {
					$data['active_banner_slider'] = $this->input->post('active_banner_slider');  
				} 
				if ($this->input->post('active_content')) {
					$data['active_content'] = $this->input->post('active_content');  
				} 
				if ($this->input->post('active_gallery')) {
					$data['active_gallery'] = $this->input->post('active_gallery');  
				} 
				if ($this->input->post('active_all_product')) {
					$data['active_all_product'] = $this->input->post('active_all_product');  
				}    
				if ($this->input->post('active_map')) {
					$data['active_map'] = $this->input->post('active_map');  
				}   
				if ($this->input->post('active_contact')) {
					$data['active_contact'] = $this->input->post('active_contact');  
				}  
				if ($this->input->post('active_center_img')) {
					$data['active_center_img'] = $this->input->post('active_center_img');  
				}
				if ($this->input->post('active_3_contents_texts')) {
					$data['active_3_contents_texts'] = $this->input->post('active_3_contents_texts');  
				}
				
				$data['img_center_text1'] = $this->input->post('img_center_text1');
				$data['img_center_text1_en'] = $this->input->post('img_center_text1_en'); 
				$data['img_center_text2'] = $this->input->post('img_center_text2');
				$data['img_center_text2_en'] = $this->input->post('img_center_text2_en'); 
				$data['img_center_text3'] = $this->input->post('img_center_text3');
				$data['img_center_text3_en'] = $this->input->post('img_center_text3_en'); 
				$data['img_center_text4'] = $this->input->post('img_center_text4');
				$data['img_center_text4_en'] = $this->input->post('img_center_text4_en'); 
				$data['img_center_text5'] = $this->input->post('img_center_text5');
				$data['img_center_text5_en'] = $this->input->post('img_center_text5_en'); 

				$body_text1 = $this->input->post('body_text1');
				$body_text1_en = $this->input->post('body_text1_en');  
				$body_text2 = $this->input->post('body_text2');
				$body_text2_en = $this->input->post('body_text2_en');   
				$body_text3 = $this->input->post('body_text3');
				$body_text3_en = $this->input->post('body_text3_en');

				$header_body_text1 = $this->input->post('header_body_text1');
				$header_body_text1_en = $this->input->post('header_body_text1_en');
				$header_body_text2 = $this->input->post('header_body_text2');
				$header_body_text2_en = $this->input->post('header_body_text2_en');
				$header_body_text3 = $this->input->post('header_body_text3');
				$header_body_text3_en = $this->input->post('header_body_text3_en');
				// if ($body_text1) {
					$data['body_text1'] = $body_text1; 
					$data['body_text1_en'] = $body_text1_en;
					$data['body_text2'] = $body_text2; 
					$data['body_text2_en'] = $body_text2_en;
					$data['body_text3'] = $body_text3; 
					$data['body_text3_en'] = $body_text3_en; 
					$data['header_body_text1'] = $header_body_text1; 
					$data['header_body_text1_en'] = $header_body_text1_en;  
					$data['header_body_text2'] = $header_body_text2; 
					$data['header_body_text2_en'] = $header_body_text2_en;  
					$data['header_body_text3'] = $header_body_text3; 
					$data['header_body_text3_en'] = $header_body_text3_en; 
				// }    

				$this->db->where('id_hotel_pages', $id)->where('hotel_id',$this->session->userdata('hotel_id'))->update('hotel_pages', $data);
				
			} 

			$this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Edit Halaman Berhasil</p>');
			
			redirect('admin/hotel_pages/edit/' . $id);
		} 
		
		$this->data['subview'] = 'admin/hotel_pages/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 page
	public function delete($id) {

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

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


	//callback function validation add new hotel_pages
	public function _cek_existing_page_title($str) {

		$num_rows = $this->hotel_page_m->cek_existing_page_title($str, $this->page_current_id);   
		if ($num_rows != 0 ) { 
			$this->form_validation->set_message('_cek_existing_page_title', 'Judul halaman indonesia sudah ada !'); 
			return FALSE;
		} else {
			return TRUE;     
		}
	}

	//callback function validation add new hotel_pages
	public function _cek_existing_page_en_title($str) {

		$num_rows = $this->hotel_page_m->cek_existing_page_en_title($str, $this->page_current_id);   
		if ($num_rows != 0 ) { 
			$this->form_validation->set_message('_cek_existing_page_en_title', 'Judul halaman bahasa Inggris sudah ada !'); 
			return FALSE;
		} else {
			return TRUE;     
		}
	}

	private function table_data_processing($page_title, $page_title_en, $status, $body_text, $body_text_en,
		$meta_description, $meta_keywords) {

		$data = array(
			'page_title' => $this->security->xss_clean($page_title),
			'page_title_en' => $this->security->xss_clean($page_title_en),
			'alias' => url_title($this->security->xss_clean($page_title)),
			'alias_en' => url_title($this->security->xss_clean($page_title_en)),
			'status' => $status,
			'body_text' => $body_text,
			'body_text_en' => $body_text_en,
			'meta_description' => $this->security->xss_clean($meta_description),
			'meta_keywords' => $this->security->xss_clean($meta_keywords),
            'priority' => $this->security->xss_clean($this->input->post('priority')),
            'img_descr' => $this->security->xss_clean($this->input->post('img_descr')),
			'img_descr_en' => $this->security->xss_clean($this->input->post('img_descr_en')),
            'hotel_id' => $this->session->userdata('hotel_id')
		);

		if ($this->input->post('parent_id') == 'no-parent') {
			$data['parent'] = NULL;
		} else {
			$data['parent'] = (int) $this->input->post('parent_id');
		}

		return $data;
	}

	
		
}

https://t.me/RX1948 - 2025