whoami7 - Manager
:
/
proc
/
self
/
root
/
home
/
papecmvm
/
public_html
/
application
/
controllers
/
admin
/
Upload File:
files >> //proc/self/root/home/papecmvm/public_html/application/controllers/admin/Setting.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); ob_start(); class Setting extends CI_Controller { function __construct() { parent::__construct(); $this->load->model('alldata', "model"); $session_data=$this->session->all_userdata(); if(count($session_data)==5) { redirect('admin/starlogin'); } } public function index() { $data['view']=$this->model->setting_model(); $this->load->view("setting/setting",$data); } //------ START: INSERT FUNCTION ------------------------------ public function add_setting(){ if($this->input->post('save')=='save'){ //---------------- STRAT: UPLOAD IMAGE ------------------- $filenm=$_FILES["image_name"]["name"]; if($filenm!=""){ $config['upload_path'] ='./bootstrap/images/'; // folder name where you wnat to upload the image // $config['allowed_types'] = 'gif|jpg|png|jpeg'; $this->upload->initialize($config); if (!$this->upload->do_upload('image_name')){ $error = array('error' => $this->upload->display_errors()); } else { $data = array('upload_data' => $this->upload->data()); $image_name=$data['upload_data']['file_name']; } }else{ $image_name=""; } //---------------- END : UPLOAD IMAGE -------------------- $insertdata= array( 'other_cat'=>$this->input->post('other_cat'), 'other_title'=>$this->input->post('other_title'), 'other_text'=>$this->input->post('other_text'), 'other_link'=>$this->input->post('other_link'), 'other_icon'=>$this->input->post('other_icon'), 'social_link'=>$this->input->post('social_link'), 'other_image'=>$image_name, 'other_position'=>$this->input->post('other_position') //'other_bgclr'=>$this->input->post('other_bgclr'), //'other_clr'=>$this->input->post('other_clr') ); $this->model->insertData('tbl_other_detail',$insertdata); $this->session->set_flashdata('msg', ' <div class="alert alert-success alert-dismissible" role="alert"> <button type="button" class="close" data-dismiss="alert" aria-label="Close"> <span aria-hidden="true">×</span></button> <strong>Success!</strong> Insert data successfully . </div>'); redirect('admin/setting'); }else{ $data['pageData']=$this->model->DetailData('tblcontent',array('publish'=>'on')); $this->load->view("setting/setting_add",$data); } } //------ END: INSERT FUNCTION ------------------------------ //------ START: EDIT FUNCTION ------------------------------ public function edit_setting($encrypted_string){ $id = $this->model->decryptdata($encrypted_string); $where=array('other_id'=>$id); if($this->input->post('save')=='save'){ //---------------- STRAT: UPLOAD IMAGE ------------------- $hidden_photo= $this->input->post("hidden_photo"); $newfile=$_FILES["image_name"]["name"]; if($newfile!=""){ //---- Unlink image ------ if (file_exists("./bootstrap/images/".$hidden_photo)){ // file_exists : chk if file is exist or not unlink("bootstrap/images/".$hidden_photo); // unlink image } $config['upload_path'] ='./bootstrap/images/'; // folder name where you wnat to upload the image // $config['allowed_types'] = 'gif|jpg|png|jpeg'; $this->upload->initialize($config); if (!$this->upload->do_upload('image_name')){ $error = array('error' => $this->upload->display_errors()); } else { $data = array('upload_data' => $this->upload->data()); $image_name=$data['upload_data']['file_name']; } }else{ $image_name=$hidden_photo; } //---------------- END : UPLOAD IMAGE -------------------- $Updatedata=array( 'other_cat'=>$this->input->post('other_cat'), 'other_title'=>$this->input->post('other_title'), 'other_text'=>$this->input->post('other_text'), 'other_link'=>$this->input->post('other_link'), 'other_icon'=>$this->input->post('other_icon'), 'social_link'=>$this->input->post('social_link'), 'other_image'=>$image_name, 'other_position'=>$this->input->post('other_position') //'other_bgclr'=>$this->input->post('other_bgclr'), //'other_clr'=>$this->input->post('other_clr') ); // echo "<pre>"; //print_r($Updatedata); //die; $this->model->UpdateData('tbl_other_detail',$Updatedata,$where); $this->session->set_flashdata('msg', ' <div class="alert alert-success alert-dismissible" role="alert"> <button type="button" class="close" data-dismiss="alert" aria-label="Close"> <span aria-hidden="true">×</span></button> <strong>Success!</strong> Update data successfully . </div>'); redirect('admin/setting'); }else{ $data['view']=$this->model->DetailData('tbl_other_detail',$where); $data['pageData']=$this->model->DetailData('tblcontent',array('publish'=>'on')); $this->load->view("setting/setting_add",$data); } } //------ END: EDIT FUNCTION ------------------------------ //------ START: DELETE FUNCTION ------------------------------ public function delete_setting(){ $chk = $this->input->post('ck'); $n=count($chk); for($i=0;$i<$n;$i++) { $ency_id=$chk[$i]; $id = $this->model->decryptdata($ency_id); $where=array('other_id'=>$id); //---------- UNLINK IMAGE ----------------------- $getimages=$this->model->DetailData('tbl_other_detail',$where); unlink("bootstrap/images/".$getimages[$i]['other_image']); //---------- UNLINK IMAGE ----------------------- $this->model->DeleteData('tbl_other_detail',$where); } $this->session->set_flashdata('msg', ' <div class="alert alert-success alert-dismissible" role="alert"> <button type="button" class="close" data-dismiss="alert" aria-label="Close"> <span aria-hidden="true">×</span></button> <strong>Success!</strong> Delete data successfully . </div>'); redirect('admin/setting'); } //------ END: DELETE FUNCTION ------------------------------- } /* End of file services.php */
Copyright ©2021 || Defacer Indonesia