<?php
$obj_tab_upload_attatch=new cls_tab_other_upload_attatch();
$obj_tab_sys_verify=new cls_tab_sys_verify();

($get_type==4)? $get_step=3:$get_step=$get_type;
$sys_user_regtype=SYS_USER_REGTYPE;
switch($get_act){
	case "save":
		$this_msg="";
		$arr_return=$obj_tab_upload_attatch->on_upload();
		if($arr_return["err"]==""){
			$lng_id=0;
			$obj_result=$obj_db->query("select verify_id from ".DB_PRE."sys_verify where verify_type=".$get_type);
			if($obj_rs=$obj_db->fetch_array($obj_result)){
				$lng_id=$obj_rs["verify_id"];
			}
			$arr_fields=array();
			$arr_fields["verify_id"]=$lng_id;
			$arr_fields["verify_user_id"]=$obj_ctl_user->id;
			$arr_fields["verify_val"]=$arr_return["path"];
			$arr_fields["verify_type"]=$get_type;
			$arr_fields["verify_state"]=0;
			$arr_msg=$obj_tab_sys_verify->on_save($arr_fields);
			if($arr_msg["err"]!=""){
				$this_msg=$arr_msg["err"];
			}
		}else{
			$this_msg=$arr_return["err"];
		}
		break;
	case "sendemail":
		$arr_return=array("id"=>0,"msg"=>"成功发出,请登录邮箱验证");
		$lng_id=0;
		$obj_result=$obj_db->query("select verify_id from ".DB_PRE."sys_verify where verify_type=".$get_type." and verify_user_id=".$obj_ctl_user->id);
		if($obj_rs=$obj_db->fetch_array($obj_result)){
			$lng_id=$obj_rs["verify_id"];
		}
		$arr_fields=array();
		$arr_fields["verify_id"]=$lng_id;
		$arr_fields["verify_user_id"]=$obj_ctl_user->id;
		if(SYS_USER_REGTYPE==1){
			//邮箱即账号
			$get_txtemail=$obj_ctl_user->uname;
		}
		$arr_fields["verify_val"]=$get_txtemail;
		$arr_fields["verify_type"]=1;
		$arr_fields["verify_state"]=0;
		$arr_msg=$obj_tab_sys_verify->on_save($arr_fields);
		if($arr_msg["err"]==""){
			$obj_tab_findpwd=new cls_tab_sys_findpwd;
			$arr_fields=array();
			$arr_fields["findpwd_user_id"]=$obj_ctl_user->id;
			$arr_fields["findpwd_email"]=$get_txtemail;
			$arr_msg=$obj_tab_findpwd->on_save($arr_fields);
			if($arr_msg["err"]==""){
				$obj_ctl_mail=new cls_ctl_mail;
				$str_content="您好，请点击以下连接验证您的邮箱：<br>".WEB_URL."/index.php?app=verify_email&uid=".$obj_ctl_user->id."&key=".$arr_msg["key"];
				$arr_msg=$obj_ctl_mail->on_send($get_txtemail,$obj_tab_sys_config->get_val("sys",'site_name')."会员箱邮验证",$str_content);
				if($arr_msg["err"]!=""){
					$arr_return["id"]=2;
					$arr_return["msg"]=$arr_msg["err"];
				}
			}else{
				$arr_return["id"]=3;
				$arr_return["msg"]=$arr_msg["err"];
			}
		}else{
			$arr_return["id"]=1;
			$arr_return["msg"]=$arr_msg["err"];
		}
		echo $obj_msg->json_encode($arr_return);exit;
		break;
	case "email":
		$this_email="";
		$obj_result=$obj_db->query("select verify_val from ".DB_PRE."sys_verify where verify_type='".$get_type."' and verify_user_id='".$obj_ctl_user->id."'");
		if($obj_rs=$obj_db->fetch_array($obj_result)){
			$this_email=$obj_rs["verify_val"];
		}else{
			$obj_result=$obj_db->query("select user_email from ".DB_PRE."sys_user where user_id='".$obj_ctl_user->id."'");
			if($obj_rs=$obj_db->fetch_array($obj_result)){
				$this_email=$obj_rs["user_email"];
			}
		}
		break;
	default:
		$this_allowpic=implode(",",$obj_tab_upload_attatch->get_allow_pic());
		$this_allowsize=format_filesize($obj_tab_upload_attatch->get_upload_config("filesize"),"M")."M";
}
?>