| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686 | <?php/** * @author darkredz */class SettingController extends DooController {	public $staff = array ();	public function beforeRun($resource, $action) {	}	function __construct() {		if (isset ( $_COOKIE ["staff"] )) {			if (! empty ( $_COOKIE ["staff"] )) {				Doo::loadModel ( 'staff' );				$staff = new staff ();								$this->staff = $staff->getStaffBySid ( $_COOKIE ["staff"] );								return "/";			}		}				Doo::loadCore ( 'uri/DooUriRouter' );		$router = new DooUriRouter ();		$routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );				if ($routeRs ['1'] != "login") {			header ( 'Content-Type:text/html;charset=utf-8' );			@header ( "Location: /login" );		}	}		/**	 * 员工信息	 */	function settingEmployeeInfo() {		Doo::loadModel ( 'staff' );		$staff = new staff ();				$isShowMsg = false;				$detail = $staff->checkStaffInfoIsComplete ( $_COOKIE ["staff"] );				if ($detail ['telephone'] == "")			$isShowMsg = true;		if ($detail ['qq'] == "")			$isShowMsg = true;		if ($detail ['wecat'] == "")			$isShowMsg = true;		if ($detail ['phone'] == "")			$isShowMsg = true;		if ($detail ['email'] == "")			$isShowMsg = true;		if ($detail ['birthday'] == "")			$isShowMsg = true;		if ($detail ['marriage'] == "")			$isShowMsg = true;		if ($detail ['living'] == "")			$isShowMsg = true;		if ($detail ['nativePlace'] == "")			$isShowMsg = true;		if ($detail ['emergencyContacts'] == "")			$isShowMsg = true;									$this->data ['isShowMsg'] = $isShowMsg;		$this->data ['staff'] = $this->staff;		$this->data ['memu'] = "adminmyinfo";		$this->data ['hrMemu'] = "settingEmployeeInfo";				$this->render ( "/setting/settingEmployeeInfo", $this->data );	}			function settingAvatarInfo(){		$this->data ['staff'] = $this->staff;		$this->data ['memu'] = "adminmyinfo";		$this->data ['hrMemu'] = "settingAvatarInfo";				$this->render ( "/setting/settingAvatarInfo", $this->data );	}		/**	 * 证件信息	 */	function settingCredentialInfo() {		Doo::loadModel ( 'staff' );		$staff = new staff ();				$detail = $staff->getStaffBySid ( $this->staff ['sid'] );				$this->data ['staff'] = $this->staff;		$this->data ['memu'] = "adminmyinfo";		$this->data ['hrMemu'] = "settingEmployeeInfo";				$this->render ( "/setting/settingCredentialInfo", $this->data );	}	/**	 * 财务信息	 */	function settingFinanceInfo() {		$this->data ['staff'] = $this->staff;		$this->data ['memu'] = "adminmyinfo";		$this->data ['hrMemu'] = "settingEmployeeInfo";				$this->render ( "/setting/settingFinanceInfo", $this->data );	}	function settingPW() {		$this->data ['msg'] = urldecode ( $this->params ['msg'] );				$this->data ['staff'] = $this->staff;		$this->data ['memu'] = "adminmyinfo";		$this->data ['hrMemu'] = "settingPW";				$this->render ( "/setting/settingPW", $this->data );	}		/*	 * 更新密码	 */	function updateMyPW() {		$oldpassword = $this->get_args ( 'oldpassword' ) ? $this->get_args ( 'oldpassword' ) : "";		$newpassword = $this->get_args ( 'newpassword' ) ? $this->get_args ( 'newpassword' ) : "";		$rnewpassword = $this->get_args ( 'rnewpassword' ) ? $this->get_args ( 'rnewpassword' ) : "";				Doo::loadModel ( 'staff' );		$staff = new staff ();		Doo::loadModel ( 'staffDynamic' );		$staffDynamic = new staffDynamic ();				$staff->sid = $this->staff ['sid'];				$msg = "更新成功";				if ($this->staff ['passwork'] == md5 ( $oldpassword )) {			if ($newpassword == $rnewpassword && (! empty ( $newpassword )))				$staff->passwork = md5 ( $newpassword );			else				$msg = "密码不一致";		} else {			if ($oldpassword != "")				$msg = "密码错误";		}				$staff->update ( array (				'where' => ' sid=' . $this->staff ['sid'] 		) );				return "/settingPW/" . $msg;	}		/**	 * 微信通知设置	 */	function notificationConf() {		Doo::loadModel ( "notificationConf" );		$notificationConf = new notificationConf ();				$detail = $notificationConf->getNotificationConfBySid ( $this->staff ['sid'] );				$rule = json_decode ( $detail ['conf'], true );		if (! isset ( $rule ['approval'] ))			$rule ['approval'] = '';		if (! isset ( $rule ['print'] ))			$rule ['print'] = '';		if (! isset ( $rule ['receivables'] ))			$rule ['receivables'] = '';				$this->data ['rule'] = $rule;		$this->data ['memu'] = "adminmyinfo";		$this->data ['hrMemu'] = "notificationConf";		$this->data ['staff'] = $this->staff;				$this->render ( "/setting/invoiceNotificationConf", $this->data );	}		/**	 * 异步设置微信通知	 */	function ajaxSetNotificationConf() {		$notificationType = $this->get_args ( 'notificationType' ) ? $this->get_args ( 'notificationType' ) : "";		$notificationValue = $this->get_args ( 'notificationValue' ) ? $this->get_args ( 'notificationValue' ) : '';				if (! empty ( $notificationType ) && ! empty ( $notificationValue ) && ! empty ( $this->staff ['sid'] )) {			Doo::loadModel ( "notificationConf" );			$notificationConf = new notificationConf ();						$detail = $notificationConf->getNotificationConfBySid ( $this->staff ['sid'] );						if (empty ( $detail )) {				$rule = array (						$notificationType => $notificationValue 				);				$rule = json_encode ( $rule );				$item = array (						'sid' => $this->staff ['sid'],						'conf' => $rule 				);								$notificationConf->addNotification ( $item );			} else {				$rule = json_decode ( $detail ['conf'], true );				$rule [$notificationType] = $notificationValue;				$rule = json_encode ( $rule );				$item = array (						'nid' => $detail ['nid'],						'conf' => $rule 				);				$notificationConf->setNotificationByCondition ( $item );			}			echo json_encode ( array (					'status' => 1,					'msgType' => $notificationType,					'msg' => '' 			) );			die ();		}		echo json_encode ( array (				'status' => 2,				'msgType' => $notificationType,				'msg' => 'illegal request' 		) );		die ();	}		/**	 * 更新员工信息	 */	function staffUpdate() {		$sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";				$username = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";		$cid_did = $this->get_args ( 'cid_did' ) ? $this->get_args ( 'cid_did' ) : '';		//$position = $this->get_args ( 'position' ) ? $this->get_args ( 'position' ) : '';		$hiredate = $this->get_args ( 'hiredate' ) ? $this->get_args ( 'hiredate' ) : '';		$telephone = $this->get_args ( 'telephone' ) ? $this->get_args ( 'telephone' ) : '';		// $baseWage = is_numeric ( $this->get_args ( 'baseWage' ) ) ? $this->get_args ( 'baseWage' ) : 0;		// $postWage = is_numeric ( $this->get_args ( 'postWage' ) ) ? $this->get_args ( 'postWage' ) : 0;		// $achievementBonus = is_numeric ( $this->get_args ( 'achievementBonus' ) ) ? $this->get_args ( 'achievementBonus' ) : 0;		$gender = $this->get_args ( 'gender' ) ? $this->get_args ( 'gender' ) : '';				$qq = is_numeric ( $this->get_args ( 'qq' ) ) ? $this->get_args ( 'qq' ) : 0;		$phone = $this->get_args ( 'phone' )  ? $this->get_args ( 'phone' ) : 0;		$wecat = $this->get_args ( 'wecat' ) ? $this->get_args ( 'wecat' ) : '';		$email = $this->get_args ( 'email' ) ? $this->get_args ( 'email' ) : '';				$birthday = $this->get_args ( 'birthday' ) ? $this->get_args ( 'birthday' ) : '';		$qualifications = $this->get_args ( 'qualifications' ) ? $this->get_args ( 'qualifications' ) : '';		$marriage = $this->get_args ( 'marriage' ) ? $this->get_args ( 'marriage' ) : '0';		$IDcards = $this->get_args ( 'IDcards' ) ? $this->get_args ( 'IDcards' ) : '';				$living = $this->get_args ( 'living' ) ? $this->get_args ( 'living' ) : '';		$nativePlace = $this->get_args ( 'nativePlace' ) ? $this->get_args ( 'nativePlace' ) : '';		$emergencyContacts = $this->get_args ( 'emergencyContacts' ) ? $this->get_args ( 'emergencyContacts' ) : '';		$remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : '';		$coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : '';		$bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : '';		$bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : '';				$salaryCard = $this->get_args ( 'salaryCard' ) ? $this->get_args ( 'salaryCard' ) : '';		$salaryBank = $this->get_args ( 'salaryBank' ) ? $this->get_args ( 'salaryBank' ) : '';				$employeeInfo = $this->get_args ( 'employeeInfo' ) ? $this->get_args ( 'employeeInfo' ) : 'employeeInfo';				$nation = $this->get_args ( 'nation' ) ? $this->get_args ( 'nation' ) : '';		$graduateInstitutions = $this->get_args ( 'graduateInstitutions' ) ? $this->get_args ( 'graduateInstitutions' ) : '';		$major = $this->get_args ( 'major' ) ? $this->get_args ( 'major' ) : '';		$education = $this->get_args ( 'education' ) ? $this->get_args ( 'education' ) : '';		$graduationTime = $this->get_args ( 'graduationTime' ) ? $this->get_args ( 'graduationTime' ) : '';		$registeredResidence = $this->get_args ( 'registeredResidence' ) ? $this->get_args ( 'registeredResidence' ) : '';		$householdRegistrationType = $this->get_args ( 'householdRegistrationType' ) ? $this->get_args ( 'householdRegistrationType' ) : '';				if (! empty ( $sidKey )) {						Doo::loadClass ( 'XDeode' );			$XDeode = new XDeode ( 5 );			Doo::loadModel ( 'staff' );			$staff = new staff ();			Doo::loadModel ( 'L_category' );			$L_category = new L_category ();			Doo::loadModel ( 'tag' );			Doo::loadModel ( 'holidaystaff' );			Doo::loadModel ( 'staffManage' );			$staffManage = new staffManage ();						// 用户名检测			if (! empty ( $username )) {				$detail = $staff->getStaffByName ( $username );				if (empty ( $detail ))					die ( 'illegal request' );			}			$detail = $staff->getStaffBySid ( $sidKey );			if (empty ( $detail ))				die ( 'illegal request' );				// if (!empty($username))				// $staff->username = $username;			if (! empty ( $hiredate ))				$staff->hiredate = $hiredate;// 			if (! empty ( $position )){// 				$position = explode ( '_', $position );// 				$staff->position = $position[1];// 				$staff->positionId = $position[0];// 			}								// 办事处-部门			if (! empty ( $cid_did )) {				$department = explode ( '_', $cid_did );				$cid = $XDeode->decode ( $department [0] );				// 加入默认总部分类				if (! is_numeric ( $cid ))					die ( 'illegal request' );				$cagegory = $L_category->getCategoryById ( $cid );				// 部门				$staff->departmentID =0;				if (! empty ( $department [1] )) {					$did = $XDeode->decode ( $department [1] );					if (! is_numeric ( $did ))						die ( 'illegal request' );					$staff->departmentID = $did;				}				$staff->cid = $cagegory [0] ['cid'];				$staff->category = $cagegory [0] ['title'];			}						if (! empty ( $telephone ))				$staff->telephone = $telephone;				// if (!empty($baseWage))				// $staff->baseWage = $baseWage;				// if (!empty($postWage))				// $staff->postWage = $postWage;				// if (!empty($achievementBonus))				// $staff->achievementBonus = $achievementBonus;			if (! empty ( $gender ))				$staff->gender = $gender;						if (! empty ( $qq ))				$staff->qq = $qq;			if (! empty ( $phone ))				$staff->phone = $phone;			if (! empty ( $wecat ))				$staff->wecat = $wecat;			if (! empty ( $email ))				$staff->email = $email;			if (! empty ( $birthday ))				$staff->birthday = $birthday;			if (! empty ( $qualifications ))				$staff->qualifications = $qualifications;			if ($marriage != '请选择')				$staff->marriage = $marriage;			else				$staff->marriage = '';			if (! empty ( $IDcards ))				$staff->IDcards = $IDcards;			if (! empty ( $living ))				$staff->living = $living;			if (! empty ( $nativePlace ))				$staff->nativePlace = $nativePlace;			if (! empty ( $emergencyContacts ))				$staff->emergencyContacts = $emergencyContacts;			if (! empty ( $coupletNumber ))				$staff->coupletNumber = $coupletNumber;			if (! empty ( $bankName ))				$staff->bankName = $bankName;			if (! empty ( $bankNumber ))				$staff->bankNumber = $bankNumber;			if (! empty ( $remittanceName ))				$staff->remittanceName = $remittanceName;						if (! empty ( $salaryCard ))				$staff->salaryCard = $salaryCard;			if (! empty ( $salaryBank ))				$staff->salaryBank = $salaryBank;						if (! empty ( $nation ))				$staff->nation = $nation;			if (! empty ( $graduateInstitutions ))				$staff->graduateInstitutions = $graduateInstitutions;			if (! empty ( $major ))				$staff->major = $major;			if (! empty ( $education ))				$staff->education = $education;			if (! empty ( $graduationTime ))				$staff->graduationTime = $graduationTime;			if (! empty ( $registeredResidence ))				$staff->registeredResidence = $registeredResidence;			if (! empty ( $householdRegistrationType ))				$staff->householdRegistrationType = $householdRegistrationType;						$staff->update ( array (					'where' => 'sid=' . $detail ['sid'] 			) );						if ($employeeInfo == 'employeeInfo') {				return '/hr';			} elseif ($employeeInfo == 'hrEmployee') {					return '/hrEmployee';			} elseif ($employeeInfo == 'settingEmployeeInfo') {				return '/settingEmployeeInfo';			} elseif ($employeeInfo == 'settingFinanceInfo') {				return '/settingFinanceInfo';			}		}		die ( 'illegal request' );	}		/**	 * 证件文件上传	 */	function settingCredentialInfoDo() {		// include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';		$IDcards = is_numeric ( $this->get_args ( 'IDcards' ) ) ? $this->get_args ( 'IDcards' ) : 0;		$certificate = $this->get_args ( 'certificate' ) ? $this->get_args ( 'certificate' ) : '';		$diploma = $this->get_args ( 'diploma' ) ? $this->get_args ( 'diploma' ) : '';		$professionalTitle = $this->get_args ( 'professionalTitle' ) ? $this->get_args ( 'professionalTitle' ) : '';				$IDcardsValidity = $this->get_args ( 'IDcardsValidity' ) ? $this->get_args ( 'IDcardsValidity' ) : '';						Doo::loadModel ( 'staff' );		$staff = new staff ();				$detail = $staff->getStaffBySid ( $this->staff ['sid'] );				$save_path = DOO::conf ()->SITE_PATH . "upload/credentialInfo/";		$webSite = WEB_SITE . '/upload/credentialInfo/';				// if (!empty($IDcards))		$staff->IDcards = $IDcards;				$msg = '';		$file_name = 'IDcardsImgA_' . $this->staff ['sid'] . '.' . $this->_GetFileEXT ( $_FILES ["IDcardsImgA"] ['name'] );		if (! empty ( $_FILES ["IDcardsImgA"] ["size"] )) {			if (! @move_uploaded_file ( $_FILES ["IDcardsImgA"] ["tmp_name"], $save_path . $file_name ))				$msg .= "文件无法保存";			else {				$staff->IDcardsImgA = $webSite . $file_name;			}		}				$file_name = 'IDcardsImgB_' . $this->staff ['sid'] . '.' . $this->_GetFileEXT ( $_FILES ["IDcardsImgB"] ['name'] );		if (! empty ( $_FILES ["IDcardsImgB"] ["size"] ))			if (! @move_uploaded_file ( $_FILES ["IDcardsImgB"] ["tmp_name"], $save_path . $file_name )) {				$msg .= "文件无法保存";			} else {				$staff->IDcardsImgB = $webSite . $file_name;			}				if (! empty ( $certificate )) {			$certificateArray = explode ( "-", $certificate );			$name = json_decode ( $detail ['certificate'] );			if (! empty ( $name )) {				$certificateArray = array_merge_recursive ( $name, $certificateArray );				$staff->certificate = json_encode ( $certificateArray );			} else				$staff->certificate = json_encode ( $certificateArray );		}				if (! empty ( $diploma )) {			$diplomaArray = explode ( "-", $diploma );			$name = json_decode ( $detail ['diploma'] );			if (! empty ( $name )) {				$diplomaArray = array_merge_recursive ( $name, $diplomaArray );				$staff->diploma = json_encode ( $diplomaArray );			} else				$staff->diploma = json_encode ( $diplomaArray );		}				if (! empty ( $professionalTitle )) {			$professionalTitleArray = explode ( "-", $professionalTitle );			$name = json_decode ( $detail ['professionalTitle'] );			if (! empty ( $name )) {				$professionalTitleArray = array_merge_recursive ( $name, $professionalTitleArray );				$staff->professionalTitle = json_encode ( $professionalTitleArray );			} else				$staff->professionalTitle = json_encode ( $professionalTitleArray );		}				if(!empty($IDcardsValidity)){			$staff->IDcardsValidity = $IDcardsValidity;		}				$staff->update ( array (				'where' => 'sid=' . $this->staff ['sid'] 		) );		return '/settingCredentialInfo';	}		/**	 * 上传学位证书	 * @return string	 */	function settingCredentialInfoTypeDo() {		$hunTian = isset ( $this->params ['hunTian'] ) ? $this->params ['hunTian'] : "";				if (empty ( $hunTian )) {			echo "文件无法保存.";			exit ( 0 );		}				$POST_MAX_SIZE = ini_get ( 'post_max_size' );		$unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );		$multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));				if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {			header ( "HTTP/1.1 500 Internal Server Error" );			echo "POST exceeded maximum allowed size.";			exit ( 0 );		}				// Settings		$save_path = DOO::conf ()->SITE_PATH . "/upload/credentialInfo/"; // The path were we will save the file (getcwd() may not be reliable and should be tested in your environment)		$upload_name = "Filedata";		$max_file_size_in_bytes = 2147483647; // 2GB in bytes		$extension_whitelist = array (				"doc",				"txt",				"jpg",				"gif",				"png" 		); // Allowed file extensions		$valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)		                                                         		// Other variables		$MAX_FILENAME_LENGTH = 260;		$file_name = "";		$file_extension = "";		$uploadErrors = array (				0 => "文件上传成功",				1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",				2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",				3 => "上传的文件仅为部分文件",				4 => "没有文件上传",				6 => "缺少临时文件夹" 		);				$nk = time ();		if ($hunTian == 'diploma')			$file_name = 'diploma_' . $this->staff ['sid'] . '_' . $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] );		elseif ($hunTian == 'professionalTitle')			$file_name = 'professionalTitle_' . $this->staff ['sid'] . '_' . $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] );		elseif ($hunTian == 'certificate') {			$file_name = 'certificate_' . $this->staff ['sid'] . '_' . $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] );		}				if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {			echo "文件无法保存.";			exit ( 0 );		}				echo json_encode ( array (				'filename' => $file_name,				'id' => $nk 		) );		exit ( 0 );	}		/**	 * 删除证件文件	 */	function delCredentialType() {		$hunTian = isset ( $this->params ['hunTian'] ) ? $this->params ['hunTian'] : "";		$name = isset ( $this->params ['name'] ) ? $this->params ['name'] : "";				if (empty ( $hunTian ) || empty ( $name )) {			die ( 'illegal request' );		}				Doo::loadModel ( 'staff' );		$staff = new staff ();		$detail = $staff->getStaffBySid ( $this->staff ['sid'] );				if ($hunTian == 'certificate') {			$msg = str_replace ( $name, "", $detail ['certificate'] );			$msg = json_decode ( $msg );			$msg = array_values ( array_filter ( $msg ) );			$staff->certificate = json_encode ( $msg );		}				if ($hunTian == 'diploma') {			$msg = str_replace ( $name, "", $detail ['diploma'] );			$msg = json_decode ( $msg );			$msg = array_values ( array_filter ( $msg ) );			$staff->diploma = json_encode ( $msg );		}				if ($hunTian == 'professionalTitle') {			$msg = str_replace ( $name, "", $detail ['professionalTitle'] );			$msg = json_decode ( $msg );			$msg = array_values ( array_filter ( $msg ) );			$staff->professionalTitle = json_encode ( $msg );		}				$staff->update ( array (				'where' => 'sid=' . $this->staff ['sid'] 		) );		return '/settingCredentialInfo';	}		/**	 * 上传头像专用	 */	function _settingAvatar() {				$result = array ();		$result ['success'] = false;		$successNum = 0;		// 定义一个变量用以储存当前头像的序号		$avatarNumber = 1;		$i = 0;		$msg = '';		// 上传目录		$dir = DOO::conf ()->SITE_PATH . "global/avatar";				// 遍历所有文件域		while ( list ( $key, $val ) = each ( $_FILES ) ) {			if ($_FILES [$key] ['error'] > 0)				$msg .= $_FILES [$key] ['error'];				else {					$fileName = 'avatar_' . $this->staff ['sid'];					// 原始图片(file 域的名称:__source,如果客户端定义可以上传的话,可在此处理)。					if ($key == '__source') { // 当前头像基于原图的初始化参数,用于修改头像时保证界面的视图跟保存头像时一致。帮助提升用户体验度。修改头像时设置默认加载的原图的url为此图片的url+该参数即可。						$initParams = $_POST ["__initParams"];						$virtualPath = $dir . "/" . $fileName . "_" . $avatarNumber . ".jpg";						$result ['sourceUrl'] = '/' . $virtualPath . $initParams;						move_uploaded_file ( $_FILES [$key] ["tmp_name"], $virtualPath );						$successNum ++;					} else if (strpos ( $key, '__avatar' ) === 0) { // 头像图片(file 域的名称:__avatar1,2,3...)。						$virtualPath = $dir . "/" . $fileName . "_" . $avatarNumber . ".jpg";						$result ['avatarUrls'] [$i] = '/' . $virtualPath;						move_uploaded_file ( $_FILES [$key] ["tmp_name"], $virtualPath );						$avatarNumber ++;						$successNum ++;						$i ++;					}				}		}		$result ['msg'] = $msg;		if ($successNum > 0)			$result ['success'] = true;			// 返回图片的保存结果(返回内容为json字符串)				Doo::loadModel ( 'staff' );			$staff = new staff ();				$staff->sid = $this->staff ['sid'];			$staff->avatar = "/global/avatar/" . $fileName;			$staff->update ();				header('Cache-Control:no-cache,must-revalidate');			header('Pragma:no-cache');						echo json_encode ( $result );	}		/**	 * 获取get或者POST值	 *	 * @param string $name 属性名称	 * @return fixed 值	 */	function get_args($name) {		if (isset ( $_GET [$name] )) {			if (is_array ( $_GET [$name] ))				return $_GET [$name];			else				return addslashes ( $_GET [$name] );		} elseif (isset ( $_POST [$name] )) {			if (is_array ( $_POST [$name] ))				return $_POST [$name];			else				return addslashes ( $_POST [$name] );		} else			return false;	}		/**	 * 旧输入导入	 */	function _GetFileEXT($filename) {		$pics = explode ( '.', $filename );		$num = count ( $pics );		return $pics [$num - 1];	}}?>
 |