<? if (!defined('BASEPATH')) exit('No direct script access allowed');

class logout extends Controller {

	var $settings;

	function Logout() {

		parent::Controller();
		$this->CI =& get_instance();
        $this->CI->load->helper('cookie');

		//$this->settings = $this->mdl_settings->get();

		// if the site has been disabled from the back end, do not allow the viewer to go any further
		//if (!$this->settings->enabled) {
			//redirect('site_disabled');
		//}

	}

	function index() {


		$userID = $this->session->userdata('userID');
		$this->CI->load->helper('cookie');
		//$this->update_logout();
		$query = $this->db->query("UPDATE admin set is_login = 0 where id='$userID'");
		delete_cookie('userID');
		delete_cookie('logged_in');
		$sessiondata = array('logged_in' => 0,'user_name' => '','userID' => '');

		$this->CI->session->set_userdata($sessiondata);

		$this->CI->session->sess_destroy();
		$this->CI->no_cache();

		//redirect('login/logoutprocess');
		redirect('admin/cpanel');

		//$this->load->view('login/loginview');


	}




    function no_cache() {
        $this->output->set_header('Last-Modified: ' . gmdate("D, d M Y H:i:s") . ' GMT');
        $this->output->set_header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
        $this->output->set_header('Pragma: no-cache');
        $this->output->set_header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
    }




	function update_logout()
	{

        $logid = $this->cpanel_login->get_logID();

			$data['logout_time'] = date("g:i a");
			$data['logout_dt'] = date('Y-m-d');

			$where = "log_id = $logid";
			$sql = $this->db->update_string('login', $data, $where);
			$query = $this->db->query($sql);





	}






}

?>