I built a custom registration form for cb 1.2.3, but I'm having trouble getting a similar form to work in version 1.7.1.
It seems I can't get the cbsecuritym3 to pull correctly, before all I needed to do was use cbGetSpoofInputTag( 'registerForm' ), but it seems now I need to call it differently like
Code:
$cbSpoofString = cbSpoofString( null, 'registerForm' );
echo cbGetSpoofInputTag( null, $cbSpoofString );
However, no matter what I try I can't seem to get it to pull the proper value.
What has changed in the newer version?
I've spent the last 12 hours straight trying to get this thing to work but I'm at a total loss.
Here's my actual form:
Code:
<form action="index.php?option=com_comprofiler" method="post" id="cbcheckedadminForm" name="adminForm" class="cb_form" onsubmit="parent.location='index.php?option=com_comprofiler';" enctype="multipart/form-data">
<input type="hidden" name="id" value="0">
<input type="hidden" name="gid" value="0">
<input type="hidden" name="emailpass" value="0">
<input type="hidden" name="option" value="com_comprofiler">
<input type="hidden" name="task" value="saveregisters">
<?php include_once('components/com_comprofiler/registration.php');
$cbSpoofString = cbSpoofString( null, 'registerForm' );
echo cbGetSpoofInputTag( null, $cbSpoofString );
echo cbGetRegAntiSpamInputTag( $regAntiSpamValues ); ?>
<table class="contentpane" id="registrationTable">
<tbody><tr><td colspan="2" id="cbpp"><div class="cbregfield"><span class="cbreglabel">First Name: </span> <span class="cbregfld"><div class="cb_field" style="display:inline"><input type="text" name="firstname" id="firstname" value="" size="25" maxlength="100" class="required inputbox" title="First Name:Please enter your real first name."><span class="cbFieldIcons"> <img src="http://spencer.kiddohub.com/components/com_comprofiler/plugin/templates/default/images/mini-icons/icon-16-required.png" width="16" height="16" alt="* This Field is required" title="This Field is required"> <img src="http://spencer.kiddohub.com/components/com_comprofiler/plugin/templates/default/images/mini-icons/icon-16-profile-yes.png" width="16" height="16" alt="This Field IS visible on profile" title="This Field IS visible on profile"> <img src="http://spencer.kiddohub.com/components/com_comprofiler/plugin/templates/default/images/mini-icons/icon-16-info.png" alt="Information for: First Name : Please enter your real first name." title="" onmouseover="return overlib('Please enter your real first name.', CAPTION, 'First Name');" onmouseout="return nd();"></span></div></span></div>
<div class="cbregfield"><span class="cbreglabel">Last Name: </span> <span class="cbregfld"><div class="cb_field" style="display:inline"><input type="text" name="lastname" id="lastname" value="" size="25" maxlength="100" class="required inputbox" title="Last Name:Please enter your real last name."><span class="cbFieldIcons"> <img src="http://spencer.kiddohub.com/components/com_comprofiler/plugin/templates/default/images/mini-icons/icon-16-required.png" width="16" height="16" alt="* This Field is required" title="This Field is required"> <img src="http://spencer.kiddohub.com/components/com_comprofiler/plugin/templates/default/images/mini-icons/icon-16-profile-yes.png" width="16" height="16" alt="This Field IS visible on profile" title="This Field IS visible on profile"> <img src="http://spencer.kiddohub.com/components/com_comprofiler/plugin/templates/default/images/mini-icons/icon-16-info.png" alt="Information for: Last Name : Please enter your real last name." title="" onmouseover="return overlib('Please enter your real last name.', CAPTION, 'Last Name');" onmouseout="return nd();"></span></div></span></div>
<br>
<div class="cbregfield"><span class="cbreglabel">Email: </span> <span class="cbregfld"><div class="cb_field" style="display:inline"><input type="text" name="email" id="email" value="" size="25" class="email required inputbox" title="Email:Please enter a valid e-mail address. A confirmation email will be sent to this address upon registration."><span class="cbFieldIcons"> <img src="http://spencer.kiddohub.com/components/com_comprofiler/plugin/templates/default/images/mini-icons/icon-16-required.png" width="16" height="16" alt="* This Field is required" title="This Field is required"> <img src="http://spencer.kiddohub.com/components/com_comprofiler/plugin/templates/default/images/mini-icons/icon-16-profile-no.png" width="16" height="16" alt="This Field IS NOT visible on profile" title="This Field IS NOT visible on profile"> <img src="http://spencer.kiddohub.com/components/com_comprofiler/plugin/templates/default/images/mini-icons/icon-16-info.png" alt="Information for: Email : Please enter a valid e-mail address. A confirmation email will be sent to this address upon registration." title="" onmouseover="return overlib('Please enter a valid e-mail address. A confirmation email will be sent to this address upon registration.', CAPTION, 'Email');" onmouseout="return nd();"></span></div></span></div>
<div class="cbregfield"><span class="cbregfld">Username <div class="cb_field" style="display:inline"><input type="text" name="username" id="username" value="" size="25" maxlength="150" class="cbusername {cbusername:true,minlength:3,maxlength:150} required inputbox" title="Username:Please enter a valid username. No spaces, at least 3 characters and contain 0-9,a-z,A-Z"><span class="cbFieldIcons"> <img src="http://spencer.kiddohub.com/components/com_comprofiler/plugin/templates/default/images/mini-icons/icon-16-required.png" width="16" height="16" alt="* This Field is required" title="This Field is required"> <img src="http://spencer.kiddohub.com/components/com_comprofiler/plugin/templates/default/images/mini-icons/icon-16-profile-yes.png" width="16" height="16" alt="This Field IS visible on profile" title="This Field IS visible on profile"> <img src="http://spencer.kiddohub.com/components/com_comprofiler/plugin/templates/default/images/mini-icons/icon-16-info.png" alt="Information for: Username : Please enter a valid username. No spaces, at least 3 characters and contain 0-9,a-z,A-Z" title="" onmouseover="return overlib('Please enter a valid username. No spaces, at least 3 characters and contain 0-9,a-z,A-Z', CAPTION, 'Username');" onmouseout="return nd();"></span></div><br></span></div>
Password: <div class="cb_field" style="display:inline"><input type="password" name="password" id="password" value="" autocomplete="off" size="25" maxlength="50" class="{minlength:6,maxlength:50} required inputbox" title="Password:Please enter a valid password. No spaces, at least 6 characters and contain lower and upper-case letters, numbers and special signs"><span class="cbFieldIcons"> <img src="http://spencer.kiddohub.com/components/com_comprofiler/plugin/templates/default/images/mini-icons/icon-16-required.png" width="16" height="16" alt="* This Field is required" title="This Field is required"> <img src="http://spencer.kiddohub.com/components/com_comprofiler/plugin/templates/default/images/mini-icons/icon-16-profile-no.png" width="16" height="16" alt="This Field IS NOT visible on profile" title="This Field IS NOT visible on profile"> <img src="http://spencer.kiddohub.com/components/com_comprofiler/plugin/templates/default/images/mini-icons/icon-16-info.png" alt="Information for: Password : Please enter a valid password. No spaces, at least 6 characters and contain lower and upper-case letters, numbers and special signs" title="" onmouseover="return overlib('Please enter a valid password. No spaces, at least 6 characters and contain lower and upper-case letters, numbers and special signs', CAPTION, 'Password');" onmouseout="return nd();"></span><input type="password" name="password__verify" id="password__verify" value="" autocomplete="off" size="25" maxlength="50" class="{minlength:6,maxlength:50,equalTo:'#password'} required inputbox" title="Verify Password:Please enter a valid password. No spaces, at least 6 characters and contain lower and upper-case letters, numbers and special signs"><span class="cbFieldIcons"> <img src="http://spencer.kiddohub.com/components/com_comprofiler/plugin/templates/default/images/mini-icons/icon-16-required.png" width="16" height="16" alt="* This Field is required" title="This Field is required"> <img src="http://spencer.kiddohub.com/components/com_comprofiler/plugin/templates/default/images/mini-icons/icon-16-profile-no.png" width="16" height="16" alt="This Field IS NOT visible on profile" title="This Field IS NOT visible on profile"> <img src="http://spencer.kiddohub.com/components/com_comprofiler/plugin/templates/default/images/mini-icons/icon-16-info.png" alt="Information for: Verify Password : Please enter a valid password. No spaces, at least 6 characters and contain lower and upper-case letters, numbers and special signs" title="" onmouseover="return overlib('Please enter a valid password. No spaces, at least 6 characters and contain lower and upper-case letters, numbers and special signs', CAPTION, 'Verify Password');" onmouseout="return nd();"></span></div><br></td></tr> <tr>
<td colspan="2" class="contentpaneopen"> </td>
</tr>
<tr>
<td colspan="2">
<span class="cb_button_wrapper"><input type="submit" value="Register" class="button"></span>
</td>
</tr>
</tbody></table>
</form>
And here's my php file I include:
Code:
<?php
defined('_JEXEC') or die('Restricted access');
global $mosConfig_debug, $mosConfig_lang, $mosConfig_emailpass, $emailpass, $option, $task;
$task = $_GET['option'];
$user =& JFactory::getUser();
$user_id = $user->get('id');
if ($user_id) {
}
else if($task == 'com_comprofiler') {
}
else {
$cbSpoofString = null;
$regAntiSpamValues = null;
function cbMakeRandomString( $stringLength = 8, $noCaps = false ) {
global $_CB_framework;
if ( $noCaps ) {
$chars = 'abchefghjkmnpqrstuvwxyz0123456789';
} else {
$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
}
$len = strlen( $chars );
$rndString = '';
$stat = @stat( __FILE__ );
if ( ! is_array( $stat ) ) {
$stat = array();
}
$stat[] = @php_uname();
$stat[] = uniqid( '', true );
$stat[] = microtime();
$stat[] = $_CB_framework->getCfg( 'secret' );
$stat[] = mt_rand( 0, mt_getrandmax() );
mt_srand( crc32( implode( ' ', $stat ) ) );
for ( $i = 0; $i < $stringLength; $i++ ) {
$rndString .= $chars[mt_rand( 0, $len - 1 )];
}
return $rndString;
}
function cbGetRegAntiSpams( $decrement = 0, $salt0 = null, $salt1 = null ) {
global $_CB_framework;
if ( ( $salt0 === null ) || ( $salt1 === null ) ) {
static $formSalt = null;
if ( $formSalt === null ) {
$formSalt = cbMakeRandomString( 16 );
}
$salt0 = $formSalt;
$salt1 = $formSalt;
}
$time = time();
$valtime = ( (int) ( $time / 10800 )) - $decrement;
// no IP addresses here, since on AOL it changes all the time.... $hostIPs = cbGetIParray();
if ( ( strlen( $salt0 ) == 16 ) && ( strlen( $salt1 ) == 16 ) ) {
$validate = array();
$validate[0] = 'cbrv1_' . md5( $salt0 . $_CB_framework->getCfg('secret') . $valtime ) . '_' . $salt0;
$validate[1] = 'cbrv1_' . md5( $salt1 . $_CB_framework->getCfg( 'db' ) . $valtime ) . '_' . $salt1;
return $validate;
} else {
_cbExpiredSessionJSterminate();
exit;
}
}
function cbGetRegAntiSpamFieldName() {
return 'cbrasitway';
}
function cbGetRegAntiSpamCookieName( $fieldValue ) {
return 'cbrvs';
/*
$md5Part = substr( $fieldValue, 6, 32 );
if ( ! preg_match( '/[0-9a-z]{32}/i', $md5Part ) ) {
return false;
}
return 'cbrvs_' . $md5Part;
*/
}
function cbGetRegAntiSpamInputTag( $cbGetRegAntiSpams = null ) {
if ( $cbGetRegAntiSpams === null ) {
$cbGetRegAntiSpams = cbGetRegAntiSpams();
}
cbimport( 'cb.session' );
CBCookie::setcookie( cbGetRegAntiSpamCookieName( $cbGetRegAntiSpams[0] ), $cbGetRegAntiSpams[1], false );
return "<input type=\"hidden\" name=\"" . cbGetRegAntiSpamFieldName() ."\" value=\"" . $cbGetRegAntiSpams[0] . "\" />\n";
}
function cbRegAntiSpamCheck( $mode = 1 ) {
global $_POST;
$validateValuePost = cbGetParam( $_POST, cbGetRegAntiSpamFieldName() );
$validateCookieName = cbGetRegAntiSpamCookieName( $validateValuePost );
if ( $validateCookieName === false ) {
$i = 2;
} else {
cbimport( 'cb.session' );
$validateValueCookie = CBCookie::getcookie( $validateCookieName );
$parts0 = explode( '_', $validateValuePost );
$parts1 = explode( '_', $validateValueCookie );
if ( ( count( $parts0 ) == 3 ) && ( count( $parts1 ) == 3 ) ) {
for($i = 0; $i < 2; $i++) {
$validate = cbGetRegAntiSpams( $i, $parts0[2], $parts1[2] );
if ( ( $validateValuePost == $validate[0] ) && ( $validateValueCookie == $validate[1] ) ) {
break;
}
}
} else {
$i = 2;
}
}
if ( $i == 2 ) {
if ( $mode == 2 ) {
return false;
}
_cbExpiredSessionJSterminate( 200 );
exit;
}
return true;
}
}
?>