Server IP : 192.185.129.71 / Your IP : 3.16.147.87 Web Server : Apache System : Linux bh-ht-3.webhostbox.net 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64 User : svymadmin ( 4072) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0755) : /home4/svymadmin/public_html/application/controllers/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
<?php defined('BASEPATH') OR exit('No direct script access allowed'); class Admin extends CI_Controller { /** * Index Page for this controller. * * Maps to the following URL * http://example.com/index.php/welcome * - or - * http://example.com/index.php/welcome/index * - or - * Since this controller is set as the default controller in * config/routes.php, it's displayed at http://example.com/ * * So any other public methods not prefixed with an underscore will * map to /index.php/welcome/<method_name> * @see https://codeigniter.com/user_guide/general/urls.html */ public function popUp($heading,$text,$type) { $user = array( 'heading' =>$heading, 'text' =>$text, 'type' =>$type, 'isPop'=>TRUE ); $this->session->set_userdata($user); } public function index() { $this->load->view('admin/dashboard'); } //================================Cards=============================// public function cards($param1="",$param2="") { if($param1=="view") { $page_data["cards"] = $this->db->order_by("card_number",'ASC')->get("cards")->result_array(); $this->load->view("admin/cards",$page_data); } if($param1=="uploads") { $cardValue = $this->db->get_where("cards",array("card_number"=>$this->input->post("card_number")))->result_array(); if($cardValue == NULL){ $addData['card_number'] = $this->input->post("card_number"); $addData['title'] = $this->input->post("title"); $addData['sub_title'] = $this->input->post("sub_title"); $addData['description'] = $this->input->post("description"); $addData['url'] = $this->input->post("url"); $addData['nickname'] = $this->input->post("nickname"); $path = "uploads/card/"; if($_FILES['image']['tmp_name'] !=NULL){ $target_file = $path . basename($_FILES["image"]["name"]); $FileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION)); $file_name="card_image_".$this->input->post("card_number").".".$FileType; move_uploaded_file($_FILES['image']['tmp_name'], $path."/".$file_name); $addData["image"] = $file_name; } $this->db->insert('cards',$addData); $id = $this->db->insert_id(); $this->popUp("Success","Data Added successfully.!","success"); }else{ $addData['title'] = $this->input->post("title"); $addData['sub_title'] = $this->input->post("sub_title"); $addData['description'] = $this->input->post("description"); $addData['url'] = $this->input->post("url"); $path = "uploads/card/"; if($_FILES['image']['tmp_name'] !=NULL){ if($cardValue[0]['image'] != NULL){if(file_exists($path.'/'.$cardValue[0]['image'])){ unlink($path.'/'.$cardValue[0]['image']);}} $target_file = $path . basename($_FILES["image"]["name"]); $FileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION)); $file_name="card_image_".$this->input->post("card_number").".".$FileType; move_uploaded_file($_FILES['image']['tmp_name'], $path."/".$file_name); $addData["image"] = $file_name; } $this->db->where("id",$cardValue[0]['id']); $this->db->update('cards',$addData); $this->popUp("Success","Data Updated successfully.!","success"); } redirect(base_url().'admin/cards/view','refresh'); } if($param1=="edit") { $data["cards"]=$this->db->get_where("cards",array("id"=>$param2))->row(); $this->load->view("admin/edit_cards_model",$data); } if($param1=="update") { $cardValue = $this->db->get_where("cards",array("id"=>$this->input->post("id")))->result_array(); $addData['title'] = $this->input->post("title"); $addData['sub_title'] = $this->input->post("sub_title"); $addData['description'] = $this->input->post("description"); $addData['url'] = $this->input->post("url"); $addData['nickname'] = $this->input->post("nickname"); $path = "uploads/card/"; if($_FILES['image']['tmp_name'] !=NULL){ if($cardValue[0]['image'] != NULL){if(file_exists($path.'/'.$cardValue[0]['image'])){ unlink($path.'/'.$cardValue[0]['image']);}} $target_file = $path . basename($_FILES["image"]["name"]); $FileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION)); $file_name="card_image_".$this->input->post("card_number").".".$FileType; move_uploaded_file($_FILES['image']['tmp_name'], $path."/".$file_name); $addData["image"] = $file_name; } $this->db->where("id",$this->input->post('id')); $this->db->update('cards',$addData); $this->popUp("Success","Data Updated successfully.!","success"); redirect(base_url().'admin/cards/view','refresh'); } if($param1=="delete") { $cardValue = $this->db->get_where("cards",array("id"=>$param2))->result_array(); $path = "uploads/card/"; if($cardValue[0]['image'] != NULL){if(file_exists($path.'/'.$cardValue[0]['image'])){ unlink($path.'/'.$cardValue[0]['image']);}} $id = $param2; $this->db->where('id',$id)->delete('cards'); $this->popUp("Success","delete successfully.!","success"); redirect(base_url().'admin/cards/view','refresh'); } } //===================================Report==================================// public function annual_report($param1="",$param2="") { if($param1 == "view") { $page_data["annualreport"] = $this->db->get("annual_report")->result_array(); $this->load->view("admin/annual_report",$page_data); } if($param1=="uploads") { $path = "uploads/annual_report/"; $addData['title'] = $this->input->post("title"); $addData['type'] = $this->input->post("type"); $this->db->insert('annual_report',$addData); $id = $this->db->insert_id(); if($this->input->post("type") == "url") { $updateData['url'] = $this->input->post("url"); }else{ if($_FILES['pdf']['tmp_name'] !=NULL){ $target_file = $path . basename($_FILES["pdf"]["name"]); $FileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION)); $file_name="annual_report_pdf_".strtotime(date("y-m-d")).$id.".".$FileType; move_uploaded_file($_FILES['pdf']['tmp_name'], $path."/".$file_name); $updateData["pdf"] = $file_name; } } if($_FILES['image']['tmp_name'] !=NULL){ $target_file = $path . basename($_FILES["image"]["name"]); $FileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION)); $file_name="annual_report_image_".strtotime(date("y-m-d")).$id.".".$FileType; move_uploaded_file($_FILES['image']['tmp_name'], $path."/".$file_name); $updateData["image"] = $file_name; } $this->db->where("id",$id); $this->db->update('annual_report',$updateData); $this->popUp("Success","Data Added successfully.!","success"); redirect(base_url().'admin/annual_report/view','refresh'); } if($param1=="edit") { $data["cards"]=$this->db->get_where("cards",array("id"=>$param2))->row(); $this->load->view("admin/edit_annual_report_model",$data); } if($param1=="delete") { $id = $param2; $annual_reportValue = $this->db->get_where("annual_report",array("id"=>$id))->result_array(); $path = "uploads/annual_report/"; if($annual_reportValue[0]['pdf'] != NULL){if(file_exists($path.'/'.$annual_reportValue[0]['pdf'])){ unlink($path.'/'.$annual_reportValue[0]['pdf']);}} if($annual_reportValue[0]['image'] != NULL){if(file_exists($path.'/'.$annual_reportValue[0]['image'])){ unlink($path.'/'.$annual_reportValue[0]['image']);}} $this->db->where('id',$id)->delete('annual_report'); $this->popUp("Success","delete successfully.!","success"); redirect(base_url().'admin/annual_report/view','refresh'); } } }