whoami7 - Manager
:
/
proc
/
self
/
root
/
home
/
papecmvm
/
www
/
application
/
controllers
/
admin
/
Upload File:
files >> //proc/self/root/home/papecmvm/www/application/controllers/admin/Portfolio.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); ob_start(); error_reporting(0); class Portfolio 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->portfolio_model(); $this->load->view("portfolio/portfolio",$data); } //------ START: INSERT FUNCTION ------------------------------ public function add_portfolio(){ $session_data=$this->session->all_userdata(); $lang=$session_data['lang']; if($this->input->post('save')=='save'){ //echo $this->input->post('port_sub_cat'); die; $path_parts = pathinfo($_FILES["image_name"]["name"]); //echo $extension; die; /*if($extension != 'jpg' && $extension != 'png' && $extension != 'jpeg' && $extension != 'gif'){ //error $this->session->set_flashdata('msg', '<div class="alert alert-dismissible" role="alert" style="color: #a94442;background-color: #f2dede;border-color: #ebccd1;"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button><strong>Error : </strong> Something went wrong...!</div>'); redirect('admin/portfolio'); }else{ */ //---------------- STRAT: UPLOAD IMAGE ------------------- $filenm=$_FILES["image_name"]["name"]; if($filenm!=""){ $config['upload_path'] ='./portfolio_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 -------------------- //echo $this->input->post('portfolio_name'); die; $insertdata= array( 'portfolio_name'=>$this->input->post('portfolio_name'), 'prot_desc'=>$this->input->post('portfolio_Desc'), 'portfolio_cat_id'=>$this->input->post('portfolio_cat_id'), 'port_sub_cat'=>$this->input->post('port_sub_cat'), 'portfolio_image_path'=>$image_name, 'banner_id'=>$this->input->post('banner_id'), 'portfolio_video_path'=>$this->input->post('portfolio_video_path'), 'portfolio_link'=>$this->input->post('portfolio_link') ); $this->form_validation->set_rules('portfolio_name', 'portfolio_name', 'required|xss_clean|regex_match[/^[^\`\~\@\#\$\%\^\*\[\]\{\}\;:<>=+"]+$/]'); if ($this->form_validation->run() == TRUE) { $this->model->insertData($lang.'tbl_portfolio',$insertdata); } else{ echo 'error'; die; } /* $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/portfolio'); //} }else{ $data['bannergrid']=$this->model->getDatamodel('tblbanners'); $data['portfolio_category']=$this->model->getDatamodel('tbl_portfolio_category'); $this->load->view("portfolio/portfolio_add",$data); } } //------ END: INSERT FUNCTION ------------------------------ //------ START: EDIT FUNCTION ------------------------------ public function edit_portfolio($encrypted_string){ $session_data=$this->session->all_userdata(); $lang=$session_data['lang']; $id = $this->model->decryptdata($encrypted_string); $where=array('portfolio_id'=>$id); if($this->input->post('save')=='save'){ //$where=array('portfolio_id'=>$id); //---------------- STRAT: UPLOAD IMAGE ------------------- $hidden_photo= $this->input->post("hidden_photo"); $newfile=$_FILES["image_name"]["name"]; if($newfile!=""){ //---- Unlink image ------ if (file_exists("./portfolio_images/".$hidden_photo)){ // file_exists : chk if file is exist or not unlink("portfolio_images/".$hidden_photo); // unlink image } $config['upload_path'] ='./portfolio_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( 'portfolio_name'=>$this->input->post('portfolio_name'), 'prot_desc'=>$this->input->post('portfolio_Desc'), 'portfolio_cat_id'=>$this->input->post('portfolio_cat_id'), 'port_sub_cat'=>$this->input->post('port_sub_cat'), 'portfolio_image_path'=>$image_name, 'portfolio_video_path'=>$this->input->post('portfolio_video_path'), 'portfolio_link'=>$this->input->post('portfolio_link') ); // echo "<pre>"; //print_r($Updatedata); //die; $this->model->UpdateData($lang.'tbl_portfolio',$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/portfolio'); }else{ $data['bannergrid']=$this->model->getDatamodel('tblbanners'); $data['portfolio_category']=$this->model->getDatamodel('tbl_portfolio_category'); $data['sub_cat']=$this->model->getDatamodel('tbl_port_sub_cat'); $data['view']=$this->model->DetailData($lang.'tbl_portfolio',$where); $this->load->view("portfolio/portfolio_add",$data); } } public function subfun($id){ $inv=$this->input->post('inv'); $where=array('pid'=>$id); $sub=$this->model->DetailData('tbl_port_sub_cat',$where); echo ' <option value=""> --SELECT-- </option>'; foreach($sub as $key){ if($inv!="" && $inv==$key['ven_inv_num']){ echo '<option value="'.$key['psid'].'" selected>'.$key['ps_name'].'</option>'; }else{ echo '<option value="'.$key['psid'].'">'.$key['ps_name'].'</option>'; } } } //------ END: EDIT FUNCTION ------------------------------ //------ START: DELETE FUNCTION ------------------------------ public function delete_portfolio(){ $session_data=$this->session->all_userdata(); $lang=$session_data['lang']; $ids=explode('&',$this->input->post('ck')); $n=count($ids); for($i=0;$i<$n;$i++) { $id=explode('=',$ids[$i]); $where=array('portfolio_id'=>$id[1]); //---------- UNLINK IMAGE ----------------------- $getimages=$this->model->DetailData('tbl_portfolio',$where); unlink("portfolio_images/".$getimages[$i]['portfolio_image_path']); //---------- UNLINK IMAGE ----------------------- $this->model->DeleteData($lang.'tbl_portfolio',$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/portfolio'); } //------ END: DELETE FUNCTION ------------------------------- } /* End of file services.php */
Copyright ©2021 || Defacer Indonesia