403Webshell
Server IP : 101.53.144.229  /  Your IP : 216.73.216.104
Web Server : Apache
System : Linux host.gdigitalindia.in 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User : digitalshiksha ( 1179)
PHP Version : 5.6.40
Disable Function : eval,show_source,system,shell_exec,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,dl,show_source,curl_multi_exechellcmd, ini_restore,apache_get_modules,get_cfg_var,passthru, exec ,proc_get_status,fpassthru,c999_buff_prepare,c999_sess_put,c99_buff_prepare,c99_sess_put,proc_close,ini_alter,dl,symlink,link,proc_close,ini_alter,dl,symlink,link,mail
MySQL : ON  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/digitalshiksha/www/application/controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/digitalshiksha/www/application/controllers/Admin.php
<?php
defined('BASEPATH') or exit('No direct script access allowed');

class Admin extends CI_Controller
{
	function __construct()
	{
		parent::__construct();

		// Load form validation ibrary & user model 
		$this->load->library('form_validation');
		$this->load->model('Admin_model');
		$this->load->model('Blog_model');
		$this->load->model('Product_model');

		// Admin login status 
		$this->isAdminLoggedIn = $this->session->userdata('isAdminLoggedIn');
		$this->Global = $this->Global_model->getdata();
		$this->load->helper(array('form', 'url'));
	}

	public function index()
	{
		if (isset($_SESSION['isAdminLoggedIn'])) {
			redirect('admin/dashboard');
		} else {
			redirect('admin/login');
		}
	}

	public function dashboard()
	{
		if (!isset($_SESSION['isAdminLoggedIn'])) {
			redirect('admin/login');
		} else {
			$this->load->view('admin/dashboard', $this->Global);
		}
	}

	public function login()
	{
		if (isset($_SESSION['isAdminLoggedIn'])) {
			redirect('admin/dashboard');
		} else {
			$this->Global = array();
			// If login request submitted 
			if (isset($_POST['loginSubmit'])) {
				$this->form_validation->set_rules('email', 'Email', 'required|valid_email');
				$this->form_validation->set_rules('password', 'password', 'required');

				if ($this->form_validation->run() == true) {
					$con = array(
						'returnType' => 'single',
						'conditions' => array(
							'email' => $this->input->post('email'),
							'password' => sha1($this->input->post('password')),
						)
					);
					$checkLogin = $this->Admin_model->getRows($con);
					if ($checkLogin) {
						$this->session->set_userdata('isAdminLoggedIn', TRUE);
						$this->session->set_userdata('userId', $checkLogin['id']);
						redirect('admin/dashboard/');
					} else {
						$this->session->set_flashdata('error_msg', ' Wrong email or password, please try again.');
					}
				} else {
					$this->session->set_flashdata('error_msg', ' Please fill all the mandatory fields.');
				}
			}

			// Load view 
			$this->load->view('admin/sign-in', $this->Global);
		}
	}
	public function logout()
	{
		$this->session->unset_userdata('isAdminLoggedIn');
		$this->session->unset_userdata('userId');
		$this->session->sess_destroy();
		redirect('admin/login');
	}
	public function forgot_password()
	{
		if (isset($_POST['email'])) {
			$email = $this->input->post('email');
			$findemail = $this->Admin_model->ForgotPassword($email);
			if ($findemail) {
				$this->Admin_model->sendpassword($findemail);
			} else {
				$this->session->set_flashdata('error_msg', ' Email not found!');
				redirect(base_url() . 'admin/login', 'refresh');
			}
		}
		$this->load->view('admin/forgot');
	}

	public function upload($file, $dir = 'images')
	{
		if (!isset($_SESSION['isAdminLoggedIn'])) {
			redirect('admin/login');
		} else {
			$config['upload_path']          = FCPATH . 'assets/front/' . $dir;
			$config['allowed_types']        = '*';

			$this->load->library('upload', $config);

			$this->upload->initialize($config);
			if (!$this->upload->do_upload($file)) {
				$data['error_message'] =  $this->upload->display_errors();
				$this->session->set_flashdata('error_msg', $data['error_message']);
				redirect($_SERVER['HTTP_REFERER']);
			} else {
				return $this->upload->data();
			}
		}
	}

