whoami7 - Manager
:
/
proc
/
self
/
root
/
home
/
papecmvm
/
www
/
application
/
controllers
/
admin
/
Upload File:
files >> //proc/self/root/home/papecmvm/www/application/controllers/admin/Postmanagement.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); ob_start(); class Postmanagement extends CI_Controller { function __construct() { parent::__construct(); $this->load->model('alldata','model'); } public function index() { $session_data=$this->session->all_userdata(); $lang=$session_data['lang']; $this->db->order_by("tblpost_id", "desc"); $this->db->select('*'); $this->db->from($lang.'tblposts'); $this->db->join('tblusers', $lang.'tblposts.user_id = tblusers.uid','left'); $content['view'] = $this->db->get()->result_array(); $this->load->view("posts/posts_view",$content); } public function addpost() { $session_data=$this->session->all_userdata(); $lang=$session_data['lang']; if($this->input->post('save')=='save') { $path_parts = pathinfo($_FILES["photo"]["name"]); $extension = $path_parts['extension']; //echo $extension; $contenthead = $this->input->post('contenthead'); //print_r($contenthead); die; $chead=implode('|-|',$contenthead); $pagecontent = $this->input->post('myeditor'); //print_r($pagecontent); die; $content=implode('|-|',$pagecontent); //echo($content); die; $config['upload_path'] = './banners/'; $config['allowed_types']= 'gif|jpg|png'; $this->upload->initialize($config); $this->load->library('upload', $config); $this->upload->do_upload('photo'); $data = $this->upload->data(); $name_array='banners/'.$data['file_name']; /* $this->load->library('image_lib'); $config['image_library'] = 'gd2'; $config['source_image'] = $name_array; $config['create_thumb'] = FALSE; $config['maintain_ratio'] = TRUE; $config['width'] = 400; $this->image_lib->clear(); $this->image_lib->initialize($config); $this->image_lib->resize();*/ $title=$this->input->post('titlepost'); $data['tblposts']=$this->model->getDatamodel($lang.'tblposts'); $slug=str_replace(' ', '-', $title); $checkslg=0; foreach ($data['tblposts'] as $key) { if ($key['post_slug']==$slug) { $slug=str_replace(' ', '-', $title).'-'.$checkslg++; } } $newDate = date("Y-m-d", strtotime($this->input->post('post_date'))); $insetcontent=array('titlepost'=>$this->input->post('titlepost'), 'content_head'=>$chead, 'contentpost'=>$content, 'post_cat'=>$this->input->post('post_cat'), 'user_id'=>$session_data['userinfo'][0]['uid'], 'modified_time'=>date('Y-m-d h:m:s'), 'imagepath'=>$name_array, 'post_slug'=>$slug, 'post_date'=>$newDate ); $this->form_validation->set_rules('titlepost', 'titlepost', 'required|xss_clean|regex_match[/^[^\`\~\@\#\$\%\^\*\[\]\{\}\;:<>=+"]+$/]'); if ($this->form_validation->run() == TRUE) { $this->model->insertData($lang.'tblposts',$insetcontent); } /* $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> Post Data successfully Insert. </div>'); */ redirect('admin/postmanagement'); } else { $this->load->view("posts/post_add"); } } public function editpostData($encrypted_string) { $session_data=$this->session->all_userdata(); $lang=$session_data['lang']; $id = $this->model->decryptdata($encrypted_string); $where=array('tblpost_id'=>$id); if($this->input->post('save')=='save') { $contenthead = $this->input->post('contenthead'); $chead=implode('|-|',$contenthead); $pagecontent = $this->input->post('myeditor'); $content=implode('|-|',$pagecontent); //print_r($content); die; $config['upload_path'] = './banners/'; $config['allowed_types']= 'gif|jpg|png'; $this->upload->initialize($config); $this->load->library('upload', $config); $this->upload->do_upload('photo'); $data = $this->upload->data(); $session_data=$this->session->all_userdata(); $name_array='banners/'.$data['file_name']; $title=$this->input->post('titlepost'); $data['tblposts']=$this->model->getDatamodel($lang.'tblposts'); $slug=str_replace(' ', '-', $title); $checkslg=0; foreach ($data['tblposts'] as $key) { if ($key['post_slug']==$slug) { $slug=str_replace(' ', '-', $title).'-'.$checkslg++; } } $newDate = date("Y-m-d", strtotime($this->input->post('post_date'))); if ($data['file_name']=='') { $insetcontent=array('titlepost'=>$this->input->post('titlepost'), 'content_head'=>$chead, 'contentpost'=>$content, 'post_cat'=>$this->input->post('post_cat'), 'user_id'=>$session_data['userinfo'][0]['uid'], 'modified_time'=>date('Y-m-d h:m:s'), 'post_date'=>$newDate, //'post_slug'=>$slug, ); } else { $insetcontent=array('titlepost'=>$this->input->post('titlepost'), 'content_head'=>$chead, 'contentpost'=>$content, 'post_cat'=>$this->input->post('post_cat'), 'user_id'=>$session_data['userinfo'][0]['uid'], 'modified_time'=>date('Y-m-d h:m:s'), 'post_date'=>$newDate, 'post_slug'=>$slug, 'imagepath'=>$name_array ); } $this->form_validation->set_rules('titlepost', 'titlepost', 'required|xss_clean|regex_match[/[^\`\~\@\#\$\%\^\*\[\]\{\}\;:<>=+"]+$/]'); if ($this->form_validation->run() == TRUE) { $this->model->UpdateData($lang.'tblposts',$insetcontent,$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> Post Data successfully Edit. </div>'); */ redirect('admin/postmanagement'); } else { $this->db->select('*'); $this->db->from($lang.'tblposts'); $this->db->where($where); $data['view']= $this->db->get()->result_array(); $this->load->view("posts/post_add",$data); } } public function deletepostselected() { $ids=explode('&',$this->input->post('ck')); $session_data=$this->session->all_userdata(); $lang=$session_data['lang']; $where = array(); for ($i=0; $i < count($ids); $i++) { $id=explode('=',$ids[$i]); $where = array('tblpost_id'=>$id[1]); $getbanner=$this->model->DetailData($lang.'tblposts',$where); unlink($getbanner[0]['imagepath']); $this->model->deleteData($lang.'tblposts',$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> Post Data successfully Delete. </div>'); */ redirect('admin/postmanagement'); } }
Copyright ©2021 || Defacer Indonesia