<?php
/*
 * 74cms 个人账户中心
 * ============================================================================
 * 版权所有: 骑士网络，并保留所有权利。
 * 网站地址: http://www.74cms.com；
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和
 * 使用；不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
*/
define('IN_QISHI', true);
require_once(dirname(__FILE__) . '/personal_common.php'); 
$act = !empty($_GET['act'])?trim($_GET['act']):'security';
//账号管理
if ($act=='security')
{
	$uid = intval($_SESSION['uid']);
	$pid = intval(get_pid($uid)); 
	$member = get_user_info($uid);
	$smarty->assign('member',$member);
	$smarty->assign('title','账号安全 - 个人会员中心 - '.$_CFG['site_name']);
	$smarty->display('member_personal/personal_security.htm');
}
//修改密码
elseif($act== 'edit_password')
{
	$uid = intval($_SESSION['uid']);
	$pid = intval(get_pid($uid)); 
	$member = get_user_info($uid);
	$smarty->assign('member',$member);
	$smarty->assign('title','修改密码 - 个人会员中心 - '.$_CFG['site_name']);
	$smarty->display('member_personal/personal_edit_password.htm');
}
//修改登录密码
elseif($act== 'save_password')
{
	$uid = $_SESSION['uid'];
	$opassword = trim($_POST['opassword'])?trim($_POST['opassword']):showmsg('请填写你的旧密码',1);
	$npassword = $_POST['npassword']?$_POST['npassword']:showmsg('请填写你的新密码',1);
	$napassword = $_POST['napassword']?$_POST['napassword']:showmsg('请填写确认新密码',1);
	if($npassword !== $napassword){
		showmsg('两次密码输入不一致!~',1);
	}else{
		if(strlen($npassword) < 6){
			showmsg('密码过短，请重新输入!~',1);
		}else{ 
			$user_info = get_user_info($uid);
			$opass = md5(md5($opassword).$user_info['pwd_hash'].$QS_pwdhash); 
			$npass = md5(md5($npassword).$user_info['pwd_hash'].$QS_pwdhash);  
			if($opass !== $user_info['password'] ){
				showmsg('旧密码输入错误！',1);
			}else{ 
				$setsqlarr['password'] = $npass;  
				updatetable(table('members'),$setsqlarr,' uid = '.$uid);
				showmsg("密码修改成功",2);
			}
		}
	}
}
//邮箱认证
elseif($act=='user_email')
{
	$uid = intval($_SESSION['uid']);
	$pid = intval(get_pid($uid)); 
	$member = get_user_info($uid);
	$smarty->assign('member',$member);
	$smarty->assign('title','邮箱认证 - 个人会员中心 - '.$_CFG['site_name']);
	if(trim($member['email_audit'])=='1'){
		$smarty->display('member_personal/personal_email_identity.htm');
	}else{
		$smarty->display('member_personal/personal_user_email.htm');
	}
}
//邮箱认证   修改邮箱
elseif($act=='edit_user_email')
{
	$uid = intval($_SESSION['uid']);
	$pid = intval(get_pid($uid)); 
	$member = get_user_info($uid);
	$smarty->assign('member',$member);
	$smarty->assign('title','邮箱认证 - 个人会员中心 - '.$_CFG['site_name']);
	$smarty->display('member_personal/personal_edit_user_email.htm');
}
//邮箱认证  成功
elseif($act=='user_email_seccess')
{
	$uid = intval($_SESSION['uid']);
	$pid = intval(get_pid($uid)); 
	$member = get_user_info($uid);
	$email = trim($_POST['email']);
	$setsqlarr['email'] = $email;
	$setsqlarr['email_audit'] = '1';
	$members_info = get_user_info($uid); 
	$setsqlresume['email']= $email;	
	updatetable(table('resume'),$setsqlresume,"  uid='{$uid}'"); 
	if(!updatetable(table('members'),$setsqlarr," uid ={$uid}")){
		showmsg("邮箱认证失败!",1);
	}
	$smarty->assign('member',$member);
	$smarty->assign('title','邮箱认证成功 - 个人会员中心 - '.$_CFG['site_name']);
	$smarty->display('member_personal/personal_user_email_seccess.htm');
}
//手机认证 
elseif($act=='user_mobile')
{
	$uid = intval($_SESSION['uid']);
	$pid = intval(get_pid($uid)); 
	$member = get_user_info($uid);
	$smarty->assign('member',$member);
	$smarty->assign('title','手机认证 - 个人会员中心 - '.$_CFG['site_name']);
	if(intval($member['mobile_audit'])==1){
		$smarty->display('member_personal/personal_mobile_identity.htm');
	}else{
		$smarty->display('member_personal/personal_user_mobile.htm');
	}
}
//手机认证  修改手机
elseif($act=='edit_user_mobile')
{
	$uid = intval($_SESSION['uid']);
	$pid = intval(get_pid($uid)); 
	$member = get_user_info($uid);
	$smarty->assign('member',$member);
	$smarty->assign('title','手机认证 - 个人会员中心 - '.$_CFG['site_name']);
	$smarty->display('member_personal/personal_edit_user_mobile.htm');
}
//手机认证 成功
elseif($act=='user_mobile_seccess')
{
	$uid = intval($_SESSION['uid']);
	$pid = intval(get_pid($uid)); 
	$member = get_user_info($uid);
	$mobile = trim($_POST['mobile']);
	$setsqlarr['mobile'] = $mobile;
	$setsqlarr['mobile_audit'] = '1';
	$members_info = get_user_info($uid); 
	$setsqlresume['telephone']= $mobile;	
	updatetable(table('resume'),$setsqlresume,"  uid='{$uid}'"); 
	if(!updatetable(table('members'),$setsqlarr," uid ={$uid}")){
		showmsg("手机认证失败!",1);
	}
	$smarty->assign('member',$member);
	$smarty->assign('title','手机认证成功 - 个人会员中心 - '.$_CFG['site_name']);
	$smarty->display('member_personal/personal_user_mobile_seccess.htm');
}
//账号绑定
elseif($act == 'binding')
{	
	$smarty->assign('title','账号绑定 - 个人会员中心 -'.$_CFG['site_name']); 
	$smarty->assign('user',get_user_info(intval($_SESSION['uid'])));
	$smarty->display('member_personal/personal_binding.htm');
}
elseif ($act=='del_qq_binding')
{
	$db->query("UPDATE ".table('members')." SET qq_openid = ''  WHERE uid='{$_SESSION[uid]}' LIMIT 1");
	showmsg('操作成功！',2);
}
elseif ($act=='del_sina_binding')
{
	$db->query("UPDATE ".table('members')." SET sina_access_token = ''  WHERE uid='{$_SESSION[uid]}' LIMIT 1");
	showmsg('操作成功！',2);
}
elseif ($act=='del_taobao_binding')
{
	$db->query("UPDATE ".table('members')." SET taobao_access_token = ''  WHERE uid='{$_SESSION[uid]}' LIMIT 1");
	showmsg('操作成功！',2);
}
unset($smarty);
?>