	public function create_slug($name, $table, $field)
	{
		if (!isset($_SESSION['isAdminLoggedIn'])) {
			redirect('admin/login');
		} else {
			// Use this code to create a slug
			// $title = "My name is Vishwas Moorjani";
			// $table = "product";
			// $field = "link";
			// $a =  $this->create_slug($title, $table, $field);

			$slug = $name;
			$slug = url_title($name);
			$key = NULL;
			$value = NULL;
			$i = 0;
			$params = array();
			$params[$field] = $slug;

			if ($key) $params["$key !="] = $value;

			while ($this->db->from($table)->where($params)->get()->num_rows()) {
				if (!preg_match('/-{1}[0-9]+$/', $slug))
					$slug .= '-' . ++$i;
				else
					$slug = preg_replace('/[0-9]+$/', ++$i, $slug);
				$params[$field] = $slug;
			}

			return strtolower($slug);
		}
	}

	public function activate($table = NULL, $link = NULL)
	{
		if (!isset($_SESSION['isAdminLoggedIn'])) {
			redirect('admin/login');
		} else {
			$this->load->model('Product_model');
			$this->Product_model->activate($table, $link);
			redirect($_SERVER['HTTP_REFERER']);
		}
	}

	public function deactivate($table = NULL, $link = NULL)
	{
		if (!isset($_SESSION['isAdminLoggedIn'])) {
			redirect('admin/login');
		} else {
			$this->load->model('Product_model');
			$this->Product_model->deactivate($table, $link);
			redirect($_SERVER['HTTP_REFERER']);
		}
	}

	public function delete($table = NULL, $link = NULL)
	{
		if (!isset($_SESSION['isAdminLoggedIn'])) {
			redirect('admin/login');
		} else {
			$this->load->model('Product_model');
			$this->Product_model->delete($table, $link);
			redirect($_SERVER['HTTP_REFERER']);
		}
	}


	public function globalsettings()
	{
		if (!isset($_SESSION['isAdminLoggedIn'])) {
			redirect('admin/login');
		} else {
			$this->load->view('admin/globalsettings', $this->Global);
		}
	}

	public function editsettings()
	{
		if (!isset($_SESSION['isAdminLoggedIn'])) {
			redirect('admin/login');
		} else {
			if (isset($_POST['submit'])) {
				$name = $_POST['name'];
				$value = $_POST['value'];
				$this->Global_model->editsettings($name, $value);
			}
			redirect('admin/globalsettings');
		}
	}

	public function change_password()
	{
		if (!isset($_SESSION['isAdminLoggedIn'])) {
			redirect('admin/login');
		} else {
			$this->load->view('admin/change-password');
		}
	}

	function dragDropUpload($link)
	{
		if (!empty($_FILES)) {
			// File upload configuration 
			$config['upload_path']          = FCPATH . 'assets/front/images/';
			$config['allowed_types']        = 'gif|jpg|png|jpeg|webp|svg';

			// Load and initialize upload library 
			$this->load->library('upload', $config);
			$this->upload->initialize($config);

			// Upload file to the server 
			if ($this->upload->do_upload('file')) {
					$configer =  array(
						'image_library' => 'gd2',
						'source_image'  =>  $this->upload->data()['full_path'],
						'maintain_ratio' =>  TRUE,
						'height'       =>  '1100',
						'new_image' => $this->upload->data()['full_path'],
					);
					$this->load->library('image_lib', $configer);
					$a = $this->image_lib->resize();
					if($a == 1){
						$fileData = $this->upload->data();
					}
				$fileData = $this->upload->data();
				$this->load->model('Product_model');
				$images = $this->Product_model->getimages($link);
				$target_value = $fileData['file_name'];
				if ($images->images == "[]") {
					$a = trim($images->images, "]") . json_encode($target_value) . "]";
				} else {
					$a = (trim($images->images, "]") . "," . json_encode($target_value)) . "]";
				}
				$insert = $this->Product_model->saveimage($link, $a);
			}
		}
	}

	public function blogs()
	{
		if (!isset($_SESSION['isAdminLoggedIn'])) {
			redirect('admin/login');
		} else {
			$this->Global['blogs'] = $this->Blog_model->getblogs();
			$this->load->view('admin/blogs', $this->Global);
		}
	}

	public function addblog()
	{
		if (!isset($_SESSION['isAdminLoggedIn'])) {
			redirect('admin/login');
		} else {
			if (isset($_POST['submit'])) {
				$data = $_POST;
				$data['category'] = json_encode($_POST['category']);
				$title = $_POST['post_title'];
				$table = "blog";
				$field = "link";
				$data['link'] =  $this->create_slug($title, $table, $field);
				
				$image = $this->upload('image', 'images');
				$data['image'] = $image['file_name'];
				unset($data["submit"]);
				$this->Blog_model->addblog($data);
			}
			$this->Global['categories'] = $this->Product_model->getmaincategories();
			$this->load->view('admin/add-blog',$this->Global);
		}
	}

