Location: PHPKode > projects > phpCAMALEO > common/fun2inc/load_usr_data.inc
<?php
if(!function_exists('load_usr_data'))
{
	#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	# Load user data from database
	#
	function load_usr_data($user)
	#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	{
		include($_SERVER[DOCUMENT_ROOT].$_SESSION[misc][folder].'db/Globals.inc');		# 9 Oct 2006
		include($_SERVER[DOCUMENT_ROOT].$_SESSION[misc][folder].'db/user_fields.inc');	# 9 Oct 2006
		#
		#	Look for the user
		#
		$sth = db_query("SELECT * FROM $user_table WHERE id = '$user' ");
		if ($sth[1] > 0)
		{
			$row = db_fetch($sth[0]);
			$user_ID_db			= $row[0]['id'];
			$password_db		= $row[0]['pw'];
			$email_db			= $row[0]['email'];
			$fname_db			= $row[0]['fname'];
			$reg_date_db		= $row[0]['reg_date'];
			$last_log_date_db 	= $row[0]['last_log_date'];
			$visits_db			= $row[0]['visits'];
			$privileges_db 		= $row[0]['privil'];
			$birthday_db		= $row[0]['birthday'];
			$confemail_db		= $row[0]['conf_email'];
		}
		else
		{
			$user_ID_db			= '';
			$password_db		= '';
			$email_db			= '';
			$fname_db			= '';
			$reg_date_db 		= '';
			$last_log_date_db 	= '';
			$visits_db 			= '';
			$privileges_db 		= '';
			$birthday_db		= '';
			$confemail_db		= '';
		}
		if ($user != $user_ID_db || $user_ID_db == '') { $feedback = BuildErrorString($user.$error_msg[1002]); return($feedback); }
		return('OKIDOKI');
	}
	
	#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	# Validate and update user data (user panel)
	#
	function user_panel($user_to_check)
	#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	{
		include($_SERVER[DOCUMENT_ROOT].$_SESSION[misc][folder].'db/Globals.inc');		# 9 Oct 2006
		include($_SERVER[DOCUMENT_ROOT].$_SESSION[misc][folder].'db/user_fields.inc');	# 9 Oct 2006
		#
		#	Data validation
		#
		$sth = db_query("SELECT * FROM $user_table WHERE id = '$user_to_check' ");
		if ($sth[1] > 0)
		{
			$row = db_fetch($sth[0]);
			$user_ID_db_ck	= $row[0]['id'];
			$passw_db_ck	= $row[0]['pw'];
			$email_db_ck	= $row[0]['email'];
		}
		else
		{
			$user_ID_db_ck	= '';
			$passw_db_ck	= '';
			$email_db_ck	= '';
		}
		if ($user_to_check != $user_ID_db_ck)	{ $feedback = BuildErrorString($error_msg[1024]); return($feedback); }
		#
		$feedback = validate_email($email);
		if ($feedback != 'valid')				{ return($feedback.'#@#4'); }
		#
		if (substr($birthday, 8, 2) != '00')
		{
			$feedback = validate_date($birthday, 'ymd');
			if ($feedback != 'valid')			{ return($feedback.'#@#2'); }
		}
		#
		$passw_form = '';
		if ($passw_form1 or $passw_form2 or $passw_old)
		{
			if (strlen($passw_form1) < 5)		{ $feedback = BuildErrorString($error_msg[1004]); return($feedback.'#@#3'); }
			if ($passw_form1 != $passw_form2)	{ $feedback = BuildErrorString($error_msg[1005]); return($feedback.'#@#6'); }
			if ($passw_old   != $passw_db_ck)	{ $feedback = BuildErrorString($error_msg[1003]); return($feedback.'#@#5'); }
			$passw_form = md5($passw_form1);
		}
		#
		#	Data validated
		#
		$args = "UPDATE $user_table SET	birthday = '$birthday',
									email	 = '$email', 
									fname	 = '$fname', ";
		if ($passw_form) $args .= "	pw		 = '$passw_form',";
		$args .= "					conf_email	= '$conf_email'
									WHERE id = '$user_to_check' LIMIT 1";
		$result = db_query($args);
		return('OKIDOKI');
	}
}
?>
Return current item: phpCAMALEO