<?php
if(!defined('IN_MYMPS')) exit('Forbidden');
if($ac == 'nobind'){
	$db->query("UPDATE `{$db_mymps}member` SET openid = '' $where");
	write_msg('','index.php?m=base&success=15');
}

if($ac=='resume'){
	if($if_corp==1) write_msg('企业用户暂不支持创建简历^_^');
	if(submit_check('base_submit')){
		if(empty($xingming)) write_msg('请填写您的真实姓名!');
		if(empty($zhuangtai)) write_msg('请选择目前工作状态!');
		//if(empty($yuexin)) write_msg('请选择月薪!');
		//if(empty($jingyan)) write_msg('请选择工作经验!');
		//if(empty($xueli)) write_msg('请选择您的最高学历!');
		$get = $db->getRow("SELECT id,zhaopian FROM `{$db_mymps}resume` WHERE userid = '$s_uid'");
		
		require MYMPS_INC."/upfile.fun.php";
		$name_file = "zhaopian";
		if ($_FILES[$name_file]["name"]){
			check_upimage($name_file);
			$destination = "/face/".date('Ymd')."/";
			$mymps_image = start_upload($name_file,$destination,0,$mymps_mymps['cfg_memberlogo_limit']['width'],$mymps_mymps['cfg_memberlogo_limit']['height'],$get['zhaopian'],$get['zhaopian']);
			$zhaopian=$mymps_image[0];
			if($get['id']>0){
				$db->query("UPDATE `{$db_mymps}resume` SET xingming='$xingming',xueli = '$xueli',yuanxiao='$yuanxiao',jingli='$jingli',jieshao='$jieshao',zhuangtai='$zhuangtai',yuexin='$yuexin',chusheng='$chusheng',zhaopian='$zhaopian',jingyan='$jingyan' {$where}");
			}else{
				$db->query("INSERT INTO `{$db_mymps}resume` (`xingming`,`xueli`,`yuanxiao`,`jingli`,`jieshao`,`zhuangtai`,`yuexin`,`chusheng`,`zhaopian`,`jingyan`,`userid`,`begintime`)VALUES('$xingming','$xueli','$yuanxiao','$jingli','$jieshao','$zhuangtai','$yuexin','$chusheng','$zhaopian','$jingyan','$s_uid','$timestamp')");
			}
		}else{
			if($get['id']>0){
				$db->query("UPDATE `{$db_mymps}resume` SET xingming='$xingming',xueli = '$xueli',yuanxiao='$yuanxiao',jingli='$jingli',jieshao='$jieshao',zhuangtai='$zhuangtai',yuexin='$yuexin',chusheng='$chusheng',jingyan='$jingyan' {$where}");
			}else{
				$db->query("INSERT INTO `{$db_mymps}resume` (`xingming`,`xueli`,`yuanxiao`,`jingli`,`jieshao`,`zhuangtai`,`yuexin`,`chusheng`,`jingyan`,`userid`,`begintime`)VALUES('$xingming','$xueli','$yuanxiao','$jingli','$jieshao','$zhuangtai','$yuexin','$chusheng','$jingyan','$s_uid','$timestamp')");
			}
		}
		if($sex) $db->query("UPDATE `{$db_mymps}member` SET sex = '$sex' {$where}");
		if($qq) $db->query("UPDATE `{$db_mymps}member` SET qq = '$qq' {$where}");
		if($weixin) $db->query("UPDATE `{$db_mymps}member` SET weixin = '$weixin' {$where}");
		if($email) $db->query("UPDATE `{$db_mymps}member` SET email = '$email' {$where}");
		if($cityid) $db->query("UPDATE `{$db_mymps}member` SET cityid = '$cityid' {$where}");
		if($areaid) $db->query("UPDATE `{$db_mymps}member` SET areaid = '$areaid' {$where}");
		if($streetid) $db->query("UPDATE `{$db_mymps}member` SET streetid = '$streetid' {$where}");
		write_msg('恭喜，您已成功创建简历！快去申请职位吧！','?m=base&ac=resume');
	}else{
		$roww=$db->getRow("SELECT * FROM `{$db_mymps}resume` WHERE userid = '$s_uid'");
		$location = location();
		include mayi_tpl('base');
	}
}else{
	$appkey = $db->getOne("SELECT value FROM `{$db_mymps}config` WHERE description = 'key_sfz'");
	if(submit_check('base_submit')){
		$isemail = isset($isemail) ? intval($isemail) : '';
		$isqq = isset($isqq) ? intval($isqq) : '';
		$istel = isset($istel) ? intval($istel) : '';
		$tel = isset($tel) ? trim($tel) : '';
		$mobile = isset($mobile) ? trim($mobile) : '';
		$cname = isset($cname) ? trim($cname) : '';
		$qq = isset($qq) ? trim($qq) : '';
		$email = isset($email) ? trim($email) : '';
		$weixin = isset($weixin) ? trim($weixin) : '';
		$url = isset($url) ? trim($url) : '';
		$sex = isset($sex) ? trim($sex) : '';
		
		$isweixin == 1 && $db -> query("UPDATE `{$db_mymps}information` SET weixin = '$weixin' {$where}");
		$isemail == 1 && $db -> query("UPDATE `{$db_mymps}information` SET email = '$email' {$where}");
		$isqq == 1 && $db -> query("UPDATE `{$db_mymps}information` SET qq = '$qq' {$where}");
		$istel == 1 && $db -> query("UPDATE `{$db_mymps}information` SET tel = '$mobile' {$where}");
		
		if($email == '' && $qq == '' && $mobile == '' && $weixin == '') write_msg('','?m=base&error=11');
		if($mobile && mymps_count("member","WHERE mobile = '$mobile' AND userid != '$s_uid'") > 0) {
			write_msg("该手机号已认证过，请更换一个手机号 ^_^");
			exit;
		}
		
		if($appkey){
			$db -> query("UPDATE `{$db_mymps}member` SET qq = '$qq', email = '$email' ,weixin = '$weixin' , sex = '$sex' ,cityid= '$cityid' ,areaid= '$areaid' ,streetid= '$streetid'  {$where}");
		}else{
			$db -> query("UPDATE `{$db_mymps}member` SET qq = '$qq', mobile = '$mobile',cname = '$cname', email = '$email' ,weixin = '$weixin' , sex = '$sex' ,cityid= '$cityid' ,areaid= '$areaid' ,streetid= '$streetid'  {$where}");
		}
		write_msg('',$url ? $url : '?m=base&success=1');
	} else {
		$location = location();
		include mayi_tpl('base');
	}
}
?>