Location: PHPKode > projects > phpCAMALEO > inc/user_access.inc
<?php
if(!function_exists('user_access'))
{
	#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	# Validate user data for access
	#
	function user_access($user_ID,$passw_form)
	#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	{
		global $confirm_text,$random_string,$IP;
		include($_SESSION[common].'db/Globals.inc');
		include($_SERVER[DOCUMENT_ROOT].$_SESSION[misc][folder].'inc/user_fields.inc');
		unset
		(
			$_SESSION[id],
			$_SESSION[user_email],
			$_SESSION[user_name],
			$_SESSION[user_team],
			$_SESSION[user_team_desc],
			$_SESSION[reg_date],
			$_SESSION[last_log_date],
			$_SESSION[last_log_ip],
			$_SESSION[bday],
			$_SESSION[conf_email],
			$_SESSION[user_tbl_mr],
			$_SESSION[visits]
		);
		$feedback=account_namevalid($user_ID);
		if($feedback==false)						{ $feedback=BuildErrorString($error_msg[1001]); return($feedback.'@1'); }
		if($confirm_text!=$_SESSION[image_string])	{ $feedback=BuildErrorString($error_msg[1013]); return($feedback.'@2'); }
		#
		#	Database checks
		#
		$passw=md5($passw_form);
		$sth=db_query("SELECT * FROM $user_table WHERE id='$user_ID' AND pw='$passw'");
		if($sth[1]>0)
		{
			$row=db_fetch($sth[0]);
			$_SESSION[user_email]	=$row[0][email];
			$_SESSION[user_name]	=$row[0][fname];
			$_SESSION[user_team]	=$row[0][team];
			$_SESSION[reg_date]		=$row[0][reg_date];
			$_SESSION[last_log_date]=$row[0][last_log_date];
			$_SESSION[last_log_ip]	=$row[0][last_ip];
			$visits					=$row[0][visits];
			$_SESSION[bday]			=$row[0][birthday];
			$_SESSION[conf_email]	=$row[0][conf_email];
			$_SESSION[user_tbl_mr]	=$row[0][tbl_max_rows];
			#
			$sth=db_query("SELECT * FROM $user_table"."_teams WHERE RRN='".$row[0][team]."'");
			$tmp=db_fetch($sth[0]);
			$_SESSION[user_team_desc]=$tmp[0][id];
		}
		else { return(BuildErrorString($error_msg[1001]).'@1'); }
		$_SESSION[id]=session_id();
		$visits++; $_SESSION[visits]=$visits;
		#
		#	Update user last access
		#
		$sth=db_query("UPDATE $user_table SET last_log_date='$today',last_ip='$_SERVER[REMOTE_ADDR]:$_SERVER[REMOTE_PORT]',visits='$visits' WHERE id='$user_ID' LIMIT 1");
		#
		#	Update online user info
		#
		$sth=db_query("SELECT * FROM online WHERE ip='$IP'");
		if($sth[1]>0)
		{
			$sth=db_query("UPDATE online SET user='$user_ID',pw='".$passw."',privil='".$row[0][privil]."',userRRN='".$row[0][RRN]."',team='".$row[0][team]."',time='".time()."' WHERE ip='$IP' LIMIT 1");
		}
		#
		@unlink($_SESSION[image_name]);
		unset($_SESSION[image_name],$_SESSION[image_string]);
		return('OKIDOKI');
	}
}
?>
Return current item: phpCAMALEO