%PDF- <> %âãÏÓ endobj 2 0 obj <> endobj 3 0 obj <>/ExtGState<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] >>/Annots[ 28 0 R 29 0 R] /MediaBox[ 0 0 595.5 842.25] /Contents 4 0 R/Group<>/Tabs/S>> endobj ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<> endobj 2 0 obj<>endobj 2 0 obj<>es 3 0 R>> endobj 2 0 obj<> ox[ 0.000000 0.000000 609.600000 935.600000]/Fi endobj 3 0 obj<> endobj 7 1 obj<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]>>/Subtype/Form>> stream
<?php defined('BASEPATH') OR exit('No direct script access allowed'); class Media extends CI_Controller { function __construct() { parent::__construct(); if((!isset($_SESSION['is_logged']))||($_SESSION['is_logged']==false)) { $_SESSION['redirect'] = base_url()."admin/media/view_mediapr"; redirect(base_url().'admin/login'); } $this->load->model('media_model', 'media'); } public function index() { $data = array(); //echo "Workin="; $data['records'] = $this->media->get_media(); $this->load->view('admin/view_mediapr',$data); //$this->view_media(); } public function addmedia() { extract($_POST); $data = array(); $data['data_string'] = ''; $post=$this->input->post(); if($post){ echo '<script>console.log("post")</script>'; $this->form_validation->set_rules('title', 'Job Title', 'required'); $this->form_validation->set_rules('slug', 'slug', 'required'); $this->form_validation->set_rules('description', 'Job description', 'required'); $this->form_validation->set_rules('media_date', 'Posting Date', 'required'); if ($this->form_validation->run() == FALSE) { echo '<script>console.log("Error in validating media")</script>'; //console.log("Error in validating doctor"); //$this->load->view('admin/addmedia'); } else { // Upload PDF & Image $image_name = $this->uploadImage('image_name'); $image_name2 = $this->uploadImage('image_name2'); $image_name3 = $this->uploadImage('image_name3'); $image_name4 = $this->uploadImage('image_name4'); $image_name5 = $this->uploadImage('image_name5'); $pdf_name = $this->uploadImage('pdf_name'); $insert_data = array( 'id' => $post['id'], 'title' => $post['title'], 'image_name' => $image_name, 'image_name_2' => $image_name2, 'image_name_3' => $image_name3, 'image_name_4' => $image_name4, 'image_name_5' => $image_name5, 'pdf_name' => $pdf_name, 'description' => $post['description'], 'slug' => strtolower(str_replace(' ','-',$post['slug'])), 'createdon' => date('Y-m-d h:i:s'), 'media_date' => date('Y-m-d',strtotime($post['media_date'])), 'status' => '1' ); $success = ''; $success = $this->media->insert_media($insert_data); //echo '<script>console.log("'.$success.'")</script>'; if($success){ redirect(base_url()."admin/media"); } } } $this->load->view('admin/addmediapr',$data); } public function update_media($id){ extract($_POST); $data = array(); $data['data_string'] = ''; $post=$this->input->post(); $records = $this->media->get_media($id); if($id) { $data = array( 'id' => $records[0]['id'], 'title' => $records[0]['title'], 'description' => $records[0]['description'], 'slug' => $records[0]['slug'], 'pdf_name' => $records[0]['pdf_name'], 'image_name' => $records[0]['image_name'], 'image_name2' => $records[0]['image_name_2'], 'image_name3' => $records[0]['image_name_3'], 'image_name4' => $records[0]['image_name_4'], 'image_name5' => $records[0]['image_name_5'], 'media_date' => $records[0]['media_date'], 'status' => $records[0]['status'] ); $this->load->view('admin/update_mediapr',$data); } } public function updatemedia($ids){ extract($_POST); $post=$this->input->post(); if($post){ $this->form_validation->set_rules('title', 'Media Title', 'required'); $this->form_validation->set_rules('slug', 'slug', 'required'); $this->form_validation->set_rules('description', 'Job description', 'required'); $this->form_validation->set_rules('media_date', 'Posting Date', 'required'); if($this->form_validation->run() == FALSE) { echo '<script>console.log("Error in validating media")</script>'; //console.log("Error in validating doctor"); die; // $this->load->view('admin/update_media'); } else { // Upload PDF & Image $image_name = $this->uploadImage('image_name'); $image_name2 = $this->uploadImage('image_name2'); $image_name3 = $this->uploadImage('image_name3'); $image_name4 = $this->uploadImage('image_name4'); $image_name5 = $this->uploadImage('image_name5'); $pdf_name = $this->uploadImage('pdf_name'); if($_POST['old_image']!='' && $image_name==''){ $image_name= $_POST['old_image']; } unset($_POST['old_image']); if($_POST['old_image2']!='' && $image_name2==''){ $image_name2= $_POST['old_image2']; } unset($_POST['old_image2']); if($_POST['old_image3']!='' && $image_name3==''){ $image_name3= $_POST['old_image3']; } unset($_POST['old_image3']); if($_POST['old_image4']!='' && $image_name4==''){ $image_name4= $_POST['old_image4']; } unset($_POST['old_image4']); if($_POST['old_image5']!='' && $image_name5==''){ $image_name5= $_POST['old_image5']; } unset($_POST['old_image5']); if($_POST['old_pdf_name']!='' && $pdf_name==''){ $pdf_name= $_POST['old_pdf_name']; } unset($_POST['old_pdf_name']); $insert_data = array( 'title' => $post['title'], 'image_name' => $image_name, 'image_name_2' => $image_name2, 'image_name_3' => $image_name3, 'image_name_4' => $image_name4, 'image_name_5' => $image_name5, 'pdf_name' => $pdf_name, 'description' => $post['description'], 'slug' => strtolower(str_replace(' ','-',$post['slug'])), 'media_date' => date('Y-m-d',strtotime($post['media_date'])), 'status' => '1' ); $mediaid = $post['id']; $success = ''; $success = $this->media->editmedia($insert_data,$mediaid); echo '<script>console.log("'.$success.'")</script>'; if($success){ redirect(base_url()."admin/media"); } } } //$this->load->view('admin/AddNews',$data); } public function remove_media($id) { $data = array(); if($this->media->delete_media($id)){ $data['msg'] = 'News Section deleted succesfully'; redirect('admin/media',$data); } else{ $data['msg'] = 'Media could not be deleted'; } $data['records'] = $this->media->get_media($id); if(!$data){ show_404(); } redirect('admin/media'); } public function view_media($id=0) { $data = array(); $data['records'] = $this->media->get_media($id); if(!$data){ show_404(); } $this->load->view('admin/view_mediapr',$data); } /* * Function : uploadImage * Description : Upload the banner image */ private function uploadImage($imageName = '') { $config['upload_path'] = './uploads/files'; $config['allowed_types'] = 'gif|jpg|png|jpeg|JPG|PNG|JPEG|PDF|pdf|SVG|svg|avi|mp4|3gp|mpeg|mpg|mov|mp3|flv|wmv'; $this->load->library('upload', $config); $this->upload->initialize($config); if (!$this->upload->do_upload($imageName)) { log_message('error', 'Image Upload Error: ' . $this->upload->display_errors()); } $img = $this->upload->data(); return $img['file_name']; } }