Thanks for your reply, however I have that variable in place. I've double checked everything again and still get the same issue. I know it has to be something I'm missing somewhere, but I'm getting frustrated as to where. As no one has responded as to whether I can add my code or not, I'll assume it's okay (hope this is the right assumption).
<?php
/**
* @package MiaCMS
* @subpackage Users
* @author MiaCMS see README.php
* @copyright see README.php
* See COPYRIGHT.php for copyright notices and details.
* @license GNU/GPL Version 2, see LICENSE.php
* MiaCMS is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; version 2 of the License.
*/
/** 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>
<form action="index.php" method="post">
<table cellpadding="0" cellspacing="0" border="0" width="100%" class="contentpane">
<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>
</table>
</form>
<?php
}
function registerForm($option, $useractivation) {
$name = trim( mosGetParam( $_REQUEST, 'name', "" ) );
$username = trim( mosGetParam( $_REQUEST, 'username', "" ) );
$email = trim( mosGetParam( $_REQUEST, 'email', "" ) );
$whoareyou = trim(mosGetParam( $_REQUEST, 'whoareyou', "" ) );
$useractivation = trim( mosGetParam( $_REQUEST, 'useractivation', "" ) );
?>
<script language="javascript" type="text/javascript">
/* <![CDATA[ */
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.'));?>" );
form.name.focus();
} else if (form.username.value == "") {
alert( "<?php echo html_entity_decode(T_('Please enter a user name.'));?>" );
form.username.focus();
} 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 );?>" );
form.username.focus();
} else if (form.email.value == "" ) {
alert( "<?php echo html_entity_decode(T_('Please enter a valid e-mail address.'));?>" );
form.email.focus();
} else if (form.email2.value == "" ) {
alert( "<?php echo html_entity_decode(T_('Please enter a valid e-mail address for the verification.'));?>" );
form.email2.focus();
} 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'));?>" );
form.password.focus();
} else if (form.password2.value == "") {
alert( "<?php echo html_entity_decode(T_('Please verify the verification password.'));?>" );
form.password2.focus();
} 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.'));?>" );
form.password.value="";
form.password2.value="";
form.password.focus();
} 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 );?>" );
form.password.focus();
} else if ((form.password.value != "") && (form.email.value != form.email2.value)){
alert( "<?php printf( html_entity_decode(T_('Email and verification do not match, please try again.')));?>" );
form.email.value="";
form.email2.value="";
form.email.focus();
} else if ( form.whoareyou.value == "") {
alert( "<?php printf( html_entity_decode(T_('Please tell us who you are.')));?>" );
form.whoareyou.focus();
} else if ( form.accept.checked == false) {
alert( "<?php printf( html_entity_decode(T_('You must accept the Privacy Policy and Disclaimer, to continue.')));?>" );
form.accept.focus();
} 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="<?php echo $name; ?>" class="inputbox" /></td>
</tr>
<tr>
<td><?php echo T_('Username:'); ?> *</td>
<td><input type="text" name="username" size="40" value="<?php echo $username; ?>" class="inputbox" /></td>
</tr>
<tr>
<td><?php echo T_('E-mail:'); ?> *</td>
<td><input type="text" name="email" size="40" value="<?php echo $email; ?>" class="inputbox" /></td>
</tr>
<tr>
<td><?php echo T_('Verify E-mail:'); ?> *</td>
<td><input type="text" name="email2" class="inputbox" id="email2" value="<?php echo $email; ?>" size="40" /></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 valign="top"><?php echo T_('Who are You:'); ?> *</td>
<td>
<textarea name="whoareyou" cols="48" rows="4" id="whoareyou" class="inputbox" style="font-size:0.85em;"></textarea></td>
</tr>
<tr>
<td valign="top"><?php echo T_('Disclaimer and<br />Privacy Policy:'); ?> *</td>
<td>
<textarea name="privacypolicy" cols="48" rows="4" id="privacypolicy" class="inputbox" style="font-size:0.85em;" readonly="readonly"><?php echo T_('put your disclaimer here..'); ?></textarea>
</td>
</tr>
<tr>
<td align="right"> </td>
<td><input name="accept" type="checkbox" id="accept" value="yes" />
<?php echo T_('Yes, I Accept'); ?></td>
</tr>
<tr>
<td colspan="2"> </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="confirmRegistration" />
<input type="button" value="<?php echo T_('Send Registration'); ?>" class="button" onclick="submitbutton()" />
</form>
<?php
}
function confirmForm($option, $name, $username, $password, $email, $whoareyou, $useractivation) {
?>
<script language="javascript" type="text/javascript">
function reviseData()
{
var form = document.mosForm;
form.task.value='reviseRegistration';
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_('Please verify that the following data is correct and click the button below to complete registration.'); ?> </td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td width="15%"><?php echo T_('Name:'); ?> </td>
<td><strong><?php echo $name;?></strong><input type="hidden" name="name" size="40" value="<?php echo $name;?>" /></td>
</tr>
<tr>
<td><?php echo T_('Username:'); ?> </td>
<td><strong><?php echo $username;?></strong><input type="hidden" name="username" size="40" value="<?php echo $username;?>" /></td>
<tr>
<td><?php echo T_('E-mail:'); ?> </td>
<td><strong><?php echo $email;?></strong><input type="hidden" name="email" size="40" value="<?php echo $email;?>" /></td>
</tr>
<tr>
<td><?php echo T_('Who are you:'); ?> </td>
<td><b><?php echo $whoareyou;?></b><input type="hidden" name="whoareyou" size="40" value="<?php echo $whoareyou;?>" /></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr align="center">
<td colspan="2"><table width="80%" border="0" cellspacing="0" cellpadding="0">
<tr align="center" valign="top">
<td width="45%" align="center" valign="top" style="background-color:#FFE9E6;"><?php echo T_('Go back and correct your data.'); ?></td>
<td width="10%" valign="top"> </td>
<td width="45%" align="center" style="background-color:#E8FFE8"><?php echo T_('The data is correct.'); ?></td>
</tr>
<tr align="center" valign="middle">
<td height="32" align="center" valign="middle" style="background-color:#FFE9E6;"><input name="back" type="button" class="button" id="back" value="<?php echo T_('Correct Your Data'); ?>" onclick="reviseData()"></td>
<td> </td>
<td align="center" valign="middle" style="background-color:#E8FFE8"><input name="confirm" type="submit" class="button" id="confirm" value="<?php echo T_('Confirm Registration'); ?>"/></td>
</tr>
</table></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="password" value="<?php echo $password;?>" />
<input type="hidden" name="option" value="<?php echo $option; ?>" />
<input type="hidden" name="task" value="saveRegistration" />
</form>
<?php
}
}
?>
[<?php
/**
* @package MiaCMS
* @author MiaCMS see README.php
* @copyright see README.php
* See COPYRIGHT.php for copyright notices and details.
* @license GNU/GPL Version 2, see LICENSE.php
* MiaCMS is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; version 2 of the License.
*/
/** ensure this file is being included by a parent file */
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
$task = mosGetParam( $_REQUEST, 'task', "" );
require_once( $mainframe->getPath( 'front_html' ) );
switch( $task ) {
case "lostPassword":
lostPassForm( $option );
break;
case "sendNewPass":
sendNewPass( $option );
break;
case "register":
case "reviseRegistration":
registerForm( $option, $mosConfig_useractivation );
break;
case "confirmRegistration":
confirmRegistration( $option );
break;
case "saveRegistration":
saveRegistration( $option );
break;
case "activate":
activate( $option );
break;
}
function lostPassForm( $option ) {
global $mainframe;
$mainframe->SetPageTitle(T_('Lost your Password?'));
HTML_registration::lostPassForm($option);
}
function sendNewPass( $option ) {
global $database, $Itemid;
global $mosConfig_live_site, $mosConfig_sitename, $mosConfig_fromname;
$_live_site = $mosConfig_live_site;
$_sitename = $mosConfig_sitename;
// ensure no malicous sql gets past
$checkusername = trim( mosGetParam( $_POST, 'checkusername', '') );
$checkusername = $database->getEscaped( $checkusername );
$confirmEmail = trim( mosGetParam( $_POST, 'confirmEmail', '') );
$confirmEmail = $database->getEscaped( $confirmEmail );
$database->setQuery( "SELECT id FROM #__users"
. "\nWHERE username='$checkusername' AND email='$confirmEmail'"
);
if (!($user_id = $database->loadResult()) || !$checkusername || !$confirmEmail) {
mosRedirect( "index.php?option=$option&task=lostPassword&mosmsg=".T_('Sorry, no corresponding user was found. Please make sure you entered a valid username and a valid email address. Both are required.') );
}
$database->setQuery( "SELECT name, email FROM #__users"
. "\n WHERE usertype='super administrator'" );
$rows = $database->loadObjectList();
foreach ($rows AS $row) {
$adminName = $row->name;
$adminEmail = $row->email;
}
$rawpass = mosMakePassword();
$message = sprintf(T_("The user account %s has this email associated with it.\n
A web user from %s has just requested that a new password be sent.\n\n
Your New Password is: %s\n\n
If you didn't ask for this, don't worry. You are seeing this message, not them.
If this was an error just login with your new password and then change your password to what you would like it to be."),
$checkusername, $mosConfig_live_site, $rawpass);
#eval ("\$message = \"$message\";");
$subject = sprintf(T_('%s :: New password for - %s'),$_sitename, $checkusername);
#eval ("\$subject = \"$subject\";");
mosMail($mosConfig_mailfrom, $mosConfig_fromname, $confirmEmail, $subject, $message);
$newpass = md5( $rawpass );
$sql = "UPDATE #__users SET password='$newpass' WHERE id='$user_id'";
$database->setQuery( $sql );
if (!$database->query()) {
die("SQL error" . $database->stderr(true));
}
$loginfo = new mosLoginDetails($checkusername, $rawpass);
$mambothandler =& mosMambotHandler::getInstance();
$mambothandler->loadBotGroup('authenticator');
$mambothandler->trigger('userChange', array($loginfo));
mosRedirect( "index.php?Itemid=$Itemid&mosmsg=".T_('New User Password created and sent!') );
}
function registerForm( $option, $useractivation ) {
global $mainframe, $database, $my, $acl;
if (!$mainframe->getCfg( 'allowUserRegistration' )) {
mosNotAuth();
return;
}
$mainframe->SetPageTitle(T_('Registration'));
HTML_registration::registerForm($option, $useractivation);
}
function confirmRegistration ($option)
{
$name = trim( mosGetParam( $_REQUEST, 'name', "" ) );
$username = trim( mosGetParam( $_REQUEST, 'username', "" ) );
$password = trim( mosGetParam( $_REQUEST, 'password', "" ) );
$email = trim( mosGetParam( $_REQUEST, 'email', "" ) );
$whoareyou = trim( mosGetParam( $_REQUEST, 'whoareyou', "" ) );
$useractivation = trim( mosGetParam( $_REQUEST, 'useractivation', "" ) );
HTML_registration::confirmForm($option, $name, $username, $password, $email, $whoareyou, $useractivation);
}
function saveRegistration( $option ) {
global $database, $my, $acl;
global $mosConfig_sitename, $mosConfig_live_site, $mosConfig_useractivation, $mosConfig_allowUserRegistration;
global $mosConfig_mailfrom, $mosConfig_fromname, $mosConfig_mailfrom, $mosConfig_fromname;
if ($mosConfig_allowUserRegistration=='0') {
mosNotAuth();
return;
}
$row = new mosUser( $database );
if (!$row->bind( $_POST, 'usertype' )) {
echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";
exit();
}
mosMakeHtmlSafe($row);
$row->id = 0;
$row->usertype = 'Registered';
$row->gid = $acl->get_group_id( 'Registered', 'ARO' );
if ($mosConfig_useractivation == '1') {
$row->activation = md5( mosMakePassword() );
$row->block = '1';
}
if (!$row->check()) {
echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";
exit();
}
$pwd = $row->password;
$row->password = md5( $row->password );
$row->registerDate = date("Y-m-d H:i:s");
if (!$row->store()) {
echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";
exit();
}
$row->checkin();
$name = $row->name;
$email = $row->email;
$username = $row->username;
$whoareyou = $row->whoareyou;
$subject = sprintf (T_('Account details for %s at %s'), $name, $mosConfig_sitename);
$subject = html_entity_decode($subject, ENT_QUOTES);
$mambothandler =& mosMambotHandler::getInstance();
$mambothandler->loadBotGroup('authenticator');
if ($mosConfig_useractivation=="1"){
$message = sprintf (T_('Hello %s,
Thank you for registering at %s. Your account has been created but, as a precaution, it must be activated by you before you can use it.
To activate the account click on the following link or copy and paste it in your browser:
%s
After activation you may login to %s using the following username and password:
Username - %s
Password - %s'),
$name, $mosConfig_sitename, $mosConfig_live_site."/index.php?option=com_registration&task=activate&activation=".$row->activation, $mosConfig_live_site, $username, $pwd);
$loginfo = new mosLoginDetails($username, $pwd);
$mambothandler->trigger('userRegister', array($loginfo));
}
else {
$message = sprintf (T_("Hello %s,
Thank you for registering at %s.
You may now login to %s using the username and password you registered with."),
$name, $mosConfig_sitename, $mosConfig_live_site);
$loginfo = new mosLoginDetails($username, $pwd);
$mambothandler->trigger('userRegister', array($loginfo));
$mambothandler->trigger('userActivate', array($loginfo));
}
$message = html_entity_decode($message, ENT_QUOTES);
// Send email to user
if ($mosConfig_mailfrom != "" && $mosConfig_fromname != "") {
$adminName2 = $mosConfig_fromname;
$adminEmail2 = $mosConfig_mailfrom;
} else {
$database->setQuery( "SELECT name, email FROM #__users"
."\n WHERE usertype='super administrator'" );
$rows = $database->loadObjectList();
$row2 = $rows[0];
$adminName2 = $row2->name;
$adminEmail2 = $row2->email;
}
mosMail($adminEmail2, $adminName2, $email, $subject, $message);
// Send notification to all administrators
$subject2 = sprintf (T_('Account details for %s at %s'), $name, $mosConfig_sitename);
$message2 = sprintf (T_('Hello %s,
A new user has registered at %s.
This email contains their details:
Name - %s
e-mail - %s
Username - %s
Who are you - %s
Please do not respond to this message as it is automatically generated and is for information purposes only'),
$adminName2, $mosConfig_sitename, $row->name, $email, $username, $whoareyou);
$subject2 = html_entity_decode($subject2, ENT_QUOTES);
$message2 = html_entity_decode($message2, ENT_QUOTES);
// get superadministrators id
$admins = $acl->get_group_objects( 25, 'ARO' );
foreach ( $admins['users'] AS $id ) {
$database->setQuery( "SELECT email, sendEmail FROM #__users"
."\n WHERE id='$id'" );
$rows = $database->loadObjectList();
$row = $rows[0];
if ($row->sendEmail) {
mosMail($adminEmail2, $adminName2, $row->email, $subject2, $message2);
}
}
if ( $mosConfig_useractivation == "1" ){
echo '<div class="componentheading">'.T_('Registration Complete').'</div><br />';
echo T_('Your account has been created and an activation link has been sent to the e-mail address you entered. Note that you must activate the account by clicking on the activation link before you can login.');
} else {
echo '<div class="componentheading">'.T_('Registration Complete').'</div><br />';
echo T_('You may now login.');
}
}
function activate( $option ) {
global $database;
global $mosConfig_useractivation, $mosConfig_allowUserRegistration;
if ($mosConfig_allowUserRegistration == '0' || $mosConfig_useractivation == '0') {
mosNotAuth();
return;
}
$activation = mosGetParam( $_REQUEST, 'activation', '' );
$activation = $database->getEscaped( $activation );
if (empty( $activation )) {
echo '<div class="componentheading">'.T_('Invalid Activation Link!').'</div><br />';
echo T_('There is no such account in our database or the account has already been activated.');
return;
}
$database->setQuery( "SELECT username FROM #__users"
."\n WHERE activation='$activation' AND block='1'" );
$username = $database->loadResult();
if ($username) {
$database->setQuery( "UPDATE #__users SET block='0', activation='' WHERE activation='$activation' AND block='1'" );
if (!$database->query()) {
echo "SQL error" . $database->stderr(true);
}
echo '<div class="componentheading">'.T_('Activation Complete!').'</div><br />';
echo T_('Your account has been activated successfully. You can now login using the username and password you chose during registration.');
$loginfo = new mosLoginDetails($username);
$mambothandler =& mosMambotHandler::getInstance();
$mambothandler->loadBotGroup('authenticator');
$mambothandler->trigger('userActivate', array($loginfo));
} else {
echo '<div class="componentheading">'.T_('Invalid Activation Link!').'</div><br />';
echo T_('There is no such account in our database or the account has already been activated.');
}
}
function is_email($email){
$rBool=false;
if(preg_match("/[\w\.\-]+@\w+[\w\.\-]*?\.\w{1,4}/", $email)){
$rBool=true;
}
return $rBool;
}
?>