<?php
/**
 * Copy Right IJH.CC
 * Each engineer has a duty to keep the code elegant
 * $Id$
 */
if(!defined('__CORE_DIR')){
    exit("Access Denied");
}

class Ctl_XiChe_Mcenter_Pwd extends Ctl_XiChe_Mcenter
{
  
  
  public function index()
  {
  	$this->tmpl = 'xiche/mcenter/pwd/forgot.html';
  } 
  
  // 商户修改密码
  public function setpwd() 
  {
	$password = $this->GP('password');
	$password_new = $this->GP('password_new');

	if(!$password || !$password_new){
		$this->msgbox->add(array('内容没有输入完整'),212);
		$this->msgbox->response();
	}else if(strlen($password_new) < 6 || strlen($password_new) > 32 ){
		$this->msgbox->add(array('新密码长度应在6-32个字符'),213);
		$this->msgbox->response();
	}else if($password == $password_new){
		$this->msgbox->add(array('原密码和新密码不能相同'),214);
		$this->msgbox->response();
	}else{
	    if(md5($password) != $this->staff['passwd']){
		    $this->msgbox->add(array('原密码输入不正确'),215);
		    $this->msgbox->response();
	    }else{  
			$up = K::M('staff/staff')->updates($this->staff['staff_id'],array('passwd'=>md5($password_new)));
			if($up){
			   $this->msgbox->add(array('修改密码成功,需重新登录'));
		       $this->msgbox->response();
			}else{
			   $this->msgbox->add(array('密码修改失败'),216);
		       $this->msgbox->response();
			}
	    }
	}
  }
}