	public function editblog($slug)
	{
		if (!isset($_SESSION['isAdminLoggedIn'])) {
			redirect('admin/login');
		} else {
			if (isset($_POST['submit'])) {
				$data = $_POST;
				$data['category'] = json_encode($_POST['category']);
				if (!empty($_FILES['image']['name'])) {
					$image = $this->upload('image', 'images');
				    $data['image'] = $image['file_name'];
				}
				unset($data["submit"]);
				$this->Blog_model->editpost($slug,$data);
				
			}
			$blog = $this->Blog_model->getblogs('id', $slug);
			$this->Global['blog'] = $blog[0];
			$this->Global['categories'] = $this->Product_model->getmaincategories();
			$this->load->view('admin/edit-blog', $this->Global);
		}
	}
	
	public function removeblog($link = NULL)
	{
		if (!isset($_SESSION['isAdminLoggedIn'])) {
			redirect('admin/login');
		} else {
			
			$this->Blog_model->removeimg('blog','image','link', $link);
			echo ("done");
		}
	}

	public function categories()
	{
		if (!isset($_SESSION['isAdminLoggedIn'])) {
			redirect('admin/login');
		} else {
			$this->load->model('Product_model');
			$this->Global['categories'] = $this->Product_model->getmaincategories();
			$this->Global['title'] = "Categories";
			$this->load->view('admin/category', $this->Global);
		}
	}

	public function addcategory()
	{
		if (!isset($_SESSION['isAdminLoggedIn'])) {
			redirect('admin/login');
		} else {
			if (isset($_POST['submit'])) {

				$title = $_POST['name'];
				$table = "category";
				$field = "link";
				$slug =  $this->create_slug($title, $table, $field);
				$data = $_POST;
				$data['link'] = $slug;
				unset($data["submit"]);
			    $this->load->model('Product_model');
				$this->Admin_model->addcategory($data);
			}
			$this->load->model('Product_model');
			$this->Global['categories'] = $this->Product_model->getmaincategories();
			$this->load->view('admin/add-category', $this->Global);
		}
	}

	public function editcategory($slug)
	{
		if (!isset($_SESSION['isAdminLoggedIn'])) {
			redirect('admin/login');
		} else {
			if (isset($_POST['submit'])) {
				$data = $_POST;
				unset($data["submit"]);
				$this->load->model('Product_model');
				$this->Admin_model->editcategory($data);
                redirect('admin/categories');
			}
			$this->load->model('Product_model');
			$this->Global['categories'] = $this->Product_model->getmaincategories();
			$category = $this->Product_model->get_category($slug);
			$this->Global['cat'] = json_decode(json_encode($category), true);
			$this->load->view('admin/edit-category', $this->Global);
		}
	}

	public function form()
    {
    	if (!isset($_SESSION['isAdminLoggedIn'])) {
    		redirect('admin/login');
    	} else {
    		$query = $this->db->query("Select * from form order by id desc");
    		$this->Global['contacts'] = $query->result_array();
    		$this->load->view('admin/contact', $this->Global);
    	}
    }

	public function contactdetails($req){
	    if (!isset($_SESSION['isAdminLoggedIn'])) {
			redirect('admin/login');
		} else {
			$query = $this->db->query("Select * from form where id='$req'");
			$this->Global['message'] = $query->row_array();
			$this->load->view('admin/contact-details', $this->Global);
		}
	}

	public function enquiry()
    {
    	if (!isset($_SESSION['isAdminLoggedIn'])) {
    		redirect('admin/login');
    	} else {
    		$query = $this->db->query("Select * from enquiry order by id desc");
    		$this->Global['contacts'] = $query->result_array();
    		$this->load->view('admin/enquiry', $this->Global);
    	}
    }

	public function enquirydetails($req){
	    if (!isset($_SESSION['isAdminLoggedIn'])) {
			redirect('admin/login');
		} else {
			$query = $this->db->query("Select * from enquiry where id='$req'");
			$this->Global['message'] = $query->row_array();
			$this->load->view('admin/enquiry-details', $this->Global);
		}
	}
}


Youez - 2016 - github.com/yon3zu
LinuXploit