?
Current Path : /home1/savoy/www/savoyeducation.com/application/controllers/admin/ |
Linux gator3171.hostgator.com 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64 |
Current File : /home1/savoy/www/savoyeducation.com/application/controllers/admin/Admin_controller.php |
<?php defined('BASEPATH') OR exit('No direct script access allowed'); class Admin_controller 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 __construct() { parent::__construct(); $this->load->helper('url'); $this->load->helper('form'); $this->load->helper('string'); $this->load->library('form_validation'); $this->load->library('session'); $this->load->library('encrypt'); $this->load->library('zip'); $this->load->library('upload'); $this->load->model('Admin_model'); $this->load->library('email'); } public function index() { $this->load->view('back-end/pages/login'); $this->load->view('back-end/templates/footer'); } public function login() { if (isset($this->session->userdata['logged_in'])) { $data = $this->session->userdata['logged_in']; redirect('admin/Admin_controller/dashboard'); } else { $this->form_validation->set_rules('email', 'email', 'trim|required'); $this->form_validation->set_rules('password', 'password', 'trim|required'); //var_dump($this->input->post()); die(); if ($this->form_validation->run() == FALSE) { redirect('admin/Admin_controller/index'); } else { $data = array( 'email' => $this->input->post('email'), 'password' => $this->input->post('password'), 'user_type' => 'admin' ); $result = $this->Admin_model->login($data); if ($result == TRUE) { redirect('admin/Admin_controller/dashboard'); } else { $this->session->set_flashdata('alert_info', 'Invalid Username or Password'); $this->session->set_flashdata('alert_class', 'alert-danger'); redirect('admin/Admin_controller/index'); } } } } public function signup() { if (isset($this->session->userdata['logged_in'])) { $data = $this->session->userdata['logged_in']; if ($data['user_type'] == 'admin') { $this->load->view('back-end/templates/sidebar'); $this->load->view('back-end/templates/header'); $this->load->view('back-end/pages/signup'); $this->load->view('back-end/templates/footer'); } else { $this->session->set_flashdata('alert_info', 'Please login first..'); $this->session->set_flashdata('alert_class', 'alert-danger'); redirect('admin/Admin_controller/index'); } } } public function registration() { $this->form_validation->set_rules('firstname', 'firstname', 'trim|required'); $this->form_validation->set_rules('email', 'email', 'trim|required|is_unique[user_login.email]'); if ($this->form_validation->run() == FALSE) { $this->signup(); } else { $data = array( 'first_name' => $this->input->post('firstname'), 'last_name' => $this->input->post('lastname'), 'email' => $this->input->post('email'), 'password' => md5($this->input->post('password')), 'user_type' => 'user' ); $result = $this->Admin_model->insert_user($data); if ($result) { $this->session->set_flashdata('alert_info', 'New user added successfully'); $this->session->set_flashdata('alert_class', 'alert-success'); redirect('admin/Admin_controller/userlist'); } else { $this->session->set_flashdata('alert_info', 'User registration failed'); $this->session->set_flashdata('alert_class', 'alert-danger'); redirect('admin/Admin_controller/signup'); } } } public function dashboard() { if (isset($this->session->userdata['logged_in'])) { $data = $this->session->userdata['logged_in']; $data1['usercount'] = $this->Admin_model->users_count(); $data1['announcementcount'] = $this->Admin_model->announcement_count(); $data1['programcount'] = $this->Admin_model->program_count(); $this->load->view('back-end/templates/header'); $this->load->view('back-end/templates/sidebar'); $this->load->view('back-end/pages/dashboard', $data1); $this->load->view('back-end/templates/footer'); } else { $this->session->set_flashdata('alert_info', 'Please login first..'); $this->session->set_flashdata('alert_class', 'alert-danger'); redirect('admin/Admin_controller/index'); } } public function userlist() { if (isset($this->session->userdata['logged_in'])) { $data = $this->session->userdata['logged_in']; $data1['userlisting'] = $this->Admin_model->fetch_users(); $this->load->view('back-end/templates/sidebar'); $this->load->view('back-end/templates/header'); $this->load->view('back-end/pages/userlist', $data1); $this->load->view('back-end/templates/footer'); } else { $this->session->set_flashdata('alert_info', 'Please login first..'); $this->session->set_flashdata('alert_class', 'alert-danger'); redirect('admin/Admin_controller/index'); } } public function delete_users($user_id) { if ($this->Admin_model->delete_users($user_id)) { $this->session->set_flashdata('alert_info', 'Data Deleted successfully'); $this->session->set_flashdata('alert_class', 'alert-successs'); redirect('admin/Admin_controller/userlist'); } else { $this->session->set_flashdata('alert_info', 'Data deletion failed'); $this->session->set_flashdata('alert_class', 'alert-danger'); redirect('admin/Admin_controller/userlist'); } } public function user_permission($id, $data) { if ($this->Admin_model->user_permission($id, $data)) { $this->session->set_flashdata('alert_info', 'Sucessfully Done!!!'); $this->session->set_flashdata('alert_class', 'alert-successs'); redirect('admin/Admin_controller/userlist'); } else { $this->session->set_flashdata('alert_info', 'Failed'); $this->session->set_flashdata('alert_class', 'alert-danger'); redirect('admin/Admin_controller/index'); } } public function add_banner() { if (isset($this->session->userdata['logged_in'])) { $data = $this->session->userdata['logged_in']; $this->load->view('back-end/templates/sidebar'); $this->load->view('back-end/templates/header'); $this->load->view('back-end/pages/add_banner', array('error' => ' ')); $this->load->view('back-end/templates/footer'); } else { $this->session->set_flashdata('alert_info', 'Please login first..'); $this->session->set_flashdata('alert_class', 'alert-danger'); redirect('admin/Admin_controller/index'); } } public function banner_upload() { $this->form_validation->set_rules('description1', 'description', 'trim|required'); $config['upload_path'] = './uploads/banners/'; $config['allowed_types'] = 'gif|jpg|png'; $config['max_size'] = 100000; $this->load->library('upload'); $this->upload->initialize($config); $this->upload->do_upload('banner_image'); if (!$this->form_validation->run()) { redirect('admin/Admin_controller/add_banner'); } else { $banner = $this->upload->data(); $bannerimage = $banner['file_name']; $data = array( 'banner_image' => $bannerimage, 'description1' => $this->input->post('description1'), 'description2' => $this->input->post('description2'), ); //var_dump($data); // die(); $result = $this->Admin_model->insert_banner($data); if ($result) { $this->session->set_flashdata('alert_info', 'Banner added successfully'); $this->session->set_flashdata('alert_class', 'alert-success'); redirect('admin/Admin_controller/banner_listing'); } else { $this->session->set_flashdata('alert_info', 'Banner not added'); $this->session->set_flashdata('alert_class', 'alert-danger'); redirect('admin/Admin_controller/add_banner'); } } } public function banner_listing() { if (isset($this->session->userdata['logged_in'])) { $data = $this->session->userdata['logged_in']; $data1['banner'] = $this->Admin_model->banner_listing(); $this->load->view('back-end/templates/sidebar'); $this->load->view('back-end/templates/header'); $this->load->view('back-end/pages/banner', $data1); $this->load->view('back-end/templates/footer'); } else { $this->session->set_flashdata('alert_info', 'Please login first..'); $this->session->set_flashdata('alert_class', 'alert-danger'); redirect('admin/Admin_controller/index'); } } public function banner_edit($id) { if (isset($this->session->userdata['logged_in'])) { $data = $this->session->userdata['logged_in']; $data1['banners'] = $this->Admin_model->edit_banner($id); $this->load->view('back-end/templates/sidebar'); $this->load->view('back-end/templates/header'); $this->load->view('back-end/pages/edit_banner', $data1); $this->load->view('back-end/templates/footer'); } else { $this->session->set_flashdata('alert_info', 'Please login first..'); $this->session->set_flashdata('alert_class', 'alert-danger'); redirect('admin/Admin_controller/index'); } } public function update_banner() { $id = $this->input->post('id'); $this->form_validation->set_rules('description', 'description', 'trim|required'); $config['upload_path'] = './uploads/banners'; $config['allowed_types'] = 'gif|jpg|png'; $config['max_size'] = 1000000; $this->load->library('upload'); $this->upload->initialize($config); $this->upload->do_upload(''); if (!$this->upload->do_upload('banner_image')) { $data = array( 'description1' => $this->input->post('description1'), 'description2' => $this->input->post('description2'), ); } if ($this->upload->do_upload('banner_image')) { $bannerfoto = $this->upload->data(); $banner_image = $bannerfoto['file_name']; $data = array( 'banner_image' => $banner_image, 'description1' => $this->input->post('description1'), 'description2' => $this->input->post('description2'), ); } $result = $this->Admin_model->update_banner_content($id, $data); if ($result) { $this->session->set_flashdata('alert_info', 'Banner updated successfully'); $this->session->set_flashdata('alert_class', 'alert-success'); redirect('admin/Admin_controller/banner_listing'); } else { $this->session->set_flashdata('alert_info', 'Data updation failed'); $this->session->set_flashdata('alert_class', 'alert-danger'); redirect('admin/Admin_controller/banner_edit'); } } public function delete_banner($id) { $this->Admin_model->delete_banners(); if ($this->Admin_model->delete_banners($id)) { $this->session->set_flashdata('alert_info', 'Data Deleted successfully'); $this->session->set_flashdata('alert_class', 'alert-successs'); redirect('admin/Admin_controller/banner_listing'); } else { $this->session->set_flashdata('alert_info', 'Data deletion failed'); $this->session->set_flashdata('alert_class', 'alert-danger'); redirect('admin/Admin_controller/delete_users'); } } public function add_announcement() { if (isset($this->session->userdata['logged_in'])) { $data = $this->session->userdata['logged_in']; $this->load->view('back-end/templates/sidebar'); $this->load->view('back-end/templates/header'); $this->load->view('back-end/pages/add_announcement', array('error' => ' ')); $this->load->view('back-end/templates/footer'); } else { $this->session->set_flashdata('alert_info', 'Please login first..'); $this->session->set_flashdata('alert_class', 'alert-danger'); redirect('admin/Admin_controller/index'); } } public function announcement_upload() { $this->form_validation->set_rules('description', 'description', 'trim|required'); $config['upload_path'] = './uploads/announcements/'; $config['allowed_types'] = 'gif|jpg|png'; $config['max_size'] = 100000; $this->load->library('upload'); $this->upload->initialize($config); $this->upload->do_upload('announcementimage'); if (!$this->form_validation->run()) { redirect('admin/Admin_controller/add_announcement'); } else { $announcement = $this->upload->data(); $announcement_image = $announcement['file_name']; $data = array( 'title' => $this->input->post('announcement_title'), 'announcement_image' => $announcement_image, 'description' => $this->input->post('description'), 'announcement_date' => $this->input->post('announcementdate'), ); // var_dump($data); // die(); $result = $this->Admin_model->insert_announcement($data); if ($result) { $this->session->set_flashdata('alert_info', 'Announcement added successfully'); $this->session->set_flashdata('alert_class', 'alert-success'); redirect('admin/Admin_controller/announcement'); } else { $this->session->set_flashdata('alert_info', 'Announcement not added'); $this->session->set_flashdata('alert_class', 'alert-danger'); redirect('admin/Admin_controller/add_announcement'); } } } public function announcement() { if (isset($this->session->userdata['logged_in'])) { $data = $this->session->userdata['logged_in']; $data1['announcement'] = $this->Admin_model->announcement_listing(); $this->load->view('back-end/templates/sidebar'); $this->load->view('back-end/templates/header'); $this->load->view('back-end/pages/announcement_listing', $data1); $this->load->view('back-end/templates/footer'); } else { $this->session->set_flashdata('alert_info', 'Please login first..'); $this->session->set_flashdata('alert_class', 'alert-danger'); redirect('admin/Admin_controller/index'); } } public function announcement_edit($id) { if (isset($this->session->userdata['logged_in'])) { $data = $this->session->userdata['logged_in']; $data1['announcements'] = $this->Admin_model->edit_announcement($id); $this->load->view('back-end/templates/sidebar'); $this->load->view('back-end/templates/header'); $this->load->view('back-end/pages/edit_announcement', $data1); $this->load->view('back-end/templates/footer'); } else { $this->session->set_flashdata('alert_info', 'Please login first..'); $this->session->set_flashdata('alert_class', 'alert-danger'); redirect('admin/Admin_controller/index'); } } public function update_announcement() { $id = $this->input->post('id'); $this->form_validation->set_rules('description', 'description', 'trim|required'); $config['upload_path'] = './uploads/announcements'; $config['allowed_types'] = 'gif|jpg|png'; $config['max_size'] = 1000000; $this->load->library('upload'); $this->upload->initialize($config); $this->upload->do_upload(''); if (!$this->upload->do_upload('announcementimage')) { $data = array( 'title' => $this->input->post('announcement_title'), 'description' => $this->input->post('description'), 'announcement_date' => $this->input->post('announcementdate'), ); } if ($this->upload->do_upload('announcementimage')) { $announcementfoto = $this->upload->data(); $announcement_image = $announcementfoto['file_name']; $data = array( 'announcement_image' => $announcement_image, 'title' => $this->input->post('announcement_title'), 'description' => $this->input->post('description'), 'announcement_date' => $this->input->post('announcementdate'), ); } $result = $this->Admin_model->update_announcement_content($id, $data); if ($result) { $this->session->set_flashdata('alert_info', 'Announcement updated successfully'); $this->session->set_flashdata('alert_class', 'alert-success'); redirect('admin/Admin_controller/announcement'); } else { $this->session->set_flashdata('alert_info', 'Data updation failed'); $this->session->set_flashdata('alert_class', 'alert-danger'); redirect('admin/Admin_controller/announcement_edit'); } } public function delete_announcement($id) { if ($this->Admin_model->delete_announcement($id)) { $this->session->set_flashdata('alert_info', 'Data Deleted successfully'); $this->session->set_flashdata('alert_class', 'alert-successs'); redirect('admin/Admin_controller/announcement'); } else { $this->session->set_flashdata('alert_info', 'Data deletion failed'); $this->session->set_flashdata('alert_class', 'alert-danger'); redirect('admin/Admin_controller/announcement'); } } public function add_programs() { if (isset($this->session->userdata['logged_in'])) { $data = $this->session->userdata['logged_in']; $this->load->view('back-end/templates/sidebar'); $this->load->view('back-end/templates/header'); $this->load->view('back-end/pages/add_programms', array('error' => ' ')); $this->load->view('back-end/templates/footer'); } else { $this->session->set_flashdata('alert_info', 'Please login first..'); $this->session->set_flashdata('alert_class', 'alert-danger'); redirect('admin/Admin_controller/index'); } } public function program_upload() { $this->form_validation->set_rules('description', 'description', 'trim|required'); $config['upload_path'] = './uploads/programs/'; $config['allowed_types'] = 'gif|jpg|png'; $config['max_size'] = 100000; $this->load->library('upload'); $this->upload->initialize($config); $this->upload->do_upload('programimage'); if (!$this->form_validation->run()) { redirect('admin/Admin_controller/add_programs'); } else { $program = $this->upload->data(); $program_image = $program['file_name']; $data = array( 'program_title' => $this->input->post('program'), 'featured_image' => $program_image, 'main_description' => $this->input->post('description'), 'short_description1' => $this->input->post('description1'), 'short_description2' => $this->input->post('description2'), ); // var_dump($data); // die(); $result = $this->Admin_model->insert_program($data); if ($result) { $this->session->set_flashdata('alert_info', 'Program added successfully'); $this->session->set_flashdata('alert_class', 'alert-success'); redirect('admin/Admin_controller/program_list'); } else { $this->session->set_flashdata('alert_info', 'Program not added'); $this->session->set_flashdata('alert_class', 'alert-danger'); redirect('admin/Admin_controller/add_announcement'); } } } public function program_list() { if (isset($this->session->userdata['logged_in'])) { $data = $this->session->userdata['logged_in']; $data1['program'] = $this->Admin_model->program_listing(); $this->load->view('back-end/templates/sidebar'); $this->load->view('back-end/templates/header'); $this->load->view('back-end/pages/list_programs', $data1); $this->load->view('back-end/templates/footer'); } else { $this->session->set_flashdata('alert_info', 'Please login first..'); $this->session->set_flashdata('alert_class', 'alert-danger'); redirect('admin/Admin_controller/index'); } } public function program_edit($id) { if (isset($this->session->userdata['logged_in'])) { $data = $this->session->userdata['logged_in']; $data1['programs'] = $this->Admin_model->edit_program($id); $this->load->view('back-end/templates/sidebar'); $this->load->view('back-end/templates/header'); $this->load->view('back-end/pages/edit_programs', $data1); $this->load->view('back-end/templates/footer'); } else { $this->session->set_flashdata('alert_info', 'Please login first..'); $this->session->set_flashdata('alert_class', 'alert-danger'); redirect('admin/Admin_controller/index'); } } public function program_update() { $id = $this->input->post('id'); $this->form_validation->set_rules('description', 'description', 'trim|required'); $config['upload_path'] = './uploads/programs'; $config['allowed_types'] = 'gif|jpg|png'; $config['max_size'] = 1000000; $this->load->library('upload'); $this->upload->initialize($config); $this->upload->do_upload(''); if (!$this->upload->do_upload('programimage')) { $data = array( 'program_title' => $this->input->post('program'), 'main_description' => $this->input->post('description'), 'short_description1' => $this->input->post('description1'), 'short_description2' => $this->input->post('description2'), ); } if ($this->upload->do_upload('programimage')) { $programfoto = $this->upload->data(); $program_image = $programfoto['file_name']; $data = array( 'program_title' => $this->input->post('program'), 'featured_image' => $program_image, 'main_description' => $this->input->post('description'), 'short_description1' => $this->input->post('description1'), 'short_description2' => $this->input->post('description2'), ); } $result = $this->Admin_model->update_program_content($id, $data); if ($result) { $this->session->set_flashdata('alert_info', 'Program updated successfully'); $this->session->set_flashdata('alert_class', 'alert-success'); redirect('admin/Admin_controller/program_list'); } else { $this->session->set_flashdata('alert_info', 'Data updation failed'); $this->session->set_flashdata('alert_class', 'alert-danger'); redirect('admin/Admin_controller/program_edit'); } } public function add_gallery($id) { // var_dump($id);die(); if (isset($this->session->userdata['logged_in'])) { $data = $this->session->userdata['logged_in']; $this->load->view('back-end/templates/sidebar'); $this->load->view('back-end/templates/header'); $this->load->view('back-end/pages/add_program_gallery', array('error' => ' ')); $this->load->view('back-end/templates/footer'); } else { $this->session->set_flashdata('alert_info', 'Please login first..'); $this->session->set_flashdata('alert_class', 'alert-danger'); redirect('admin/Admin_controller/index'); } } public function gallery_add_process() { $id = $this->input->post('id'); $data = array(); if ($this->input->post('fileSubmit') && !empty($_FILES['userFiles']['name'])) { $filesCount = count($_FILES['userFiles']['name']); for ($i = 0; $i < $filesCount; $i++) { $_FILES['userFile']['name'] = $_FILES['userFiles']['name'][$i]; $_FILES['userFile']['type'] = $_FILES['userFiles']['type'][$i]; $_FILES['userFile']['tmp_name'] = $_FILES['userFiles']['tmp_name'][$i]; $_FILES['userFile']['error'] = $_FILES['userFiles']['error'][$i]; $_FILES['userFile']['size'] = $_FILES['userFiles']['size'][$i]; $uploadPath = 'uploads/programs/'; $config['upload_path'] = $uploadPath; $config['allowed_types'] = 'gif|jpg|png'; $this->load->library('upload', $config); $this->upload->initialize($config); if ($this->upload->do_upload('userFile')) { $fileData = $this->upload->data(); $uploadData[$i]['file_name'] = $fileData['file_name']; $uploadData[$i]['created'] = date("Y-m-d H:i:s"); $uploadData[$i]['modified'] = date("Y-m-d H:i:s"); $uploadData[$i]['program_id'] = $id; } } if (!empty($uploadData)) { //Insert file information into the database $insert = $this->Admin_model->insert_programgallery($uploadData); $statusMsg = $insert ? 'Files uploaded successfully.' : 'Some problem occurred, please try again.'; $this->session->set_flashdata('statusMsg', $statusMsg); redirect('admin/Admin_controller/program_gallery_listing/' . $id); } } //Get files data from database $data['files'] = $this->Admin_model->getRows(); //Pass the files data to view //$this->load->view('upload_files/addgallery', $data); $this->load->view('back-end/templates/sidebar'); $this->load->view('back-end/templates/header'); $this->load->view('back-end/pages/add_program_gallery', $data); $this->load->view('back-end/templates/footer'); } public function program_gallery_listing($id) { if (isset($this->session->userdata['logged_in'])) { $data = $this->session->userdata['logged_in']; $data1['gallery'] = $this->Admin_model->gallery_list($id); $this->load->view('back-end/templates/sidebar'); $this->load->view('back-end/templates/header'); $this->load->view('back-end/pages/program_gallery', $data1); $this->load->view('back-end/templates/footer'); } else { $this->session->set_flashdata('alert_info', 'Please login first..'); $this->session->set_flashdata('alert_class', 'alert-danger'); redirect('admin/Admin_controller/index'); } } public function gallery_delete($id) { if ($this->Admin_model->delete_gallery($id)) { $this->session->set_flashdata('alert_info', 'Brand Deleted successfully'); $this->session->set_flashdata('alert_class', 'alert-successs'); redirect('admin/Admin_controller/program_list'); } else { $this->session->set_flashdata('alert_info', 'Data deletion failed'); $this->session->set_flashdata('alert_class', 'alert-danger'); redirect('admin/Admin_controller/index'); } } public function add_page() { if (isset($this->session->userdata['logged_in'])) { $data = $this->session->userdata['logged_in']; $this->load->view('back-end/templates/sidebar'); $this->load->view('back-end/templates/header'); $this->load->view('back-end/pages/add_page'); $this->load->view('back-end/templates/footer'); } else { $this->session->set_flashdata('alert_info', 'Please login first..'); $this->session->set_flashdata('alert_class', 'alert-danger'); redirect('admin/Admin_controller/index'); } } public function page_adding_process() { $this->form_validation->set_rules('pagetitle', 'Pagetitle', 'trim|required'); $this->form_validation->set_rules('description', 'Description', 'trim|required'); $config['upload_path'] = './uploads/'; $config['allowed_types'] = 'gif|jpg|png'; $config['max_size'] = 100000; $this->load->library('upload'); $this->upload->initialize($config); $this->upload->do_upload('image'); if (!$this->form_validation->run()) { redirect('admin/Admin_controller/add_page'); } else { $page = $this->upload->data(); $pagedetail = $page['file_name']; $data = array( 'page_title' => $this->input->post('pagetitle'), 'description' => $this->input->post('description'), 'page_image' => $pagedetail ); //var_dump($data); //die(); $result = $this->Admin_model->insert_page($data); if ($result) { $this->session->set_flashdata('alert_info', 'Page added successfully'); $this->session->set_flashdata('alert_class', 'alert-success'); redirect('admin/Admin_controller/page_listing'); } else { $this->session->set_flashdata('alert_info', 'Page not added'); $this->session->set_flashdata('alert_class', 'alert-danger'); redirect('admin/Admin_controller/add_page'); } } } public function page_listing() { if (isset($this->session->userdata['logged_in'])) { $data = $this->session->userdata['logged_in']; $data1['page'] = $this->Admin_model->page_list(); $this->load->view('back-end/templates/sidebar'); $this->load->view('back-end/templates/header'); $this->load->view('back-end/pages/page_listing', $data1); $this->load->view('back-end/templates/footer'); } else { $this->session->set_flashdata('alert_info', 'Please login first..'); $this->session->set_flashdata('alert_class', 'alert-danger'); redirect('admin/Admin_controller/index'); } } public function edit_pages($id) { if (isset($this->session->userdata['logged_in'])) { $data = $this->session->userdata['logged_in']; $data1['pages'] = $this->Admin_model->edit_page($id); $this->load->view('back-end/templates/sidebar'); $this->load->view('back-end/templates/header'); $this->load->view('back-end/pages/edit_page', $data1); $this->load->view('back-end/templates/footer'); } else { $this->session->set_flashdata('alert_info', 'Please login first..'); $this->session->set_flashdata('alert_class', 'alert-danger'); redirect('admin/Admin_controller/index'); } } public function update_page() { $id = $this->input->post('id'); $this->form_validation->set_rules('pagetitle', 'Pagetitle', 'trim|required'); $this->form_validation->set_rules('description', 'Description', 'trim|required'); $config['upload_path'] = './uploads/'; $config['allowed_types'] = 'gif|jpg|png'; $config['max_size'] = 1000000; $this->load->library('upload'); $this->upload->initialize($config); $this->upload->do_upload(''); if (!$this->upload->do_upload('image')) { $data = array( 'page_title' => $this->input->post('pagetitle'), 'description' => $this->input->post('description'), //'image' => $pagedetail ); } if ($this->upload->do_upload('image')) { $pagefoto = $this->upload->data(); $page_image = $pagefoto['file_name']; $data = array( 'page_title' => $this->input->post('pagetitle'), 'description' => $this->input->post('description'), 'page_image' => $page_image ); } $result = $this->Admin_model->update_page_content($id, $data); if ($result) { $this->session->set_flashdata('alert_info', 'page updated successfully'); $this->session->set_flashdata('alert_class', 'alert-success'); redirect('admin/Admin_controller/page_listing'); } else { $this->session->set_flashdata('alert_info', 'Data updation failed'); $this->session->set_flashdata('alert_class', 'alert-danger'); redirect('admin/Admin_controller/edit_pages'); } } public function forgot_password() { $this->load->view('back-end/pages/forgotpassword'); $this->load->view('back-end/templates/footer'); } public function forgetpasswordsender() { $data = random_string('alnum', 8); $email = $this->input->post('email'); $newPassword = md5($data); $result = $this->Admin_model->CheckUserExist($email); if ($result == TRUE) { if ($this->Admin_model->forgetChangePassword($email, $newPassword)) { $data1['pass'] = $data; $data1['mail2'] = $email; $this->load->view('back-end/pages/testpasswordpage', $data1); $this->load->view('back-end/templates/footer'); } } else { $this->session->set_flashdata('alert_info', 'Email Address Does not exist'); $this->session->set_flashdata('alert_class', 'alert-danger'); redirect('admin/Admin_controller/forgot_password'); } } public function change_password() { if (isset($this->session->userdata['logged_in'])) { $data = $this->session->userdata['logged_in']; $this->load->view('back-end/templates/sidebar'); $this->load->view('back-end/templates/header'); $this->load->view('back-end/pages/change_password'); $this->load->view('back-end/templates/footer'); } else { $this->session->set_flashdata('alert_info', 'Please login first..'); $this->session->set_flashdata('alert_class', 'alert-danger'); redirect('admin/Admin_controller/index'); } } public function change_password_update() { $this->form_validation->set_rules('oldpass', 'Old Password', 'required|trim'); $this->form_validation->set_rules('newpass', 'New Password', 'required|trim'); $this->form_validation->set_rules('confpass', 'Confirm Password', 'required|trim|matches[newpass]'); if ($this->form_validation->run() == FALSE) { redirect('admin/Admin_controller/change_password'); } else { $logged_in_user = $this->session->userdata['logged_in']; $username = $logged_in_user['email']; $password = md5($this->input->post('oldpass')); $new_pass = md5($this->input->post('newpass')); if ($this->Admin_model->update_password($username, $password, $new_pass)) { $this->session->set_flashdata('alert_info', 'Data updated successfully'); $this->session->set_flashdata('alert_class', 'alert-successs'); redirect('admin/Admin_controller/dashboard'); } else { $this->session->set_flashdata('alert_info', 'Data updation failed'); $this->session->set_flashdata('alert_class', 'alert-danger'); redirect('admin/Admin_controller/change_password'); } } } public function test_page() { $feeds = json_decode(file_get_contents('https://graph.facebook.com/SavoyEducationCenter/posts?fields=created_time,full_picture,message&access_token=599505266921545|3338b811044b512442af67b005530390')); $data['feeds'] = $feeds; $this->load->view('back-end/templates/sidebar'); $this->load->view('back-end/templates/header'); $this->load->view('back-end/pages/test', $data); $this->load->view('back-end/templates/footer'); } public function edit_contact() { if (isset($this->session->userdata['logged_in'])) { $data = $this->session->userdata['logged_in']; $data1['contactus'] = $this->Admin_model->edit_contact_page(); $this->load->view('back-end/templates/sidebar'); $this->load->view('back-end/templates/header'); $this->load->view('back-end/pages/edit_contact', $data1); $this->load->view('back-end/templates/footer'); } else { $this->session->set_flashdata('alert_info', 'Please login first..'); $this->session->set_flashdata('alert_class', 'alert-danger'); redirect('admin/Admin_controller/index'); } } public function contact_listing() { if (isset($this->session->userdata['logged_in'])) { $data = $this->session->userdata['logged_in']; $data1['contactus'] = $this->Admin_model->contactus_list(); $this->load->view('back-end/templates/sidebar'); $this->load->view('back-end/templates/header'); $this->load->view('back-end/pages/contact_list', $data1); $this->load->view('back-end/templates/footer'); } else { $this->session->set_flashdata('alert_info', 'Please login first..'); $this->session->set_flashdata('alert_class', 'alert-danger'); redirect('admin/Admin_controller/index'); } } public function update_contact() { $id = $this->input->post('id'); $this->form_validation->set_rules('address', 'address', 'trim|required'); if ($this->form_validation->run() == FALSE) { redirect('admin/Admin_controller/edit_contact'); } else { $data['address'] = $this->input->post('address'); $data['phone1'] = $this->input->post('phone1'); $data['phone2'] = $this->input->post('phone2'); $data['email'] = $this->input->post('email'); $data['site'] = $this->input->post('website'); if ($this->Admin_model->update_contact_details($id, $data)) { $this->session->set_flashdata('alert_info', 'Data updated successfully'); $this->session->set_flashdata('alert_class', 'alert-successs'); redirect('admin/Admin_controller/contact_listing'); } else { $this->session->set_flashdata('alert_info', 'Data updation failed'); $this->session->set_flashdata('alert_class', 'alert-danger'); redirect('admin/Admin_controller/index'); } } } public function add_video(){ if (isset($this->session->userdata['logged_in'])) { $data = $this->session->userdata['logged_in']; $this->load->view('back-end/templates/sidebar'); $this->load->view('back-end/templates/header'); $this->load->view('back-end/pages/video_add', array('error' => ' ')); $this->load->view('back-end/templates/footer'); } else { $this->session->set_flashdata('alert_info', 'Please login first..'); $this->session->set_flashdata('alert_class', 'alert-danger'); redirect('admin/Admin_controller/index'); } } public function video_upload(){ $this->form_validation->set_rules('videourl', 'videourl', 'trim|required'); $config['upload_path'] = './uploads/video/'; $config['allowed_types'] = 'gif|jpg|png'; $config['max_size'] = 100000; $this->load->library('upload'); $this->upload->initialize($config); $this->upload->do_upload('video_image'); if (!$this->form_validation->run()) { redirect('admin/Admin_controller/add_banner'); } else { $video = $this->upload->data(); $videoimage = $video['file_name']; $data = array( 'video_image' => $videoimage, 'video_url' => $this->input->post('videourl'), ); //var_dump($data); // die(); $result = $this->Admin_model->insert_video($data); if ($result) { $this->session->set_flashdata('alert_info', 'Video added successfully'); $this->session->set_flashdata('alert_class', 'alert-success'); redirect('admin/Admin_controller/video_listing'); } else { $this->session->set_flashdata('alert_info', 'Video not added'); $this->session->set_flashdata('alert_class', 'alert-danger'); redirect('admin/Admin_controller/add_video'); } } } public function video_listing(){ if (isset($this->session->userdata['logged_in'])) { $data = $this->session->userdata['logged_in']; $data1['video'] = $this->Admin_model->video_list(); $this->load->view('back-end/templates/sidebar'); $this->load->view('back-end/templates/header'); $this->load->view('back-end/pages/video', $data1); $this->load->view('back-end/templates/footer'); } else { $this->session->set_flashdata('alert_info', 'Please login first..'); $this->session->set_flashdata('alert_class', 'alert-danger'); redirect('admin/Admin_controller/index'); } } public function video_edit($id) { if (isset($this->session->userdata['logged_in'])) { $data = $this->session->userdata['logged_in']; $data1['videos'] = $this->Admin_model->edit_video($id); $this->load->view('back-end/templates/sidebar'); $this->load->view('back-end/templates/header'); $this->load->view('back-end/pages/edit_video', $data1); $this->load->view('back-end/templates/footer'); } else { $this->session->set_flashdata('alert_info', 'Please login first..'); $this->session->set_flashdata('alert_class', 'alert-danger'); redirect('admin/Admin_controller/index'); } } public function update_video() { $id = $this->input->post('id'); $this->form_validation->set_rules('videourl', 'videourl', 'trim|required'); $config['upload_path'] = './uploads/video'; $config['allowed_types'] = 'gif|jpg|png'; $config['max_size'] = 1000000; $this->load->library('upload'); $this->upload->initialize($config); $this->upload->do_upload(''); if (!$this->upload->do_upload('video_image')) { $data = array( 'video_url' => $this->input->post('videourl'), ); } if ($this->upload->do_upload('video_image')) { $videofoto = $this->upload->data(); $video_image = $videofoto['file_name']; $data = array( 'video_image' => $video_image , 'video_url' => $this->input->post('videourl'), ); } $result = $this->Admin_model->update_video_content($id, $data); if ($result) { $this->session->set_flashdata('alert_info', 'Video updated successfully'); $this->session->set_flashdata('alert_class', 'alert-success'); redirect('admin/Admin_controller/video_listing'); } else { $this->session->set_flashdata('alert_info', 'Data updation failed'); $this->session->set_flashdata('alert_class', 'alert-danger'); redirect('admin/Admin_controller/video_edit'); } } public function delete_video($id) { if ($this->Admin_model->delete_videos($id)) { $this->session->set_flashdata('alert_info', 'Data Deleted successfully'); $this->session->set_flashdata('alert_class', 'alert-successs'); redirect('admin/Admin_controller/video_listing'); } else { $this->session->set_flashdata('alert_info', 'Data deletion failed'); $this->session->set_flashdata('alert_class', 'alert-danger'); redirect('admin/Admin_controller/video_listing'); } } public function logout() { $this->session->unset_userdata('user_type'); $this->session->unset_userdata('name'); $this->session->unset_userdata('email'); $this->session->sess_destroy(); redirect('admin/Admin_controller/index'); } }