<?php

/*

script: confirm.php
purpose: allows a user to confirm their email address
copyright: copyright 2004 Php Image Host. All Rights Reserved. You may modify this file for use on your
					site running a licenced copy of the Php Image Host scripts.
					You must not distribute this file or derivations of it.
Nullified By CrAcKlOvE


*/

// include the database, etc, configuration file

require_once(dirname(__FILE__).'/includes/config.inc.php');

$confirmationerror = '';

// include the site header

require_once(dirname(__FILE__).'/header.php');

// if the user is logged in, just display the default "logged in" message and exit

if( $loggedin ){
	require(dirname(__FILE__).'/includes/loggedin.inc.php');
}

if( $banned ){

	$pagecontent->display('IP Banned');

}else{

	if( $config->email_confirmation == 0 ){

		// if we do not require account email confirmation, just display the not logged in message

		require_once(dirname(__FILE__).'/includes/notloggedin.inc.php');

	}else{

		// check if the user has submitted the confirmation form 
		// (or has clicked on the url in their sign-up email that contains the confirmation code)

		$username = $ace->getstr('username', $_REQUEST);
		$cid = $ace->getstr('cid', $_REQUEST);
		$confirmed = false;
		$suspended = false;

		if( $ace->getstr('confirm', $_REQUEST) != '' ){
			$user = $users->confirmuser($username, $cid);
			if( $user == -1 ){
				$suspended = true;
			}elseif( $user == 0 ){
				$confirmationerror = 'Invalid username or confirmation id.';
			}else{
				$confirmed = true;
			}
		}

		if( $confirmed ){

			// if the user has successfully confirmed their email address, display the
			// relevant message (editable via the "page content" page in the admin area

			$pagecontent->display('Email Confirmed');

		}elseif( $suspended ){

			// if the user's account has been suspended, display the relevant message

			$pagecontent->display('Suspended Message');

		}else{

			// if they haven't confirmed the account, display the confirmation required 
			// message and the confirmation form.

			$pagecontent->display('Confirm');

			if( $confirmationerror != '' ){
?>
<div class="errors"><?php echo $confirmationerror;?></div>
<?php

			}

?>
<form name="confirmform" action="<?php echo $_SERVER['SCRIPT_NAME'];?>" method="post">
<div class="memberform">
<table align="center" class="membertable" cellspacing="1" cellpadding="0" border="0">
<tr>
	<td colspan="2" class="memberheading">Confirm Your Account</td>
</tr>
<tr>
	<td class="memberlabel">Username:</td>
	<td class="memberfield"><input class="memberinput" type="text" name="username" value="<?php echo htmlspecialchars($username);?>" />
		<br />Enter the username you chose when you signed up.
	</td>
</tr>
<tr>
	<td class="memberlabel">Confirmation ID#:</td>
	<td class="memberfield"><input class="memberinput" type="text" name="cid" value="<?php echo htmlspecialchars($cid);?>" />
		<br />Enter the confirmation id included in your sign-up email. If you have lost this email we can
		<a href="remind.php">resend it</a>.
	</td>
</tr>
<tr>
	<td class="memberlabel">&nbsp;</td>
	<td class="memberfield"><input class="memberinput" type="submit" name="confirm" value="Confirm Account" /></td>
</tr>
</table>
</div>
</form>
<script language="JavaScript" type="text/javascript">
<!--
document.forms.confirmform['username'].focus();
//-->
</script>
<?php

		}

	}

}
require_once(dirname(__FILE__).'/footer.php');

?>
