<?php
if(!isset($get_act)) $get_act="";
$this_err="";
if($get_act=="1"){
	$this_uid=0;
	$str_code=get_safecode($get_findpwd_code);
	if($str_code!=get_cookie("user_code_findpwd")){
		$obj_msg->alert("输入验证码不正确！");
		$obj_msg->on_history_back();
		exit;
	}
	$arr_info=$obj_ctl_user->get_user_id($get_name);
	if( isset($arr_info[$get_name]) ){
		$this_uid=$arr_info[$get_name];
	}else{
		$obj_msg->alert("输入账号不存在！");
		$obj_msg->on_history_back();
		exit;
	}
}
if($get_act=="2"){
	$arr_info=$obj_ctl_user->get_user_info($get_finduid);
	if(isset($arr_info["user_email"])&&$arr_info["user_email"]!=""){
		$obj_tab_findpwd=new cls_tab_sys_findpwd;
		$arr_fields=array();
		$arr_fields["findpwd_user_id"]=$get_finduid;
		$arr_fields["findpwd_email"]=$arr_info["user_email"];
		$arr_return=$obj_tab_findpwd->on_save($arr_fields);
		if($arr_return["err"]==""){
			$obj_ctl_mail=new cls_ctl_mail();
			$str_webname="";
			if(isset($cft_sys["site_name"])) $str_webname=$cft_sys["site_name"];
			$str_email_to=$arr_info["user_email"];
			$str_content="尊敬的".$str_webname."用户： <br>您好！<br>您在本站申请了找回密码，请点击以下链接确认更改。<a href=\"".WEB_URL."/index.php?app=findpwd&act=3&uid=".$get_finduid."&key=".$arr_return["key"]."\" target=\"_blank\">".WEB_URL."/index.php?app=findpwd&act=3&uid=".$get_finduid."&key=".$arr_return["key"]."</a>";
			$arr_msg=$obj_ctl_mail->on_send($str_email_to,"找回密码",$str_content);
			if($arr_msg["err"]!=""){
				$obj_msg->alert("发送邮件失败!");
				$obj_msg->on_history_back();
				exit;
			}
			$arr_x=explode("@",$str_email_to);
			$str_x=$arr_x[0];
			if(strlen($str_x)>3){
				$str_1=substr($str_x,0,2);
				$str_2=substr($str_x,-1);
			}
			$lng_x=strlen($str_x)-3;
			$str_y=str_repeat("*",$lng_x);
			$this_email=$str_1.$str_y.$str_2."@".$arr_x[1];

		}else{
			$obj_msg->alert("找回密码失败!");
			$obj_msg->on_history_back();
			exit;
		}
	}else{
			$obj_msg->alert("您没有填写邮箱，不能通过邮箱找回，请联系客服!");
			$obj_msg->on_history_back();
			exit;
	}
}

if($get_act==3){
	if(!isset($get_uid)||!isset($get_key)||!is_numeric($get_uid)){
		$this_err="访问已过期，请<a href='?app=findpwd'>重新申请找回密码</a>!";
	}else{
		$str_key=chk_escape($get_key);
		$get_uid=intval($get_uid);
		$str_sql="select * from ".DB_PRE."sys_findpwd where findpwd_user_id=".$get_uid." and findpwd_key='".$str_key."'";
		$obj_result = $obj_db->query($str_sql);
		if($obj_rs = $obj_db->fetch_array($obj_result)){
		}else{
			$this_err="访问已过期，请<a href='?app=findpwd' style='color:#ff0000'>重新申请找回密码</a>!";
		}
	}
}
if($get_act==4){
	if(!isset($get_uid)||!isset($get_key)||!is_numeric($get_uid)){
		$this_err="访问已过期，请<a href='?app=findpwd'>重新申请找回密码</a>!";
	}else{
		if(!isset($get_pwd1)||!isset($get_pwd2)){
			$obj_msg->alert("请输入密码!");
			$obj_msg->on_history_back();
			exit;
		}
		if($get_pwd1!=$get_pwd2){
			$obj_msg->alert("两次输入密码不一至!");
			$obj_msg->on_history_back();
			exit;
		}
		$arr_msg=chk_pwd($get_pwd1);
		if($arr_msg["err"]!=""){
			$obj_msg->alert($arr_msg["err"]);
			$obj_msg->on_history_back();
			exit;
		}
		$str_key=chk_escape($get_key);
		$get_uid=intval($get_uid);
		$str_sql="select * from ".DB_PRE."sys_findpwd where findpwd_user_id=".$get_uid." and findpwd_key='".$str_key."'";
		$obj_result = $obj_db->query($str_sql);
		if($obj_rs = $obj_db->fetch_array($obj_result)){
			$str_sql="select user_pwd_key from ".DB_PRE."sys_user where user_id='".$obj_rs["findpwd_user_id"]."'";
			$obj_result2=$obj_db->query($str_sql);
			if($obj_rs2=$obj_db->fetch_array($obj_result2))
			{
				//更新新密码
				$str_new_pwd=get_pwd($get_pwd1,$obj_rs2["user_pwd_key"]);
				$str_sql="update ".DB_PRE."sys_user set user_pwd='".$str_new_pwd."' where user_id='".$obj_rs["findpwd_user_id"]."'";
				$arr_return["err"]=$obj_db->execute($str_sql);
				if($arr_return["err"]!=""){
					$obj_msg->alert("更新密码失败！");
					$obj_msg->on_history_back();
					exit;
				}else{
					//清除申请记录
					$str_sql="delete from ".DB_PRE."sys_findpwd where findpwd_user_id=".$obj_rs["findpwd_user_id"];
					$obj_db->execute($str_sql);
				}
			}
		}else{
			$this_err="访问已过期，请<a href='?app=findpwd' style='color:#ff0000'>重新申请找回密码</a>!";
		}
	}
}

//本周人气推荐
$lng_time=get_toweek_time();
$lng_time=0;
$obj_result = $obj_db->query("SELECT * FROM ".DB_PRE."hr_job where job_updatetime>'".$lng_time."' order by job_hits desc limit 0,10");
$lng_x=1;
$arr_week_job=array();
while($obj_rs = $obj_db->fetch_array($obj_result)){
	if($lng_x==0){
		$lng_x=1;
		$obj_rs["rowid"]=1;
	}else{
		$lng_x=0;
		$obj_rs["rowid"]=2;
	}
	if($obj_rs["job_pay1"]==0&&$obj_rs["job_pay2"]==0){
		$obj_rs["pay"]="面议";
	}else{
		$obj_rs["pay"]=$obj_rs["job_pay1"]."~".$obj_rs["job_pay2"];
	}
	$arr_week_job[]=$obj_rs;
}

?>