<?php
/**
* @package Mambo Open Source
* @subpackage Users
* @copyright (C) 2005 - 2006 Mambo Foundation Inc.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
*
* Mambo was originally developed by Miro (www.miro.com.au) in 2000. Miro assigned the copyright in Mambo to The Mambo Foundation in 2005 to ensure
* that Mambo remained free Open Source software owned and managed by the community.
* Mambo is Free Software
*/ 

/** ensure this file is being included by a parent file */
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

class HTML_registration {
	function lostPassForm($option) {
		?>

<div class="componentheading">
	<?php echo T_('Lost your Password?'); ?>
</div>
<table cellpadding="0" cellspacing="0" border="0" width="100%" class="contentpane">
  <form action="index.php" method="post">
    <tr>
      <td colspan="2"><?php printf(T_('Please enter your Username and e-mail address then click on the Send Password button.%s You will receive a new password shortly.  Use the new password to access the site.'), '<br />') ?></td>
    </tr>
    <tr>
      <td><?php echo T_('Username:'); ?></td>
      <td><input type="text" name="checkusername" class="inputbox" size="40" maxlength="25" /></td>
    </tr>
    <tr>
      <td><?php echo T_('E-mail Address:'); ?></td>
      <td><input type="text" name="confirmEmail" class="inputbox" size="40" /></td>
    </tr>
    <tr>
      <td colspan="2"> <input type="hidden" name="option" value="<?php echo $option;?>" />
        <input type="hidden" name="task" value="sendNewPass" /> <input type="submit" class="button" value="<?php echo T_('Send Password'); ?>" /></td>
    </tr>
  </form>
</table>
<?php
	}

	function registerForm($option, $useractivation) {
?>
	<script language="javascript" type="text/javascript">
		function submitbutton() {
			var form = document.mosForm;
			//old method didn't really work, just excluded certain characters rather than limiting to a range of characters.
			//var r = new RegExp("[\<|\>|\"|\'|\%|\;|\(|\)|\&|\+|\-]", "i");
			var r = new RegExp("[^A-Za-z0-9]", "i");

			// do field validation
			if (form.name.value == "") {
				alert( "<?php echo html_entity_decode(T_('Please enter your name.'));?>" );
			} else if (form.username.value == "") {
				alert( "<?php echo html_entity_decode(T_('Please enter a user name.'));?>" );
			} else if (r.exec(form.username.value) || form.username.value.length < 3) {
				alert( "<?php printf( html_entity_decode(T_("Please enter a valid %s.  No spaces, more than %d characters and containing only the characters 0-9,a-z, or A-Z")), html_entity_decode(T_('Please enter a user name.')), 2 );?>" );
			} else if (form.email.value == "" ) {
				alert( "<?php echo html_entity_decode(T_('Please enter a valid e-mail address.'));?>" );
			} else if (form.password.value.length < 6) {
				alert( "<?php echo html_entity_decode(T_('Please enter a valid password -- more than 6 characters with no spaces and containing only the characters 0-9, a-z, or A-Z'));?>" );
			} else if (form.password2.value == "") {
				alert( "<?php echo html_entity_decode(T_('Please verify the password.'));?>" );
			} else if ((form.password.value != "") && (form.password.value != form.password2.value)){
				alert( "<?php echo html_entity_decode(T_('Password and verification do not match, please try again.'));?>" );
			} else if (r.exec(form.password.value)) {
				alert( "<?php printf( html_entity_decode(T_("Please enter a valid %s.  No spaces, more than %d characters and containing only the characters 0-9,a-z, or A-Z")), html_entity_decode(T_('Password:')), 6 );?>" );
			} else {
				form.submit();
			}
		}
	</script>

<div class="componentheading">
	<?php echo T_('Registration'); ?>
</div>
<form action="index.php" method="post" name="mosForm">
<table cellpadding="0" cellspacing="0" border="0" width="100%" class="contentpane">
<tr>
<td colspan="2"><?php echo T_('Fields marked with an asterisk (*) are required.'); ?></td>
</tr>
    <tr>
      <td width="30%"><?php echo T_('Name:'); ?> *</td>
      <td><input type="text" name="name" size="40" value="" class="inputbox" /></td>
    </tr>

    <tr>

      <td><?php echo T_('Username:'); ?> *</td>
      <td><input type="text" name="username" size="40" value="" class="inputbox" /></td>
    <tr>

      <td><?php echo T_('E-mail:'); ?> *</td>
      <td><input type="text" name="email" size="40" value="" class="inputbox" /></td>
    </tr>

    <tr>
      <td><?php echo T_('Password:'); ?> *</td>
      <td><input class="inputbox" type="password" name="password" size="40" value="" /></td>
    </tr>

    <tr>
      <td><?php echo T_('Verify Password:'); ?> *</td>
      <td><input class="inputbox" type="password" name="password2" size="40" value="" /></td>
    </tr>

    <tr>
      <td colspan="2">&nbsp;</td>
    </tr>

    <tr>
      <td colspan=2>
  </td>
		</tr>
</table>
<input type="hidden" name="id" value="0" />
<input type="hidden" name="gid" value="0" />
<input type="hidden" name="useractivation" value="<?php echo $useractivation;?>" />
<input type="hidden" name="option" value="<?php echo $option; ?>" />
<input type="hidden" name="task" value="saveRegistration" />
<input type="button" value="<?php echo T_('Send Registration'); ?>" class="button" onclick="submitbutton()" />
</form>
<?php
	}

}
?>
