<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Pass extends CI_Controller {

	function __construct(){
		parent::__construct();
        	$this->load->helper('url');
                $this->load->library('session'); //加载session
		$this->load->model('CsdjDB');
		$this->load->model('CsdjAdmin');
                $this->db->cache_off();
	        $this->CsdjAdmin->Admin_Login();
	}


	public function index()
	{
            $this->load->view('admin/pass');
        }

	public function edit()
	{
                $this->CsdjAdmin->Admin_Qx('12');
		$pass1 = $this->security->xss_clean($this->input->post('pass1', TRUE));
		$pass2 = $this->security->xss_clean($this->input->post('pass2', TRUE));

		if (empty($pass1)||empty($pass2)){
			$this->CsdjAdmin->Admin_Url('<font color=red>原密码和新密码都不能为空！</font>',site_url('admin/pass/'));
		}

		if(md5(md5($pass1))!=$this->session->userdata('admin_pass')){
			$this->CsdjAdmin->Admin_Url('<font color=red>原密码不能正确哦！</font>',site_url('admin/pass/'));
                }else{
	                    $updata['CS_AdminPass']  = md5($pass2);
                            $this->CsdjDB->get_update ('admin',$this->session->userdata('admin_id'),$updata);

                            $admindata['admin_pass']=md5(md5($pass2));
                            $this->session->set_userdata($admindata); //更新缓存

			    $this->CsdjAdmin->Admin_Url('<font color=#0000ff>恭喜您，修改成功！</font>',site_url('admin/pass/'),'ok');
                }

        }
}

