Location: PHPKode > projects > phpCAMALEO > common/includes/UserLost.inc
<?PHP
/***************************************************************************
 *	UserLost.inc
 *
 *	begin		: June 2004
 *	version		: 9 October 2006
 *	copyright	: (C) 2004,2005 grandolini.net
 *
 *	Functions to support user memory...
 *
 ***************************************************************************/

include_once('Session.php');

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Validate user data for new password
#
function req_password($user_ID, $email, $flag='')
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
{
	include($_SESSION[common].'db/Globals.inc');
	include($_SERVER[DOCUMENT_ROOT].$_SESSION[misc][folder].'inc/user_fields.inc');
	#
	#	Is there any data to check?
	#
	if(!$user_ID && !$email) { return(BuildErrorString(1008)); }
	#
	#	Database checks
	#
	$args="SELECT * FROM $user_table WHERE 1=1";
	if($user_ID)	{ $args.="	AND	id='$user_ID'"; }
	if($email)		{ $args.="	AND	email='$email'"; }
	$sth=db_query($args);
	#
	if($sth[1]>0)	{ $row=db_fetch($sth[0]); }
	else			{ return(BuildErrorString(1007)); }
	#
	$user_ID_db	=$row[0][id];
	$email_db	=$row[0][email];
	#
	#	Data validated
	#
	if($flag!='uid')
	{
		include($_SESSION[common].'fun2inc/random_string.inc');
		$new_passw=random_string(8);
		$password=md5($new_passw);
		$sth=db_query("UPDATE $user_table SET pw='$password' WHERE id='$user_ID_db' AND email='$email_db' LIMIT 1");
	}
	#
	#	Send confirmation email
	#
	$host_root=$_SERVER[SERVER_NAME];
	if($_SESSION[misc][folder]!='' && $_SESSION[misc][folder]!='/') { $host_root=$_SERVER[SERVER_NAME].'/'.$_SESSION[misc][folder].'/'; }
	#
	include($_SESSION[common].'fun2inc/send_info.inc');
	if($flag=='uid')
	{
		$result=send_info($email_db, F_LOSTUID_SUBJ, $_SERVER[DOCUMENT_ROOT].$_SESSION[misc][folder].'import/'.$_SESSION[sitelanguage].'/e_userid.txt', 
							'', '', '', '', '', '', $host_root,
							$user_ID_db, '<a href="http://'.$host_root.'Access.php">login</a>');
	}
	else
	{
		$result=send_info($email_db, F_LOSTUPW_SUBJ, $_SERVER[DOCUMENT_ROOT].$_SESSION[misc][folder].'import/'.$_SESSION[sitelanguage].'/e_new_password.txt', 
							'', '', '', '', '', '', $host_root,
							$user_ID_db, $new_passw, '<a href="http://'.$host_root.'Access.php">login</a>');
	}
	if($result=='') { return 'OKIDOKI'; } else { return(BuildErrorString(1504,1500)); }
}
?>
Return current item: phpCAMALEO