<?

/*
FlexCMS (http://www.flexcms.com)
Flexible, Powerful, Affordable.

Contents of this file are protected by the copyright
notice found at http://www.flexcms.com/flex/pages/copyright.html,
and its usage is subject to the terms of the licensing agreement 
available at http://www.flexcms.com/flex/pages/license.html
*/



	// ========================================================================================
	// verify email address
	// ========================================================================================
	

	$PageTitle = $MsgText[0][124];
	$BrowserTitle = $MsgText[0][124];
	$LocationBar = '<a href="'.$IndexURL.'">'.$MsgText[0][1].'</a> > '.$MsgText[0][124];
	
	
	$Arguments2 = addslashes($Arguments2);
	$Arguments3 = addslashes($Arguments3);
	
			
	$query = "select * from `".$Settings['DBPrefix']."core-Users` where Email='".$Arguments2."' and ConfirmationCode='".$Arguments3."' limit 1";
	$result = mysql_query($query) or die (mysql_error());
	if (mysql_num_rows($result) > 0) {
		$row = mysql_fetch_array($result);
		
		
		$query = "update `".$Settings['DBPrefix']."core-Users` set Verified='y' where Email='".$Arguments2."' and ConfirmationCode='".$Arguments3."' limit 1";
		$result = mysql_query($query) or die (mysql_error());
		
		
		if ($Settings['Notify'] == 'y') {
				
			if ($Settings['NotifyEmail'] != '') {
				$NotifyEmail = $Settings['NotifyEmail'];
			}
			else {
				$NotifyEmail = $Settings['ContactEmail'];
			}
				
			
			$Message = "\n".'A new user account has been created.'."\n\n\n".'Username: '.$row['Username']."\n\n".'Name: '.$row['FirstName'].' '.$row['LastName']."\n\n\n\n".$MsgText[0][142].','."\n".$Settings['SiteName']."\n".$IndexURL;
			mail($NotifyEmail, 'New User Account Created', $Message, 'From: "'.$Settings['SiteName'].'" <'.$Settings['ContactEmail'].'>','-f'.$Settings['ContactEmail']);
						
				
		}
		
		
		
		//$Message = $MsgText[0][143]."\n\n".$MsgText[0][140]."\n\n".$MsgText[0][99].': '.$row['Username']."\n".$MsgText[0][131].': '.$row['BarePassword']."\n\n".$MsgText[0][141]."\n\n\n\n".$MsgText[0][142].','."\n".$Settings['SiteName']."\n".$IndexURL;
		//mail($row['Email'], $MsgText[0][143], $Message, 'From: "'.$Settings['SiteName'].'" <'.$Settings['ContactEmail'].'>','-f'.$Settings['ContactEmail']);
		
		
		
		
		
		if ($row['ReturnTo'] != '') {
			$row['ReturnTo'] = '/'.$row['ReturnTo'];
		}
		
		
		$FinalPassword = '';
		$EncryptedUsername = crypt($row['Username'],substr($row['Username'],0,2));
		$EncryptedUsername = substr($EncryptedUsername,0,8);
		$LoopCount = ceil(strlen($row['BarePassword'])/8);
		for ($i = 1; $i <= $LoopCount; $i++) {
			$FinalPassword .= crypt(substr($row['BarePassword'],($i*8)-8,8),substr($row['BarePassword'],0,2));
		}
		$FinalPassword = $EncryptedUsername.$FinalPassword;
		
		
		$PageContents = $MsgText[0][657].'<br><br><a href="'.$MainURL . '/login-submit-nf/'.str_replace('/','+++',$row['Username']).'/'.str_replace('/','+++',$FinalPassword).$row['ReturnTo'].'"><b>'.$MsgText[0][146].'</b></a>';
		
		
		$query = "update `".$Settings['DBPrefix']."core-Users` set BarePassword='', ReturnTo='' where Email='".$Arguments2."' and ConfirmationCode='".$Arguments3."' limit 1";
		$result = mysql_query($query) or die (mysql_error());
			
	}
	else {
	
		$PageContents = $MsgText[0][658].'<br><br>';
		
	}


?>
