/**
  * Checks the registration anti-spam
  *
  * @param  int      $mode  What to do if it fails: 2: Return false, 1: Terminates with exit
  * @return boolean
  */
 function cbRegAntiSpamCheck($mode = 1)
 {
     global $_POST;
     $validateValuePost = cbGetParam($_POST, cbGetRegAntiSpamFieldName());
     $validateCookieName = cbGetRegAntiSpamCookieName();
     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;
 }
    function _cbadmin_ajaxBatch($ajaxUrl, $cssSelectorReply, $formSelector, $postArray, $delay, $limitstart = 0, $limit = 30, $textDuringExecution = null, $textWhenDone = null, $cssSelectorTitle, $titleTextWhenDone)
    {
        global $_CB_framework;
        $ajaxUrl = addslashes($ajaxUrl);
        $cbSpoofField = cbSpoofField();
        $cbSpoofString = cbSpoofString(null, 'cbadmingui');
        $regAntiSpamFieldName = cbGetRegAntiSpamFieldName();
        $regAntiSpamValues = cbGetRegAntiSpams();
        cbGetRegAntiSpamInputTag($regAntiSpamValues);
        // sets the cookie
        $regAntiSpZ = $regAntiSpamValues[0];
        $postString = '';
        foreach ($postArray as $k => $v) {
            if (is_array($v)) {
                foreach ($v as $vv) {
                    $postString .= '&' . urlencode($k) . '[]=' . urlencode($vv);
                }
            } else {
                $postString .= '&' . urlencode($k) . '=' . urlencode($v);
            }
        }
        $postString = addslashes($postString);
        //$errorText				=	addslashes( $errorText );
        $textWaiting = addslashes(CBTxt::T('Waiting delay for next batch...'));
        $textExecuting = addslashes($textDuringExecution ? $textDuringExecution : CBTxt::T('Executing'));
        $textFinished = addslashes($textWhenDone ? $textWhenDone : CBTxt::T('Done'));
        $textError = addslashes(CBTxt::T('ERROR!'));
        $titleTextWhenDone = addslashes($titleTextWhenDone);
        $_CB_framework->outputCbJQuery(<<<EOT
\t{
\t\tvar cbanimate = function() {
\t\t\t\$(this).animate({width:'100%'},20000,function(){
\t\t\t\t\$(this).animate({width:'0%'},1000,cbanimate);
\t\t\t});
\t\t};
\t\tvar cbajaxjsonbatch = function(limitstart,limit,successFnct){
\t\t\t\$.ajax( {\ttype: 'POST',
\t\t\t\t\t\turl:  '{$ajaxUrl}',
\t\t\t\t\t\tdata: \$('{$formSelector}').serialize() + '&{$cbSpoofField}=' + encodeURIComponent('{$cbSpoofString}') + '&{$regAntiSpamFieldName}=' + encodeURIComponent('{$regAntiSpZ}') + '{$postString}' + '&limitstart=' + limitstart,
\t\t\t\t\t\tsuccess: function(response) {
\t\t\t\t\t\t\t\$('{$cssSelectorReply}'+'Bar div').stop().animate( {width:'100%'},500).animate( {width:'0%'},200, function() { \$(this).css({"background-color":"#8f8"}) });
\t\t\t\t\t\t\t\$('{$cssSelectorReply}').fadeOut(400, function() {
\t\t\t\t\t\t\t\t\$(this).html(response.htmlcontent).fadeIn(400, function() {
\t\t\t\t\t\t\t\t\tif ( response.result == 1 ) {
\t\t\t\t\t\t\t\t\t\$(this).each( function() {
\t\t\t\t\t\t\t\t\t\t\$('{$cssSelectorReply}'+'Bar span').html('{$textWaiting}')
\t\t\t\t\t\t\t\t\t\t.siblings('div').animate( {width:'100%'},{$delay}*1000,'linear', function() {
\t\t\t\t\t\t\t\t\t\t\t\$(this).animate( {width:'0%'},200, function() {
\t\t\t\t\t\t\t\t\t\t\t\tcbajaxjsonbatch(limitstart+limit,limit,successFnct);
\t\t\t\t\t\t\t\t\t\t\t});
\t\t\t\t\t\t\t\t\t\t});
\t\t\t\t\t\t\t\t\t});
\t\t\t\t\t\t\t\t\t} else if ( response.result == 2 ) {
\t\t\t\t\t\t\t\t\t\t\$('{$cssSelectorReply}'+'Bar span').html('{$textFinished}');
\t\t\t\t\t\t\t\t\t\tif (successFnct) {
\t\t\t\t\t\t\t\t\t\t\tsuccessFnct.call(response);
\t\t\t\t\t\t\t\t\t\t}
\t\t\t\t\t\t\t\t\t} else {
\t\t\t\t\t\t\t\t\t\t\$('{$cssSelectorReply}'+'Bar span').html('{$textError}')
\t\t\t\t\t\t\t\t\t\t.siblings('div').css({"background-color":"#fcc"});
\t\t\t\t\t\t\t\t\t}
\t\t\t\t\t\t\t\t});
\t\t\t\t\t\t\t})
\t\t\t\t\t\t},
\t\t\t\t\t\terror: function (XMLHttpRequest, textStatus, errorThrown) {
\t\t\t\t\t\t\t\$('{$cssSelectorReply}'+'Bar div').stop().animate( {width:'100%'},500).css({"background-color":"#f87"});
\t\t\t\t\t\t\t\$('{$cssSelectorReply}'+'Bar span').html('{$textError}');
\t\t\t\t\t\t\t\$('{$cssSelectorReply}').hide().html( ( errorThrown ? errorThrown : textStatus ? textStatus : 'No additional message' ).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;") ).fadeIn('fast');
\t\t\t\t\t\t},
\t\t\t\t\t\tdataType: 'json'
\t\t\t});
\t\t\t\$('{$cssSelectorReply}'+'Bar span').html('{$textExecuting}')
\t\t\t.siblings('div').css({"background-color":"#ee8"}).each(cbanimate);
\t\t};
\t\t
\t\tvar cbTitleSetDone = function() {
\t\t\t\$('{$cssSelectorTitle}').html('{$titleTextWhenDone}');
\t\t};
\t\t\tcbajaxjsonbatch({$limitstart},{$limit},cbTitleSetDone);
\t}
EOT
);
    }
    /**
     * Internal utility function to output JS for the Ajax content for function currencyconvertercheck() to update currencies
     *
     * @param  string  $ajaxUrl
     * @param  string  $cssSelectorReply
     * @return void
     */
    protected function _ajaxContent($ajaxUrl, $cssSelectorReply)
    {
        global $_CB_framework;
        $cbSpoofField = cbSpoofField();
        $cbSpoofString = cbSpoofString(null, 'guiajax');
        $regAntiSpamFieldName = cbGetRegAntiSpamFieldName();
        $regAntiSpamValues = cbGetRegAntiSpams();
        cbGetRegAntiSpamInputTag($regAntiSpamValues);
        // sets the cookie
        $regAntiSpZ = $regAntiSpamValues[0];
        //$errorText				=	addslashes( $errorText );
        $_CB_framework->outputCbJQuery(<<<EOT
\t\$.ajax( {\ttype: 'POST',
\t\t\t\turl:  '{$ajaxUrl}',
\t\t\t\tdata: '{$cbSpoofField}=' + encodeURIComponent('{$cbSpoofString}') + '&{$regAntiSpamFieldName}=' + encodeURIComponent('{$regAntiSpZ}'),
\t\t\t\tsuccess: function(response) {
\t\t\t\t\t\$('{$cssSelectorReply}').hide().html(response).fadeIn('fast');
\t\t\t\t},
\t\t\t\terror: function (XMLHttpRequest, textStatus, errorThrown) {
\t\t\t\t\t\$('{$cssSelectorReply}').hide().html(errorThrown ? errorThrown.message : textStatus).fadeIn('fast');
\t\t\t\t},
\t\t\t\tdataType: 'html'
\t});
EOT
);
    }
Exemplo n.º 4
0
	/**
	 * Loads the CB jQuery Validation into the header
	 *
	 * @param  string  $selector  The jQuery selector to bind validation to
	 * @return void
	 */
	static function loadValidation( $selector = '.cbValidation' )
	{
		global $_CB_framework;

		static $options				=	null;

		if ( ! $options ) {
			$liveSite				=	$_CB_framework->getCfg( 'live_site' ) . ( $_CB_framework->getUi() == 2 ? '/administrator' : null );
			$cbSpoofField			=	cbSpoofField();
			$cbSpoofString			=	cbSpoofString( null, 'fieldclass' );
			$regAntiSpamFieldName	=	cbGetRegAntiSpamFieldName();
			$regAntiSpamValues		=	cbGetRegAntiSpams();

			$messages				=	array(	'required' => addslashes( CBTxt::T( 'VALIDATION_ERROR_FIELD_REQUIRED', 'This field is required.' ) ),
													'remote' => addslashes( CBTxt::T( 'VALIDATION_ERROR_FIELD_NEEDS_FIX', 'Please fix this field.' ) ),
													'email' => addslashes( CBTxt::T( 'VALIDATION_ERROR_FIELD_EMAIL', 'Please enter a valid email address.' ) ),
													'url' => addslashes( CBTxt::T( 'VALIDATION_ERROR_FIELD_URL', 'Please enter a valid URL.' ) ),
													'date' => addslashes( CBTxt::T( 'VALIDATION_ERROR_FIELD_DATE', 'Please enter a valid date.' ) ),
													'dateISO' => addslashes( CBTxt::T( 'VALIDATION_ERROR_FIELD_DATE_ISO', 'Please enter a valid date (ISO).' ) ),
													'number' => addslashes( CBTxt::T( 'VALIDATION_ERROR_FIELD_NUMBER', 'Please enter a valid number.' ) ),
													'digits' => addslashes( CBTxt::T( 'VALIDATION_ERROR_FIELD_DIGITS_ONLY', 'Please enter only digits.' ) ),
													'creditcard' => addslashes( CBTxt::T( 'VALIDATION_ERROR_FIELD_CREDIT_CARD_NUMBER', 'Please enter a valid credit card number.' ) ),
													'equalTo' => addslashes( CBTxt::T( 'VALIDATION_ERROR_FIELD_SAME_VALUE_AGAIN', 'Please enter the same value again.' ) ),
													'notEqualTo' => addslashes( CBTxt::T( 'VALIDATION_ERROR_FIELD_DIFFERENT_VALUE', 'Please enter a different value, values must not be the same.' ) ),
													'accept' => addslashes( CBTxt::T( 'VALIDATION_ERROR_FIELD_EXTENSION', 'Please enter a value with a valid extension.' ) ),
													'maxlength' => addslashes( CBTxt::T( 'VALIDATION_ERROR_FIELD_MORE_THAN_CHARS', 'Please enter no more than {0} characters.' ) ),
													'minlength' => addslashes( CBTxt::T( 'VALIDATION_ERROR_FIELD_LEAST_CHARS', 'Please enter at least {0} characters.' ) ),
													'rangelength' => addslashes( CBTxt::T( 'VALIDATION_ERROR_FIELD_BETWEEN_AND_CHARS', 'Please enter a value between {0} and {1} characters long.' ) ),
													'range' => addslashes( CBTxt::T( 'VALIDATION_ERROR_FIELD_BETWEEN_AND_NUMBER', 'Please enter a value between {0} and {1}.' ) ),
													'max' => addslashes( CBTxt::T( 'VALIDATION_ERROR_FIELD_LESS_OR_EQUAL_TO', 'Please enter a value less than or equal to {0}.' ) ),
													'min' => addslashes( CBTxt::T( 'VALIDATION_ERROR_FIELD_GREATER_OR_EQUAL_TO', 'Please enter a value greater than or equal to {0}.' ) ),
													'maxWords' => addslashes( CBTxt::T( 'VALIDATION_ERROR_FIELD_MORE_THAN_WORDS', 'Please enter {0} words or less.' ) ),
													'minWords' => addslashes( CBTxt::T( 'VALIDATION_ERROR_FIELD_LEAST_WORDS', 'Please enter at least {0} words.' ) ),
													'rangeWords' => addslashes( CBTxt::T( 'VALIDATION_ERROR_FIELD_BETWEEN_AND_WORDS', 'Please enter between {0} and {1} words.' ) ),
													'extension' => addslashes( CBTxt::T( 'VALIDATION_ERROR_FIELD_EXTENSION', 'Please enter a value with a valid extension.' ) ),
													'pattern' => addslashes( CBTxt::T( 'VALIDATION_ERROR_FIELD_PATTERN', 'Invalid format.' ) ),
													'cbfield' => addslashes( CBTxt::T( 'VALIDATION_ERROR_FIELD_NEEDS_FIX', 'Please fix this field.' ) ),
													'cbremote' => addslashes( CBTxt::T( 'VALIDATION_ERROR_FIELD_NEEDS_FIX', 'Please fix this field.' ) ),
													'cbusername' => addslashes( CBTxt::T( 'VALIDATION_ERROR_FIELD_USERNAME', 'Please enter a valid username with no space at beginning or end and must not contain the following characters: < > \ " \' % ; ( ) &' ) ),
													'cburl' => addslashes( CBTxt::T( 'VALIDATION_ERROR_FIELD_URL', 'Please enter a valid URL.' ) ),
													'filesize' => addslashes( CBTxt::T( 'VALIDATION_ERROR_FILZSIZE', 'File size must exceed the minimum of {0} {2}s, but not the maximum of {1} {2}s.' ) ),
													'filesizemin' => addslashes( CBTxt::T( 'VALIDATION_ERROR_FILZSIZE_MIN', 'File size exceeds the minimum of {0} {2}s.' ) ),
													'filesizemax' => addslashes( CBTxt::T( 'VALIDATION_ERROR_FILZSIZE_MAX', 'File size exceeds the maximum of {1} {2}s.' ) )
			);

			$settings				=	array();

			$settings['cbfield']	=	array(	'url' => addslashes( $liveSite . '/index.php?option=com_comprofiler&view=fieldclass&function=[function]&user=[user]&field=[field]&reason=[reason]&format=raw' ),
												   'spooffield' => addslashes( $cbSpoofField ),
												   'spoofstring' => addslashes( $cbSpoofString ),
												   'spamfield' => addslashes( $regAntiSpamFieldName ),
												   'spamstring' => addslashes( $regAntiSpamValues[0] )
			);

			$options				=	array( 'messages' => $messages, 'settings' => $settings );
		}

		$js							=	null;

		static $selectors			=	array();

		if ( ! isset( $selectors[$selector] ) ) {
			$selectors[$selector]	=	true;

			$js						.=	"$( '" . addslashes( $selector ) . "' ).cbvalidate(" . json_encode( $options ) . ");";
		}

		static $rules				=	array();

		foreach ( self::$rules as $method => $rule ) {
			if ( ! isset( $rules[$method] ) ) {
				$rules[$method]		=	true;

				$js					.=	"$.validator.addMethod( '" . addslashes( $method ) . "', function( value, element, params ) {"
									.		$rule[0]
									.	"}, $.validator.format( '" . addslashes( $rule[1] ) . "' ) );";
			}
		}

		static $classRules			=	array();

		foreach ( self::$classRules as $class => $rules ) {
			if ( ! isset( $classRules[$class] ) ) {
				$classRules[$class]	=	true;

				$js					.=	"$.validator.addClassRules( '" . addslashes( $class ) . "', JSON.parse( '" . addcslashes( json_encode( $rules ), "'" ) . "' ) );";
			}
		}

		if ( $js ) {
			$_CB_framework->outputCbJQuery( $js, 'cbvalidate' );
		}
	}
    function ajaxCheckField(&$field, &$user, $reason, $validateParams = null)
    {
        global $_CB_framework;
        static $_CB_fieldajax_outputed = false;
        static $_CB_fieldajax_validator_outputed = false;
        $cbSpoofField = cbSpoofField();
        $cbSpoofString = cbSpoofString(null, 'fieldclass');
        $regAntiSpamFieldName = cbGetRegAntiSpamFieldName();
        $regAntiSpamValues = cbGetRegAntiSpams();
        $userid = (int) $user->id;
        $checking = _UE_CHECKING;
        // . '&start_debug=1',
        $live_site = $_CB_framework->getCfg('live_site');
        $regAntiSpZ = $regAntiSpamValues[0];
        $url = "index.php?option=com_comprofiler&task=fieldclass&function=checkvalue&user={$userid}&reason={$reason}";
        if ($_CB_framework->getUi() == 2) {
            $ajaxUrl = $live_site . '/administrator/' . $_CB_framework->backendUrl($url, false, 'raw');
        } else {
            $ajaxUrl = cbSef($url, false, 'raw');
        }
        if ($validateParams !== null && defined('_CB_VALIDATE_NEW')) {
            if ($_CB_fieldajax_validator_outputed !== true) {
                cbimport('cb.validator');
                cbValidator::addMethod('remotejhtml', <<<EOT
jQuery.validator.addMethod("remotejhtml", function(value, element, param) {
\t\t\tif ( this.optional(element) )
\t\t\t\treturn "dependency-mismatch";

\t\t\tvar previous = this.previousValue(element);

\t\t\tif (!this.settings.messages[element.name] )
\t\t\t\tthis.settings.messages[element.name] = {};
\t\t\tthis.settings.messages[element.name].remote = typeof previous.message == "function" ? previous.message(value) : previous.message;

\t\t\tparam = typeof param == "string" && {url:param} || param;

\t\t\tvar respField = \$('#'+\$(element).attr('id')+'__Response');
\t\t\tif ( respField.html() != '&nbsp;' ) {
\t\t\t\tif ( previous.old !== value ) {
\t\t\t\t\trespField.fadeOut('medium' );
\t\t\t\t} else {
\t\t\t\t\trespField.fadeIn('medium' );
\t\t\t\t}
\t\t\t}

\t\t\tif ( previous.old !== value && ! this.cbIsOnKeyUp && ! this.cbIsFormSubmitting ) {

\t\t\t\tvar inputid = \$(element).attr('id');
\t\t\t\tif ( ! \$('#'+inputid+'__Response').size() ) {
\t\t\t\t\tvar respField = '<div class=\\"cb_result_container\\"><div id=\\"' + inputid + '__Response\\">&nbsp;</div></div>';
\t\t\t\t\t\$(element).parent().each( function() {
\t\t\t\t\t\tif (this.tagName.toLowerCase() == 'td') {
\t\t\t\t\t\t\t\$(this).append(respField);
\t\t\t\t\t\t} else {
\t\t\t\t\t\t\t\$(this).after(respField);
\t\t\t\t\t\t}
\t\t\t\t\t\t\$(inputid+'__Response').hide();
\t\t\t\t\t} );
\t\t\t\t}

\t\t\t\tprevious.old = value;
\t\t\t\tvar validator = this;
\t\t\t\t// this.startRequest(element);
\t\t\t\tvar data = {};
\t\t\t\tdata[element.name] = value;
\t\t\t\t\$.ajax(\$.extend(true, {
\t\t\t\t\ttype: 'POST',
\t\t\t\t\turl:  '{$ajaxUrl}&field='+encodeURIComponent(inputid),
\t\t\t\t\tmode: "abort",
\t\t\t\t\tport: "validate" + element.name,
\t\t\t\t\tdataType: "html",\t/* """json", */
\t\t\t\t\tdata: 'value=' + encodeURIComponent(value) + '&{$cbSpoofField}=' + encodeURIComponent('{$cbSpoofString}') + '&{$regAntiSpamFieldName}=' + encodeURIComponent('{$regAntiSpZ}'),
\t\t\t\t\t/* data: data, */
\t\t\t\t\tsuccess: function(response) {
\t\t\t\t\t\t/* never errors on that one: */
\t\t\t\t\t\tvar submitted = validator.formSubmitted;
\t\t\t\t\t\tvalidator.prepareElement(element);
\t\t\t\t\t\tvalidator.formSubmitted = submitted;
\t\t\t\t\t\tvalidator.successList.push(element);
\t\t\t\t\t\tvalidator.showErrors();

\t\t\t\t\t\tprevious.valid = response;
\t\t\t\t\t\t// validator.stopRequest(element, response);

\t\t\t\t\t\tvar respField = \$('#'+\$(element).attr('id')+'__Response');
\t\t\t\t\t\trespField.fadeOut('fast', function() {
\t\t\t\t\t\t\trespField.html(response).fadeIn('fast');
\t\t\t\t\t\t} );
\t\t\t\t\t},
\t\t\t\t\terror: function(jqXHR, textStatus) {
\t\t\t\t\t\t// validator.stopRequest(element, textStatus);
\t\t\t\t\t\tvar respField = \$('#'+\$(element).attr('id')+'__Response');
\t\t\t\t\t\trespField.fadeOut('fast', function() {
\t\t\t\t\t\t\trespField.html(textStatus).fadeIn('fast');
\t\t\t\t\t\t} );
\t\t\t\t\t}
\t\t\t\t}, param));
\t\t\t\t\$('#'+inputid+'__Response').html('<img alt=\\"\\" src=\\"{$live_site}/components/com_comprofiler/images/wait.gif\\" /> {$checking}').fadeIn('fast');
\t\t\t\treturn true;\t\t// "pending";
\t\t\t} else if( this.pending[element.name] ) {
\t\t\t\treturn "pending";
\t\t\t}
\t\t\treturn true; // previous.valid;
}, 'Ajax Reply Error');
EOT
);
                /*
                jQuery.validator.addMethod("remotejhtml", function(value, element, param) {
                			if ( this.optional(element) )
                				return "dependency-mismatch";
                
                			var previous = this.previousValue(element);
                
                			if (!this.settings.messages[element.name] )
                				this.settings.messages[element.name] = {};
                			this.settings.messages[element.name].remote = typeof previous.message == "function" ? previous.message(value) : previous.message;
                
                			param = typeof param == "string" && {url:param} || param;
                
                			if ( previous.old !== value && ! this.cbIsOnKeyUp ) {
                				previous.old = value;
                				var validator = this;
                				this.startRequest(element);
                				var data = {};
                				data[element.name] = value;
                				$.ajax($.extend(true, {
                					type: 'POST',
                					url:  '$ajaxUrl&field='+encodeURIComponent(element.id),
                					mode: "abort",
                					port: "validate" + element.name,
                					dataType: "html",
                					data: 'value=' + encodeURIComponent(value) + '&$cbSpoofField=' + encodeURIComponent('$cbSpoofString') + '&$regAntiSpamFieldName=' + encodeURIComponent('$regAntiSpZ'),
                					success: function(response) {
                						if ( response == '' ) {
                							var submitted = validator.formSubmitted;
                							validator.prepareElement(element);
                							validator.formSubmitted = submitted;
                							validator.successList.push(element);
                							validator.showErrors();
                						} else {
                							var errors = {};
                							errors[element.name] =  response || validator.defaultMessage( element, "remote" );
                							validator.showErrors(errors);
                						}
                						previous.valid = response;
                						validator.stopRequest(element, response);
                					}
                				}, param));
                				return "pending";
                			} else if( this.pending[element.name] ) {
                				return "pending";
                			}
                			return previous.valid;
                }, 'Ajax Reply Error');
                */
                $_CB_fieldajax_validator_outputed = true;
            }
        } else {
            if ($_CB_fieldajax_outputed !== true) {
                $_CB_framework->outputCbJQuery(<<<EOT
\$.fn.cb_field_ajaxCheck = function() {
\tif ( ( \$(this).val() != '' ) && ( \$(this).val() != \$(this).data('cblastvalsent') ) ) {
\t\tvar inputid = \$(this).attr('id');
\t\tif ( ! \$('#'+inputid+'__Response').size() ) {
\t\t\tvar respField = '<div class=\\"cb_result_container\\"><div id=\\"' + inputid + '__Response\\">&nbsp;</div></div>';
\t\t\t\$(this).parent().each( function() {
\t\t\t\tif (this.tagName.toLowerCase() == 'td') {
\t\t\t\t\t\$(this).append(respField);
\t\t\t\t} else {
\t\t\t\t\t\$(this).after(respField);
\t\t\t\t}
\t\t\t\t\$(inputid+'__Response').hide();
\t\t\t} );
\t\t}
\t\tif (  \$('#'+inputid+'__Response').length > 0 ) {
\t\t\t\$('#'+inputid+'__Response').html('<img alt=\\"\\" src=\\"{$live_site}/components/com_comprofiler/images/wait.gif\\" /> {$checking}').fadeIn('fast');
\t\t\tvar cbInputField = this;
\t\t\tvar lastVal = \$(this).val();
\t\t\t\$(this).data('cblastvalsent', lastVal );
\t\t\t\$.ajax( {\ttype: 'POST',
\t\t\t\t\t\turl:  '{$ajaxUrl}&field='+encodeURIComponent(inputid),
\t\t\t\t\t\tdata: 'value=' + encodeURIComponent( lastVal ) + '&{$cbSpoofField}=' + encodeURIComponent('{$cbSpoofString}') + '&{$regAntiSpamFieldName}=' + encodeURIComponent('{$regAntiSpZ}'),
\t\t\t\t\t\tsuccess: function(response) {
\t\t\t\t\t\t\tvar respField = \$('#'+\$(cbInputField).attr('id')+'__Response');
\t\t\t\t\t\t\trespField.fadeOut('fast', function() {
\t\t\t\t\t\t\t\trespField.html(response).fadeIn('fast');
\t\t\t\t\t\t\t} );
\t\t\t\t\t\t\t\$(cbInputField).data( 'cblastvalchecked', lastVal );
\t\t\t\t\t\t},
\t\t\t\t\t\tdataType: 'html'
\t\t\t});
\t\t}
\t}
};
\$.fn.cb_field_ajaxClear = function() {
\tvar respField = \$('#'+\$(this).attr('id')+'__Response');
\tif ( respField.html() != '&nbsp;' ) {
\t\tif ( \$(this).val() != \$(this).data( 'cblastvalchecked' ) ) {
\t\t\trespField.fadeOut('medium' );
\t\t} else {
\t\t\trespField.fadeIn('medium' );
\t\t}
\t}
};
EOT
);
                $_CB_fieldajax_outputed = true;
            }
        }
        if ($validateParams !== null && defined('_CB_VALIDATE_NEW')) {
            $validateParams[] = 'remotejhtml:true';
            return $this->getMetaClass($field, $validateParams);
        } else {
            $_CB_framework->outputCbJQuery("\$('#" . $field->name . "').data( 'cblastvalsent', \$('#" . $field->name . "').val() ).blur( \$.fn.cb_field_ajaxCheck ).keyup( \$.fn.cb_field_ajaxClear );");
            return null;
        }
    }
Exemplo n.º 6
0
 /**
  * output points field html display
  *
  * @param  FieldTable  $field
  * @param  UserTable   $user
  * @param  string      $reason
  * @param  boolean     $ajax
  * @return string
  */
 private function getPointsHTML(&$field, &$user, $reason, $ajax = false)
 {
     global $_CB_framework;
     static $JS_loaded = 0;
     $userId = (int) $user->get('id');
     $fieldName = $field->get('name');
     $value = (int) $user->get($fieldName);
     $readOnly = $this->_isReadOnly($field, $user, $reason);
     $maxPoints = (int) $field->params->get('integer_maximum', '1000000');
     $pointsLayout = $field->params->get('points_layout', '');
     $userlistIncrement = (int) $field->params->get('points_list', 0);
     $userlistAccess = false;
     if ($reason == 'list') {
         $fieldName = $fieldName . $userId;
         if ($userlistIncrement) {
             $userlistAccess = true;
         }
     }
     $canIncrement = !$readOnly && $this->getIncrementAccess($field, $user) && ($reason == 'list' && $userlistAccess || $reason != 'list');
     if ($canIncrement) {
         $plusCSS = $field->params->get('points_plus_class', '');
         $minusCSS = $field->params->get('points_minus_class', '');
         $plusIcon = '<span class="' . ($plusCSS ? htmlspecialchars($plusCSS) : 'fa fa-plus-circle fa-lg') . '"></span>';
         $minusIcon = '<span class="' . ($minusCSS ? htmlspecialchars($minusCSS) : 'fa fa-minus-circle fa-lg') . '"></span>';
         $replace = array('[plus]' => $value < $maxPoints ? '<span class="cbPointsFieldIncrement cbPointsFieldIncrementPlus" data-value="plus" data-field="' . $field->get('name') . '" data-target="' . $userId . '">' . $plusIcon . '</span>' : null, '[minus]' => $value > 0 ? '<span class="cbPointsFieldIncrement cbPointsFieldIncrementMinus" data-value="minus" data-field="' . $field->get('name') . '" data-target="' . $userId . '">' . $minusIcon . '</span>' : null, '[value]' => '<span class="cbPointsFieldValue">' . $value . '</span>');
         if ($pointsLayout) {
             $pointsLayout = CBTxt::Th($pointsLayout, null, $replace);
         } else {
             $pointsLayout = CBTxt::Th('POINTS_FIELD_LAYOUT_VALUE_PLUS_MINUS', '[value] [plus] [minus]', $replace);
         }
         if ($ajax) {
             $return = $pointsLayout;
         } else {
             $return = '<span id="' . $fieldName . 'Container" class="cbPointsField' . ($userlistAccess ? ' cbClicksInside' : null) . '">' . $pointsLayout . '</span>';
             if (!$JS_loaded++) {
                 cbGetRegAntiSpamInputTag();
                 $cbGetRegAntiSpams = cbGetRegAntiSpams();
                 $js = "\$( '.cbPointsField' ).on( 'click', '.cbPointsFieldIncrement', function ( e ) {" . "var points = \$( this ).parents( '.cbPointsField' );" . "var increment = \$( this ).data( 'value' );" . "var field = \$( this ).data( 'field' );" . "var target = \$( this ).data( 'target' );" . "\$.ajax({" . "type: 'POST'," . "url: '" . addslashes(cbSef('index.php?option=com_comprofiler&view=fieldclass&function=savevalue&reason=' . urlencode($reason), false, 'raw')) . "'," . "data: {" . "field: field," . "user: target," . "value: increment," . cbSpoofField() . ": '" . addslashes(cbSpoofString(null, 'fieldclass')) . "'," . cbGetRegAntiSpamFieldName() . ": '" . addslashes($cbGetRegAntiSpams[0]) . "'" . "}" . "}).done( function( data, textStatus, jqXHR ) {" . "points.html( data );" . "});" . "});";
                 $_CB_framework->outputCbJQuery($js);
             }
         }
     } else {
         $return = parent::getField($field, $user, 'html', $reason, 0);
     }
     return $return;
 }
	/**
	 * Checks if an email address has been supplied by the provider or if email form needs to render
	 *
	 * @param UserTable           $user
	 * @param Hybrid_User_Profile $profile
	 * @return bool
	 */
	private function email( &$user, $profile )
	{
		global $_CB_framework;

		$email						=	$this->input( 'email', null, GetterInterface::STRING );
		$emailVerify				=	$this->input( 'email__verify', null, GetterInterface::STRING );

		if ( $email ) {
			if ( ! cbIsValidEmail( $email ) ) {
				$_CB_framework->enqueueMessage( sprintf( CBTxt::T( 'UE_EMAIL_NOVALID', 'This is not a valid email address.' ), htmlspecialchars( $email ) ), 'error' );

				$email				=	null;
			} else {
				$field				=	new FieldTable();

				$field->load( array( 'name' => 'email' ) );

				$field->set( 'params', new Registry( $field->get( 'params' ) ) );

				if ( $field->params->get( 'fieldVerifyInput', 0 ) && ( $email != $emailVerify ) ) {
					$_CB_framework->enqueueMessage( CBTxt::T( 'Email and verification do not match, please try again.' ), 'error' );

					$email			=	null;
				}
			}
		}

		if ( ! $email ) {
			$email					=	$profile->email;
		}

		if ( ! $email ) {
			$regAntiSpamValues		=	cbGetRegAntiSpams();

			outputCbTemplate();
			outputCbJs();
			cbValidator::loadValidation();

			$cbUser					=	CBuser::getInstance( null );

			$_CB_framework->enqueueMessage( CBTxt::T( 'PROVIDER_SIGN_UP_INCOMPLETE', 'Your [provider] sign up is incomplete. Please complete the following.', array( '[provider]' => $this->_providerName ) ) );

			$return					=	'<form action="' . $_CB_framework->pluginClassUrl( $this->element, false, array( 'provider' => $this->_provider, 'action' => 'authenticate', 'return' => base64_encode( $this->_returnUrl ) ) ) . '" method="post" enctype="multipart/form-data" name="adminForm" id="cbcheckedadminForm" class="cb_form form-auto cbValidation">'
									.		'<div class="cbRegistrationTitle page-header">'
									.			'<h3>' . CBTxt::T( 'Sign up incomplete' ) . '</h3>'
									.		'</div>'
									.		$cbUser->getField( 'email', null, 'htmledit', 'div', 'register', 0, true, array( 'required' => 1, 'edit' => 1, 'registration' => 1 ) )
									.		'<div class="form-group cb_form_line clearfix">'
									.			'<div class="col-sm-offset-3 col-sm-9">'
									.				'<input type="submit" value="Sign up" class="btn btn-primary cbRegistrationSubmit" data-submit-text="Loading...">'
									.			'</div>'
									.		'</div>'
									.		cbGetSpoofInputTag( 'plugin' )
									.		cbGetRegAntiSpamInputTag( $regAntiSpamValues )
									.	'</form>';

			echo $return;

			return false;
		}

		$user->set( 'email', $email );

		return true;
	}
Exemplo n.º 8
0
 /**
  * Sends legacy mass mailer
  *
  * @deprecated 2.0
  *
  * @param  UserTable[]  $rows
  * @param  string       $emailSubject
  * @param  string       $emailBody
  * @param  string       $emailAttach
  * @param  string       $emailFromName
  * @param  string       $emailFromAddr
  * @param  string       $emailReplyName
  * @param  string       $emailReplyAddr
  * @param  int          $emailsPerBatch
  * @param  int          $emailsBatch
  * @param  int          $emailPause
  * @param  bool         $simulationMode
  * @param  array        $pluginRows
  * @return void
  */
 public function startEmailUsers($rows, $emailSubject, $emailBody, $emailAttach, $emailFromName, $emailFromAddr, $emailReplyName, $emailReplyAddr, $emailsPerBatch, $emailsBatch, $emailPause, $simulationMode, $pluginRows)
 {
     global $_CB_framework, $_CB_Backend_Title;
     _CBsecureAboveForm('showUsers');
     outputCbTemplate(2);
     outputCbJs(2);
     $_CB_Backend_Title = array(0 => array('fa fa-envelope-o', CBTxt::T('Community Builder: Sending Mass Mailer')));
     $userIds = array();
     foreach ($rows as $row) {
         $userIds[] = (int) $row->id;
     }
     $cbSpoofField = cbSpoofField();
     $cbSpoofString = cbSpoofString(null, 'cbadmingui');
     $regAntiSpamFieldName = cbGetRegAntiSpamFieldName();
     $regAntiSpamValues = cbGetRegAntiSpams();
     cbGetRegAntiSpamInputTag($regAntiSpamValues);
     $maximumBatches = count($rows) / $emailsPerBatch;
     if ($maximumBatches < 1) {
         $maximumBatches = 1;
     }
     $progressPerBatch = round(100 / $maximumBatches);
     $delayInMilliseconds = $emailPause ? 0 : $emailPause * 1000;
     $js = "var cbbatchemail = function( batch, emailsbatch, emailsperbatch ) {" . "\$.ajax({" . "type: 'POST'," . "url: '" . addslashes($_CB_framework->backendViewUrl('ajaxemailusers', false, array(), 'raw')) . "'," . "dataType: 'json'," . "data: {" . "emailsubject: '" . addslashes($emailSubject) . "'," . "emailbody: '" . addslashes(rawurlencode($emailBody)) . "'," . "emailattach: '" . addslashes($emailAttach) . "'," . "emailfromname: '" . addslashes($emailFromName) . "'," . "emailfromaddr: '" . addslashes($emailFromAddr) . "'," . "emailreplyname: '" . addslashes($emailReplyName) . "'," . "emailreplyaddr: '" . addslashes($emailReplyAddr) . "'," . "emailsperbatch: emailsperbatch," . "emailsbatch: emailsbatch," . "emailpause: '" . addslashes($emailPause) . "'," . "simulationmode: '" . addslashes($simulationMode) . "'," . "cid: " . json_encode($userIds) . "," . $cbSpoofField . ": '" . addslashes($cbSpoofString) . "'," . $regAntiSpamFieldName . ": '" . addslashes($regAntiSpamValues[0]) . "'" . "}," . "success: function( data, textStatus, jqXHR ) {" . "if ( data.result == 1 ) {" . "var progress = ( " . (int) $progressPerBatch . " * batch ) + '%';" . "\$( '#cbProgressIndicatorBar > .progress-bar' ).css({ width: progress });" . "\$( '#cbProgressIndicatorBar > .progress-bar > span' ).html( progress );" . "\$( '#cbProgressIndicator' ).html( data.htmlcontent );" . "setTimeout( cbbatchemail( ( batch + 1 ), ( emailsbatch + emailsperbatch ), emailsperbatch ), " . (int) $delayInMilliseconds . " );" . "} else if ( data.result == 2 ) {" . "\$( '#cbProgressIndicatorBar' ).removeClass( 'progress-striped active' );" . "\$( '#cbProgressIndicatorBar > .progress-bar' ).css({ width: '100%' });" . "\$( '#cbProgressIndicatorBar > .progress-bar' ).addClass( 'progress-bar-success' );" . "\$( '#cbProgressIndicatorBar > .progress-bar > span' ).html( '100%' );" . "\$( '#cbProgressIndicator' ).html( data.htmlcontent );" . "} else {" . "\$( '#cbProgressIndicatorBar' ).removeClass( 'progress-striped active' );" . "\$( '#cbProgressIndicatorBar > .progress-bar' ).css({ width: '100%' });" . "\$( '#cbProgressIndicatorBar > .progress-bar' ).addClass( 'progress-bar-danger' );" . "\$( '#cbProgressIndicatorBar > .progress-bar > span' ).html( '" . addslashes(CBTxt::T('Email failed to send')) . "' );" . "\$( '#cbProgressIndicator' ).html( data.htmlcontent );" . "}" . "}," . "error: function( jqXHR, textStatus, errorThrown ) {" . "\$( '#cbProgressIndicatorBar' ).removeClass( 'progress-striped active' );" . "\$( '#cbProgressIndicatorBar > .progress-bar' ).css({ width: '100%' });" . "\$( '#cbProgressIndicatorBar > .progress-bar' ).addClass( 'progress-bar-danger' );" . "\$( '#cbProgressIndicatorBar > .progress-bar > span' ).html( '" . addslashes(CBTxt::T('Email failed to send')) . "' );" . "\$( '#cbProgressIndicator' ).html( errorThrown );" . "}" . "});" . "};" . "cbbatchemail( 1, " . (int) $emailsBatch . ", " . (int) $emailsPerBatch . " );";
     $_CB_framework->outputCbJQuery($js);
     $return = '<form action="' . $_CB_framework->backendUrl('index.php') . '" method="post" id="cbmailbatchform" name="adminForm" class="cb_form form-auto cbEmailUsersBatchForm">';
     if ($simulationMode) {
         $return .= '<div class="form-group cb_form_line clearfix">' . '<label class="control-label col-sm-3">' . CBTxt::T('MASS_MAILER_SIMULATION_MODE_LABEL', 'Simulation Mode') . '</label>' . '<div class="cb_field col-sm-9">' . '<div><input type="checkbox" name="simulationmode" id="simulationmode" checked="checked" disabled="disabled" /> <label for="simulationmode">' . CBTxt::T('Do not send emails, just show me how it works') . '</label></div>' . '</div>' . '</div>';
     }
     $return .= $this->_pluginRows($pluginRows) . '<div class="form-group cb_form_line clearfix">' . '<label class="control-label col-sm-3">' . CBTxt::T('SEND_EMAIL_TO_TOTAL_USERS', 'Send Email to [total] users', array('[total]' => (int) count($rows))) . '</label>' . '<div class="cb_field col-sm-9">' . '<div>' . '<div id="cbProgressIndicatorBar" class="progress progress-striped active">' . '<div class="progress-bar" style="width: 0%;">' . '<span></span>' . '</div>' . '</div>' . '<div id="cbProgressIndicator"></div>' . '</div>' . '</div>' . '</div>' . $this->_pluginRows($pluginRows);
     if (!$simulationMode) {
         $return .= '<input type="hidden" name="simulationmode" value="' . htmlspecialchars($simulationMode) . '" />';
     }
     $return .= '<input type="hidden" name="option" value="com_comprofiler" />' . '<input type="hidden" name="view" value="ajaxemailusers" />' . '<input type="hidden" name="boxchecked" value="0" />';
     foreach ($rows as $row) {
         $return .= '<input type="hidden" name="cid[]" value="' . (int) $row->id . '">';
     }
     $return .= cbGetSpoofInputTag('user') . '</form>';
     echo $return;
 }
    static function registerForm($option, $emailpass, &$user, &$postvars, $regErrorMSG = null, $stillDisplayLoginModule = false)
    {
        global $_CB_framework, $_CB_database, $ueConfig, $_PLUGINS;
        $results = $_PLUGINS->trigger('onBeforeRegisterFormDisplay', array(&$user, $regErrorMSG));
        if ($_PLUGINS->is_errors()) {
            echo "<script type=\"text/javascript\">alert(\"" . $_PLUGINS->getErrorMSG() . "\"); window.history.go(-1); </script>\n";
            exit;
        }
        $cbTemplate = HTML_comprofiler::_cbTemplateLoad();
        outputCbTemplate(1);
        outputCbJs(1);
        initToolTip(1);
        $output = 'htmledit';
        $formatting = isset($ueConfig['use_divs']) && $ueConfig['use_divs'] ? 'divs' : 'tabletrs';
        // gets registration tabs from plugins (including the contacts tab core plugin for username, password, etc:
        $tabs = new cbTabs(0, 1, null, false);
        // do not output unused JS code in registration page (IE7 and Safari bugs on that)
        //$tabcontent							=	$tabs->getEditTabs( $user, $postvars, $output, 'tabletrs', 'register', false );
        $tabcontent = $tabs->getEditTabs($user, $postvars, $output, $formatting, 'register', false);
        // outputs the site terms and conditions link and approval checkbox: Not yet a CB field		//TBD
        if ($ueConfig['reg_enable_toc']) {
            global $_CB_OneTwoRowsStyleToggle;
            $class = 'sectiontableentry' . $_CB_OneTwoRowsStyleToggle;
            $_CB_OneTwoRowsStyleToggle = $_CB_OneTwoRowsStyleToggle == 1 ? 2 : 1;
            if ($formatting == 'divs') {
                $tabcontent .= "\t<div class=\"" . $class . " cb_form_line cbclearboth\" id=\"cbfr_termsc\">\n" . '<div class="cb_field"><div id="cbfv_termsc">';
            } else {
                $tabcontent .= "\t<tr class=\"" . $class . "\" id=\"cbfr_termsc\">\n" . "\t\t<td>&nbsp;</td>\n<td class='fieldCell'>";
            }
            $tabcontent .= "<div class=\"cbSnglCtrlLbl\"><input type='checkbox' name='acceptedterms' id='acceptedterms' class='required' value='1' mosReq='0' mosLabel='" . htmlspecialchars(_UE_TOC) . "' /> <label for='acceptedterms'>" . sprintf(_UE_TOC_LINK, "<a href='" . cbSef(htmlspecialchars($ueConfig['reg_toc_url'])) . "' target='_BLANK'> ", "</a>") . '</label>' . getFieldIcons($_CB_framework->getUi(), 1, null, null, null) . "</div>";
            if ($formatting == 'divs') {
                $tabcontent .= "</div></div></div>\n";
            } else {
                $tabcontent .= "</td>\n" . "\t</tr>\n";
            }
        }
        $_CB_framework->setPageTitle(_UE_REGISTRATION);
        $_CB_framework->appendPathWay(_UE_REGISTRATION);
        // starts outputing:
        // $cbSpoofField					=	cbSpoofField();
        $cbSpoofString = cbSpoofString(null, 'registerForm');
        // $regAntiSpamFieldName			=	cbGetRegAntiSpamFieldName();
        $regAntiSpamValues = cbGetRegAntiSpams();
        // <script type="text/javascript" src="includes/js/mambojavascript.js"></script>
        ob_start();
        if (defined('_CB_VALIDATE_NEW')) {
            cbimport('cb.validator');
            cbValidator::renderGenericJs();
            $cbjavascript = ob_get_contents();
            ob_end_clean();
            $_CB_framework->outputCbJQuery($cbjavascript, array('metadata', 'validate'));
        } else {
            // old way:
            ?>
var cbDefaultFieldBackground;
function cbFrmSubmitButton() {
	var me = this.elements;
<?php 
            $version = checkJversion();
            if ($version == 1) {
                // var r = new RegExp("^[a-zA-Z](([\.\-a-zA-Z0-9@])?[a-zA-Z0-9]*)*$", "i");
                ?>
	var r = new RegExp("[\<|\>|\"|\'|\%|\;|\(|\)|\&]", "i");
<?php 
            } elseif ($version == -1) {
                ?>
	var r = new RegExp("[^A-Za-z0-9]", "i");
<?php 
            } else {
                ?>
	var r = new RegExp("[\<|\>|\"|\'|\%|\;|\(|\)|\&|\+|\-]", "i");
<?php 
            }
            ?>
	var errorMSG = '';
	var iserror=0;
	if (cbDefaultFieldBackground === undefined && typeof(me['username'])!='undefined') cbDefaultFieldBackground = ((me['username'].style.getPropertyValue) ? me['username'].style.getPropertyValue("backgroundColor") : me['username'].style.backgroundColor);
<?php 
            echo $tabs->fieldJS;
            ?>
	if (typeof(me['username'])!='undefined' && me['username'].value == "") {
		errorMSG += "<?php 
            echo CBTxt::html_entity_decode(_REGWARN_UNAME);
            ?>
\n";
		me['username'].style.backgroundColor = "red";
		iserror=1;
	} else if (typeof(me['username'])!='undefined' && ( r.exec(me['username'].value) || (me['username'].value.length < 3))) {
		errorMSG += "<?php 
            printf(CBTxt::html_entity_decode(_VALID_AZ09), CBTxt::html_entity_decode(_PROMPT_UNAME), 2);
            ?>
\n";
		me['username'].style.backgroundColor = "red";
		iserror=1;
	} else if (typeof(me['username'])!='undefined' && me['username'].style.backgroundColor.slice(0,3)=="red") { me['username'].style.backgroundColor = cbDefaultFieldBackground;
<?php 
            if ($emailpass != "1") {
                ?>
	}
	if (typeof(me['password'])!='undefined' && me['password'].value.length < 6) {
		errorMSG += "<?php 
                printf(CBTxt::html_entity_decode(_VALID_AZ09), CBTxt::html_entity_decode(_REGISTER_PASS), 6);
                ?>
\n";
		me['password'].style.backgroundColor = "red";
		iserror=1;
	} else if (typeof(me['password'])!='undefined' && (me['password'].value != "") && (me['password'].value != me['password__verify'].value)){
		errorMSG += "<?php 
                echo CBTxt::html_entity_decode(_REGWARN_VPASS2);
                ?>
\n";
		me['password'].style.backgroundColor = "red"; me['password__verify'].style.backgroundColor = "red";
		iserror=1;
	} else if (typeof(me['password'])!='undefined') {
		if (me['password'].style.backgroundColor.slice(0,3)=="red") me['password'].style.backgroundColor = cbDefaultFieldBackground;
		if (me['password__verify'].style.backgroundColor.slice(0,3)=="red") me['password__verify'].style.backgroundColor = cbDefaultFieldBackground;
<?php 
            }
            ?>
	}
<?php 
            if ($ueConfig['reg_enable_toc']) {
                ?>
	if(!me['acceptedterms'].checked) {
		errorMSG += "<?php 
                echo CBTxt::html_entity_decode(_UE_TOC_REQUIRED);
                ?>
\n";
		iserror=1;
	}
<?php 
            }
            ?>
	// loop through all input elements in form
	var fieldErrorMessages = new Array;
	for (var i=0; i < me.length; i++) {
		// check if element is mandatory; here mosReq="1"
		var myenabled = (typeof(me[i].getAttribute('mosNoReq')) == 'undefined' ) || (me[i].getAttribute('mosNoReq') != 1);
		var mytyp = me[i].getAttribute('type');
		var myact = myenabled && mytyp != 'reset' && mytyp != 'button' && mytyp != 'submit' && mytyp != 'image';
		if ( myact && (typeof(me[i].getAttribute('mosReq')) != "undefined") && ( me[i].getAttribute('mosReq') == 1) ) {
			if (me[i].type == 'radio' || me[i].type == 'checkbox') {
				var rOptions = me[me[i].getAttribute('name')];
				var rChecked = 0;
				if(rOptions.length > 1) {
					for (var r=0; r < rOptions.length; r++) {
						if ( (typeof(rOptions[r].getAttribute('mosReq')) != "undefined") && ( rOptions[r].getAttribute('mosReq') == 1) ) {
							if (rOptions[r].checked) {
								rChecked=1;
							}
						}
					}
				} else {
					if (me[i].checked) {
						rChecked=1;
					}
				}
				if (rChecked==0) {
					for (var k=0; k < me.length; k++) {
						if (me[i].getAttribute('name') == me[k].getAttribute('name')) {
							if (me[k].checked) {
								rChecked=1;
								break;
							}
						}
					}
				}
				if (rChecked==0) {
					var alreadyFlagged = false;
					for (var j = 0, n = fieldErrorMessages.length; j < n; j++) {
						if (fieldErrorMessages[j] == me[i].getAttribute('name')) {
							alreadyFlagged = true;
							break
						}
					}
					if ( ! alreadyFlagged ) {
						fieldErrorMessages.push(me[i].getAttribute('name'));
						// add up all error messages
						errorMSG += me[i].getAttribute('mosLabel') + ' : <?php 
            echo CBTxt::html_entity_decode(_UE_REQUIRED_ERROR);
            ?>
\n';
						// notify user by changing background color, in this case to red
						me[i].style.backgroundColor = "red";
						iserror=1;
					}
				} else if (me[i].style.backgroundColor.slice(0,3)=="red") me[i].style.backgroundColor = cbDefaultFieldBackground;
			}
			if (me[i].value == '') {
				// add up all error messages
				errorMSG += me[i].getAttribute('mosLabel') + ' : <?php 
            echo CBTxt::html_entity_decode(_UE_REQUIRED_ERROR);
            ?>
\n';
				// notify user by changing background color, in this case to red
				me[i].style.backgroundColor = "red";
				iserror=1;
			} else if (me[i].style.backgroundColor.slice(0,3)=="red") me[i].style.backgroundColor = cbDefaultFieldBackground;
		}
	}
	if(iserror==1) {
		alert(errorMSG);
		return false;
	} else {
		return true;
	}
}
$('#cbcheckedadminForm').submit( cbFrmSubmitButton );
<?php 
            $cbjavascript = ob_get_contents();
            ob_end_clean();
            $_CB_framework->outputCbJQuery($cbjavascript);
            // end of old
        }
        if ($regErrorMSG) {
            echo "<div class='error'>" . $regErrorMSG . "</div>\n";
        }
        // output results of plugins event "onBeforeRegisterFormDisplay":
        if (is_array($results)) {
            echo implode('', $results);
        }
        $introMessage = isset($ueConfig['reg_intro_msg']) ? stripslashes(getLangDefinition($ueConfig['reg_intro_msg'])) : null;
        $conclusionMessage = isset($ueConfig['reg_conclusion_msg']) ? stripslashes(getLangDefinition($ueConfig['reg_conclusion_msg'])) : null;
        $https_post = checkCBPostIsHTTPS(true);
        $urlRegister = cbSef("index.php?option=" . $option);
        if ($https_post) {
            if (substr($urlRegister, 0, 5) != 'http:' && substr($urlRegister, 0, 6) != 'https:') {
                $urlRegister = $_CB_framework->getCfg('live_site') . '/' . $urlRegister;
            }
            $urlRegister = str_replace('http://', 'https://', $urlRegister);
        }
        $regFormTag = '<form action="' . $urlRegister . '" method="post" id="cbcheckedadminForm" name="adminForm" class="cb_form" 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";
        $topIcons = null;
        $bottomIcons = null;
        if (!isset($ueConfig['reg_show_icons_explain']) || $ueConfig['reg_show_icons_explain'] > 0) {
            $icons = getFieldIcons(1, true, true, '', '', true);
            if (in_array($ueConfig['reg_show_icons_explain'], array(1, 3))) {
                $topIcons = $icons;
            }
            if (in_array($ueConfig['reg_show_icons_explain'], array(2, 3))) {
                $bottomIcons = $icons;
            }
        }
        $moduleContent = null;
        if (isset($ueConfig['reg_show_login_on_page']) && $ueConfig['reg_show_login_on_page'] == 1 && ($stillDisplayLoginModule || !$regErrorMSG)) {
            $params = null;
            $login_module_file = $_CB_framework->getCfg('absolute_path') . '/modules/' . (checkJversion() > 0 ? 'mod_cblogin/' : '') . 'mod_cblogin.php';
            if (file_exists($login_module_file)) {
                define('_UE_LOGIN_FROM', 'regform');
                $_CB_database->setQuery("SELECT params from #__modules WHERE module = 'mod_cblogin' ORDER BY ordering", 0, 1);
                $raw_params = $_CB_database->loadResult();
                $params = new cbParamsBase($raw_params);
                // needed for login module
                // $params of login module is needed for the include( $login_module_file ) below !!
                ob_start();
                include $login_module_file;
                $moduleContent = ob_get_contents();
                ob_end_clean();
            }
        }
        // renders using template viewer:
        echo HTML_comprofiler::_cbTemplateRender($cbTemplate, $user, 'RegisterForm', 'drawProfile', array(&$user, $tabcontent, $regFormTag, $introMessage, _LOGIN_REGISTER_TITLE, _REGISTER_TITLE, _UE_REGISTER, $moduleContent, $topIcons, $bottomIcons, $conclusionMessage, $formatting), $output);
        // finally small javascript to focus on first field on registration form if there is no introduction text and it's a text field:
        if (!(isset($ueConfig['reg_intro_msg']) && $ueConfig['reg_intro_msg'] || isset($ueConfig['reg_show_login_on_page']) && $ueConfig['reg_show_login_on_page'] == 1 || $regErrorMSG)) {
            $_CB_framework->outputCbJQuery('$("#cbcheckedadminForm input[type!=\'hidden\']:first").filter("[type=\'text\'],textarea,[type=\'password\']").focus();');
        }
    }
 static function lostPassForm($option)
 {
     global $_CB_framework, $ueConfig, $_PLUGINS;
     $results = $_PLUGINS->trigger('onLostPassForm', array(1));
     if ($_PLUGINS->is_errors()) {
         echo "<script type=\"text/javascript\">alert(\"" . $_PLUGINS->getErrorMSG() . "\"); window.history.go(-1); </script>\n";
         exit;
     }
     $regAntiSpamValues = cbGetRegAntiSpams();
     $usernameExists = isset($ueConfig['login_type']) && $ueConfig['login_type'] != 2;
     $pageTitle = $usernameExists ? CBTxt::Th('UE_LOST_USERNAME_OR_PASSWORD', 'Lost your Username or your Password ?') : CBTxt::T('UE_LOST_YOUR_PASSWORD', 'Lost your Password ?');
     outputCbTemplate(1);
     cbValidator::loadValidation();
     initToolTip(1);
     $js = "\$( '#checkusername,#checkemail' ).keyup( function() {" . "\$( this ).next( '.cb_result_container' ).remove();" . "if ( \$.trim( \$( '#checkusername' ).val() ) != '' ) {" . "if ( \$.trim( \$( '#checkemail' ).val() ) == '' ) {" . "\$( '.cbLostPassSend' ).prop( 'disabled', true );" . "} else {" . "\$( '.cbLostPassSend' ).prop( 'disabled', false );" . "}" . "} else {" . "if ( \$.trim( \$( '#checkemail' ).val() ) == '' ) {" . "\$( '.cbLostPassSend' ).prop( 'disabled', true );" . "} else {" . "\$( '.cbLostPassSend' ).prop( 'disabled', false );" . "}" . "}" . "});";
     if ($usernameExists) {
         $js .= "\$( '#reminderUsername,#reminderPassword' ).click( function() {" . "\$( '#checkusername,#checkemail' ).next( '.cb_result_container' ).remove();" . "\$( '#checkusername,#checkemail' ).val( '' );" . "\$( '.cbLostPassSend' ).prop( 'disabled', true );" . "\$( '.cb_forgot_line,.cb_forgot_button' ).show();" . "if ( \$( '#reminderUsername' ).prop( 'checked' ) ) {" . "if ( \$( '#reminderPassword' ).prop( 'checked' ) ) {" . "\$( '.cbLostPassSend' ).val( '" . addslashes(CBTxt::Th('UE_BUTTON_SEND_USERNAME_PASS', 'Send Username/Password')) . "' );" . "\$( '#lostusernamedesc,#lostpassdesc' ).hide();" . "\$( '#lostusernamepassdesc' ).show();" . "} else {" . "\$( '.cbLostPassSend' ).val( '" . addslashes(CBTxt::Th('UE_BUTTON_SEND_USERNAME', 'Send Username')) . "' );" . "\$( '#lostusernamepassdesc,#lostpassdesc' ).hide();" . "\$( '#lostusernamedesc' ).show();" . "}" . "\$( '#lostpassusername' ).hide();" . "\$( '#lostpassemail' ).show();" . "} else {" . "if ( \$( '#reminderPassword' ).prop( 'checked' ) ) {" . "\$( '.cbLostPassSend' ).val( '" . addslashes(CBTxt::Th('UE_BUTTON_SEND_PASS', 'Send Password')) . "' );" . "\$( '#lostusernamepassdesc,#lostusernamedesc' ).hide();" . "\$( '#lostpassusername,#lostpassemail,#lostpassdesc' ).show();" . "} else {" . "\$( '.cb_forgot_line,.cb_forgot_button,#lostusernamepassdesc,#lostusernamedesc,#lostpassdesc' ).hide();" . "}" . "}" . "});" . "\$( '.cb_forgot_line,.cb_forgot_button,#lostusernamepassdesc,#lostusernamedesc,#lostpassdesc' ).hide();";
     }
     $_CB_framework->outputCbJQuery($js);
     $pageClass = $_CB_framework->getMenuPageClass();
     $return = '<div class="cbLostPassForm cb_template cb_template_' . selectTemplate('dir') . ($pageClass ? ' ' . htmlspecialchars($pageClass) : null) . '">' . ($pageTitle ? '<div class="page-header"><h3>' . $pageTitle . '</h3></div>' : null) . '<form action="' . $_CB_framework->viewUrl('sendNewPass', true, null, 'html', checkCBPostIsHTTPS(true) ? 1 : 0) . '" method="post" id="adminForm" name="adminForm" class="cb_form form-auto cbValidation">';
     if ($usernameExists) {
         $return .= '<div class="form-group cb_form_line clearfix" id="lostpassreminder">' . '<label class="col-sm-3 control-label">' . CBTxt::Th('UE_REMINDER_NEEDED_FOR', 'Reminder needed for') . '</label>' . '<div class="cb_field col-sm-9">' . '<span class="cbSingleCntrl">' . '<label for="reminderUsername" class="checkbox-inline">' . '<input type="checkbox" id="reminderUsername" name="typeofloose[]" value="username" /> ' . CBTxt::Th('UE_LOST__USERNAME', 'Lost Username') . '</label>' . '</span>' . '<span class="cbSingleCntrl">' . '<label for="reminderPassword" class="checkbox-inline">' . '<input type="checkbox" id="reminderPassword" name="typeofloose[]" value="password" /> ' . CBTxt::Th('UE_LOST__PASSWORD', 'Lost Password') . '</label>' . '</span>' . '</div>' . '</div>' . '<div class="form-group cb_form_line clearfix" id="lostusernamedesc">' . '<div class="cb_field col-sm-offset-3 col-sm-9">' . CBTxt::Th('UE_LOST_USERNAME_ONLY_DESC', 'If you <strong>lost your username</strong>, please enter your E-mail Address, then click the Send Username button, and your username will be sent to your email address.') . '</div>' . '</div>' . '<div class="form-group cb_form_line clearfix" id="lostusernamepassdesc">' . '<div class="cb_field col-sm-offset-3 col-sm-9">' . CBTxt::Th('UE_LOST_USERNAME_PASSWORD_DESC', 'If you <strong>forgot both your username and your password</strong>, please recover the username first, then the password. To recover your username, please enter your E-mail Address, leaving Username field empty, then click the Send Username button, and your username will be sent to your email address. From there you can use this same form to recover your password.') . '</div>' . '</div>';
     }
     $return .= '<div class="form-group cb_form_line clearfix" id="lostpassdesc">' . '<div class="cb_field col-sm-offset-3 col-sm-9">';
     if ($usernameExists) {
         $return .= CBTxt::Th('UE_LOST_PASSWORD_DESC', 'If you <strong>lost your password</strong> but know your username, please enter your Username and your E-mail Address, press the Send Password button, and you will receive a new password shortly. Use this new password to access the site.');
     } else {
         $return .= CBTxt::Th('UE_LOST_PASSWORD_EMAIL_ONLY_DESC', 'If you <strong>lost your password</strong>, please enter your E-mail Address, then click the Send Password button, and you will receive a new password shortly. Use this new password to access the site.');
     }
     $return .= '</div>' . '</div>';
     if ($usernameExists) {
         $usernameValidation = cbValidator::getRuleHtmlAttributes('cbfield', array('user' => 0, 'field' => 'username', 'reason' => 'register', 'function' => 'testexists'));
         $return .= '<div class="cb_forgot_line form-group cb_form_line clearfix" id="lostpassusername">' . '<label for="checkusername" class="col-sm-3 control-label">' . CBTxt::Th('PROMPT_UNAME', 'Username:') . '</label>' . '<div class="cb_field col-sm-9">' . '<input type="text" name="checkusername" id="checkusername" class="form-control" size="30" maxlength="255"' . $usernameValidation . ' />' . '</div>' . '</div>';
     }
     $emailValidation = cbValidator::getRuleHtmlAttributes('cbfield', array('user' => 0, 'field' => 'email', 'reason' => 'register', 'function' => 'testexists'));
     $return .= '<div class="cb_forgot_line form-group cb_form_line clearfix" id="lostpassemail">' . '<label for="checkemail" class="col-sm-3 control-label">' . CBTxt::Th('PROMPT_EMAIL', 'E-mail Address:') . '</label>' . '<div class="cb_field col-sm-9">' . '<input type="text" name="checkemail" id="checkemail" class="form-control" size="30" maxlength="255"' . $emailValidation . ' />' . '</div>' . '</div>';
     if (is_array($results)) {
         foreach ($results as $result) {
             if ($result) {
                 $return .= '<div class="cb_forgot_line form-group cb_form_line clearfix">' . '<label' . (isset($result[2]) ? ' for="' . htmlspecialchars($result[2]) . '"' : null) . ' class="col-sm-3 control-label">' . (isset($result[0]) ? $result[0] : null) . '</label>' . '<div class="cb_field col-sm-9">' . (isset($result[1]) ? $result[1] : null) . '</div>' . '</div>';
             }
         }
     }
     $return .= '<div class="cb_forgot_button form-group cb_form_line clearfix">' . '<div class="col-sm-offset-3 col-sm-9">' . '<input type="submit" class="btn btn-primary cbLostPassSend" value="' . htmlspecialchars($usernameExists ? CBTxt::Th('UE_BUTTON_SEND_USERNAME_PASS', 'Send Username/Password') : CBTxt::Th('UE_BUTTON_SEND_PASS', 'Send Password')) . '" disabled="disabled"' . cbValidator::getSubmitBtnHtmlAttributes() . ' />' . '</div>' . '</div>';
     if (!$usernameExists) {
         $return .= '<input type="hidden" name="typeofloose[]" value="password" />';
     }
     $return .= cbGetSpoofInputTag('lostPassForm') . cbGetRegAntiSpamInputTag($regAntiSpamValues) . '</form>' . '</div>' . cbPoweredBy();
     echo $return;
     $_CB_framework->setMenuMeta();
 }