Server IP : 192.185.129.71 / Your IP : 3.139.64.23 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/vivekaexcel.edu.in/application/controllers/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
<?php defined('BASEPATH') OR exit('No direct script access allowed'); class Admin extends CI_Controller { function __construct() { parent::__construct(); $this->load->library('encryption'); // if($this->session->email != NULL && $this->session->password != NULL ){ // $this->db->where("email",$this->session->email); // $temp=$this->db->get("admin")->result_array(); // if($temp!=NULL){ // $pwd=$this->encryption->decrypt($temp[0]['password']); // if($pwd==$this->session->password){return 1;} // else{redirect(base_url().'login','refresh');} // }else{redirect(base_url().'login','refresh');} // }else{ // redirect(base_url().'login','refresh'); // } } public function popUp($heading,$text,$type){ $user = array( 'heading' =>$heading, 'text' =>$text, 'type' =>$type, 'isPop'=>TRUE ); $this->session->set_userdata($user); } //===============================Home====================================// public function index() { $this->load->view('admin/dashboard'); } //==============================news===============================// public function news($param1="",$param2="") { if($param1=="view") { $page_data["news"] = $this->db->get("news")->result_array(); $this->load->view("admin/news",$page_data); } if($param1=="uploads") { $addData['date'] = date("Y-m-d",strtotime($this->input->post("date"))); $addData['title'] = $this->input->post("title"); $addData['category'] = $this->input->post("category"); $addData['description'] = $this->input->post("description"); $path = "uploads/news/"; if($_FILES['image']['tmp_name'] !=NULL){ $target_file = $path . basename($_FILES["image"]["name"]); $FileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION)); $file_name="news_image_".strtotime(date("Y-m-d H:i:s")).".".$FileType; move_uploaded_file($_FILES['image']['tmp_name'], $path."/".$file_name); $addData["image"] = $file_name; } $this->db->insert('news',$addData); $id = $this->db->insert_id(); $this->popUp("Success","Data Added successfully.!","success"); redirect(base_url().'admin/news/view','refresh'); } if($param1=="edit") { $data["news"]=$this->db->get_where("news",array("id"=>$param2))->row(); $this->load->view("admin/edit_news_model",$data); } if($param1=="update") { $newsValue = $this->db->get_where("news",array("id"=>$this->input->post("id")))->result_array(); $addData['date'] = date("Y-m-d",strtotime($this->input->post("date"))); $addData['title'] = $this->input->post("title"); $addData['category'] = $this->input->post("category"); $addData['description'] = $this->input->post("description"); $path = "uploads/news/"; if($_FILES['image']['tmp_name'] !=NULL){ // if($newsValue[0]['image'] != NULL){if(file_exists($path.'/'.$newsValue[0]['image'])){ unlink($path.'/'.$newsValue[0]['image']);}} $target_file = $path . basename($_FILES["image"]["name"]); $FileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION)); $file_name="news_image_".strtotime(date("Y-m-d H:i:s")).".".$FileType; move_uploaded_file($_FILES['image']['tmp_name'], $path."/".$file_name); $addData["image"] = $file_name; } $this->db->update('news',$addData,array("id",$this->input->post('id'))); $this->popUp("Success","Data Updated successfully.!","success"); redirect(base_url().'admin/news/view','refresh'); } if($param1=="delete") { $newsValue = $this->db->get_where("news",array("id"=>$param2))->result_array(); $path = "uploads/news/"; if($newsValue[0]['image'] != NULL){if(file_exists($path.'/'.$newsValue[0]['image'])){ unlink($path.'/'.$newsValue[0]['image']);}} $id = $param2; $this->db->where('id',$id)->delete('news'); $this->popUp("Success","delete successfully.!","success"); redirect(base_url().'admin/news/view','refresh'); } } //==============================Events===============================// public function events($param1="",$param2="") { if($param1=="view") { $page_data["events"] = $this->db->get("events")->result_array(); $this->load->view("admin/events",$page_data); } if($param1=="uploads") { $addData['date'] = date("Y-m-d",strtotime($this->input->post("date"))); $addData['from_time'] = date("H:i:s",strtotime($this->input->post("from_time"))); $addData['to_time'] = date("H:i:s",strtotime($this->input->post("to_time"))); $addData['title'] = $this->input->post("title"); $addData['location'] = $this->input->post("location"); $addData['description'] = $this->input->post("description"); $path = "uploads/events/"; if($_FILES['image']['tmp_name'] !=NULL){ $target_file = $path . basename($_FILES["image"]["name"]); $FileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION)); $file_name="events_image_".strtotime(date("Y-m-d H:i:s")).".".$FileType; move_uploaded_file($_FILES['image']['tmp_name'], $path."/".$file_name); $addData["image"] = $file_name; } $this->db->insert('events',$addData); $id = $this->db->insert_id(); $this->popUp("Success","Data Added successfully.!","success"); redirect(base_url().'admin/events/view','refresh'); } if($param1=="edit") { $data["events"]=$this->db->get_where("events",array("id"=>$param2))->row(); $this->load->view("admin/edit_events_model",$data); } if($param1=="update") { $eventsValue = $this->db->get_where("events",array("id"=>$this->input->post("id")))->result_array(); $addData['date'] = date("Y-m-d",strtotime($this->input->post("date"))); $addData['from_time'] = date("H:i:s",strtotime($this->input->post("from_time"))); $addData['to_time'] = date("H:i:s",strtotime($this->input->post("to_time"))); $addData['title'] = $this->input->post("title"); $addData['location'] = $this->input->post("location"); $addData['description'] = $this->input->post("description"); $path = "uploads/events/"; if($_FILES['image']['tmp_name'] !=NULL){ if($eventsValue[0]['image'] != NULL){if(file_exists($path.'/'.$eventsValue[0]['image'])){ unlink($path.'/'.$eventsValue[0]['image']);}} $target_file = $path . basename($_FILES["image"]["name"]); $FileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION)); $file_name="events_image_".strtotime(date("Y-m-d H:i:s")).".".$FileType; move_uploaded_file($_FILES['image']['tmp_name'], $path."/".$file_name); $addData["image"] = $file_name; } $this->db->update('events',$addData,array("id",$this->input->post('id'))); $this->popUp("Success","Data Updated successfully.!","success"); redirect(base_url().'admin/events/view','refresh'); } if($param1=="delete") { $eventsValue = $this->db->get_where("events",array("id"=>$param2))->result_array(); $path = "uploads/events/"; if($eventsValue[0]['image'] != NULL){if(file_exists($path.'/'.$eventsValue[0]['image'])){ unlink($path.'/'.$eventsValue[0]['image']);}} $id = $param2; $this->db->where('id',$id)->delete('events'); $this->popUp("Success","delete successfully.!","success"); redirect(base_url().'admin/events/view','refresh'); } } //==============================Flash News===============================// public function flashNews($param1="",$param2="") { if($param1=="view") { $page_data["flashNews"] = $this->db->order_by("id",'DESC')->get("flashNews")->result_array(); $this->load->view("admin/flashNews",$page_data); } if($param1=="uploads") { $addData['date'] = date("Y-m-d",strtotime($this->input->post("date"))); $addData['title'] = $this->input->post("title"); $addData['url'] = $this->input->post("url"); $this->db->insert('flashNews',$addData); $id = $this->db->insert_id(); $this->popUp("Success","Data Added successfully.!","success"); redirect(base_url().'admin/flashNews/view','refresh'); } if($param1=="edit") { $data["flashNews"]=$this->db->get_where("flashNews",array("id"=>$param2))->row(); $this->load->view("admin/edit_flashNews_model",$data); } if($param1=="update") { $flashNewsValue = $this->db->get_where("flashNews",array("id"=>$this->input->post("id")))->result_array(); $addData['date'] = date("Y-m-d",strtotime($this->input->post("date"))); $addData['title'] = $this->input->post("title"); $addData['url'] = $this->input->post("url"); $this->db->update('flashNews',$addData,array("id",$this->input->post('id'))); $this->popUp("Success","Data Updated successfully.!","success"); redirect(base_url().'admin/flashNews/view','refresh'); } if($param1=="delete") { $flashNewsValue = $this->db->get_where("flashNews",array("id"=>$param2))->result_array(); $id = $param2; $this->db->where('id',$id)->delete('flashNews'); $this->popUp("Success","delete successfully.!","success"); redirect(base_url().'admin/flashNews/view','refresh'); } } //==============================Quick Links===============================// public function quickLinks($param1="",$param2="") { if($param1=="view") { $page_data["quickLinks"] = $this->db->order_by("id",'DESC')->get("quickLinks")->result_array(); $this->load->view("admin/quickLinks",$page_data); } if($param1=="uploads") { $addData['date'] = date("Y-m-d",strtotime($this->input->post("date"))); $addData['title'] = $this->input->post("title"); $addData['url'] = $this->input->post("url"); $this->db->insert('quickLinks',$addData); $id = $this->db->insert_id(); $this->popUp("Success","Data Added successfully.!","success"); redirect(base_url().'admin/quickLinks/view','refresh'); } if($param1=="edit") { $data["quickLinks"]=$this->db->get_where("quickLinks",array("id"=>$param2))->row(); $this->load->view("admin/edit_quickLinks_model",$data); } if($param1=="update") { $addData['date'] = date("Y-m-d",strtotime($this->input->post("date"))); $addData['title'] = $this->input->post("title"); $addData['url'] = $this->input->post("url"); $this->db->update('quickLinks',$addData,array("id",$this->input->post('id'))); $this->popUp("Success","Data Updated successfully.!","success"); redirect(base_url().'admin/quickLinks/view','refresh'); } if($param1=="delete") { $id = $param2; $this->db->where('id',$id)->delete('quickLinks'); $this->popUp("Success","delete successfully.!","success"); redirect(base_url().'admin/quickLinks/view','refresh'); } } }