Skip to Content Skip to Menu

[SOLVED] Changes to how cbsecuritym3

  • sfraise
  • sfraise
  • OFFLINE
  • Posts: 96
  • Thanks: 14
  • Karma: 4
12 years 8 months ago - 12 years 8 months ago #190353 by sfraise
[SOLVED] Changes to how cbsecuritym3 was created by sfraise
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">&nbsp;</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; } } ?>
Last edit: 12 years 8 months ago by krileon.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48438
  • Thanks: 8275
  • Karma: 1443
12 years 8 months ago #190376 by krileon
Replied by krileon on topic Re: Changes to how cbsecuritym3
The below is the exact usage of CBs own registration form. I recommend trying it. For future reference the best way to mimic CBs forms is to simply review the forms source. You can find CBs registration form in comprofiler.html.php in function registerForm.
Code:
cbGetSpoofInputTag( null, cbSpoofString( null, 'registerForm' ) ) cbGetRegAntiSpamInputTag( cbGetRegAntiSpams() )


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

  • sfraise
  • sfraise
  • OFFLINE
  • Posts: 96
  • Thanks: 14
  • Karma: 4
12 years 8 months ago - 12 years 8 months ago #190531 by sfraise
Replied by sfraise on topic Re: Changes to how cbsecuritym3
Thanks Krileon,

I get the same result changing it to this method.
I actually pulled everything I have here straight out of the comprofiler.html.php file, this is what's confusing me so much here. The cbrasitway value works fine, it's just that cbsecuritym3 value that doesn't pull right. The only thing I didn't pull out of the code are the emailpass and option values, I just declared them as com_comprofiler and saveregisters, but I wouldn't imagine that would have anything to do with it.

Here's how it's listed in my comprofiler.html.php file starting at line 1394:
Code:
$regFormTag = '<form action="' . cbSef("index.php?option=".$option) . '" 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="' .$emailpass . '" /> <input type="hidden" name="option" value="' . $option . '" /> <input type="hidden" name="task" value="saveregisters" /> ' . cbGetSpoofInputTag( null, $cbSpoofString ) . ' ' . cbGetRegAntiSpamInputTag( $regAntiSpamValues ) . "\n" ;

and the cbSpoofString variable is set on line 1237
Code:
$cbSpoofString = cbSpoofString( null, 'registerForm' );

I have to be missing something somewhere here.
Last edit: 12 years 8 months ago by sfraise.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48438
  • Thanks: 8275
  • Karma: 1443
12 years 8 months ago #190589 by krileon
Replied by krileon on topic Re: Changes to how cbsecuritym3
Don't know what to tell you. We don't support external registrations. The API works outside of CB just fine as I've tons of spam checking all over GJ. What I've provided in my previous post is the exact same usage as CBs own registration page. Ensure you're including CBs full API however (see tutorials within my signature on how to include CB API externally).


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

  • sfraise
  • sfraise
  • OFFLINE
  • Posts: 96
  • Thanks: 14
  • Karma: 4
12 years 8 months ago #190683 by sfraise
Replied by sfraise on topic Re: Changes to how cbsecuritym3
What you gave isn't the actual usage that I have in my comprofiler.html.php using version 1.7.1, and if I try to change it to the method you gave it results in a session error from the actual cb registration form. The way it is in my file is how I showed it in the previous post.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48438
  • Thanks: 8275
  • Karma: 1443
12 years 8 months ago #190714 by krileon
Replied by krileon on topic Re: Changes to how cbsecuritym3
The exact usage is as follows; I provided an example. You can write it however you want, but that's what is being used.
Code:
$cbSpoofString = cbSpoofString( null, 'registerForm' ); $regAntiSpamValues = cbGetRegAntiSpams(); ' . cbGetSpoofInputTag( null, $cbSpoofString ) . ' ' . cbGetRegAntiSpamInputTag( $regAntiSpamValues ) . "\n"

Why are you trying to create a custom registration page? It's possible to completely redesign the registration to an extent using the CB PHP template file. You can also redesign it using pure jQuery in a CB new plugin using the before registration form display trigger (that's what CB Conditionals does for step by step).

In cases like this I hate to suggest it, but you're better off editing core code as CB has a lot of security checks in place to prevent fake registrations and spam.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum