/** * 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 ); }
/** * 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 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() != ' ' ) { \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\\"> </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\\"> </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() != ' ' ) { \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; } }
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,"&").replace(/</g,"<").replace(/>/g,">") ).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 ); }
/** * 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' ); } }
/** * 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; }
/** * 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 lostPassForm($option) { global $_CB_framework, $ueConfig, $_PLUGINS; $_PLUGINS->loadPluginGroup('user'); $results = $_PLUGINS->trigger('onLostPassForm', array(1)); //$ui=1 if ($_PLUGINS->is_errors()) { echo "<script type=\"text/javascript\">alert(\"" . $_PLUGINS->getErrorMSG() . "\"); window.history.go(-1); </script>\n"; exit; } $cbSpoofField = cbSpoofField(); $cbSpoofString = cbSpoofString(null, 'registerForm'); $regAntiSpamFieldName = cbGetRegAntiSpamFieldName(); $regAntiSpamValues = cbGetRegAntiSpams(); $checkUsername = isset($ueConfig['reg_username_checker']) && $ueConfig['reg_username_checker']; $checkEmail = isset($ueConfig['reg_email_checker']) && $ueConfig['reg_email_checker'] > 1; $usernameExists = isset($ueConfig['login_type']) && $ueConfig['login_type'] != 2; $https_post = checkCBPostIsHTTPS(true); $urlLostPass = cbSef('index.php'); if ($https_post) { if (substr($urlLostPass, 0, 5) != 'http:' && substr($urlLostPass, 0, 6) != 'https:') { $urlLostPass = $_CB_framework->getCfg('live_site') . '/' . $urlLostPass; } $urlLostPass = str_replace('http://', 'https://', $urlLostPass); } outputCbTemplate(1); ob_start(); /* $('#adminForm').validate( { errorClass: 'cb_result_warning', rules: { checkusername: { required: false, minlength: 3 //, // remote: "users.php" }, /* password: { required: true, minlength: 5 }, password_confirm: { required: true, minlength: 5, equalTo: "#password" }, * checkemail: { required: true, email: true, // remote: "emails.php" }, }, messages: { checkusername: { required: "Enter a username", minlength: jQuery.format("Enter at least {0} characters"), remote: jQuery.format("{0} is already in use") }, /* password: { required: "Provide a password", rangelength: jQuery.format("Enter at least {0} characters") }, password_confirm: { required: "Repeat your password", minlength: jQuery.format("Enter at least {0} characters"), equalTo: "Enter the same password as above" }, * checkemail: { required: "Please enter a valid email address", minlength: "Please enter a valid email address", remote: jQuery.format("{0} is already in use") }, }, errorPlacement: function(error, element) { if ( element.is(":radio") ) error.appendTo( element.parent().next().next() ); else if ( element.is(":checkbox") ) error.appendTo ( element.next() ); else // error.appendTo( element.parent().next() ); error.appendTo( element.parent().next().children()[0] ); } } ); */ /* $('#adminForm').ajaxForm( { url: '< ?php echo $_CB_framework->getCfg( 'live_site' ); ? >/index2.php?no_html=1&output=raw', target: '#cb_lost_username_passwd_content', beforeSubmit: function(formData, jqForm, options) { $('#cb_line_lostbutton').fadeOut('fast', function() { $('#cb_line_lostbutton').html('<img src=\"< ?php echo $_CB_framework->getCfg( 'live_site' ); ?>/components/com_comprofiler/images/wait.gif\" /> <?php echo _UE_CHECKING; ? >').fadeIn('fast'); } ); return true; }, success: function(responseText, statusText) { alert('Got reply !status: ' + statusText + '\n\nresponseText: \n' + responseText + '\n\nThe output div should have already been updated with the responseText.'); } } ); */ // checkboxes onchange trigger only on blur: ?> $.fn.cb_uncheck = function() { return this.each( function() { this.checked = false; }); }; $('#boxLostUsername,#boxLostPassword').click( function() { if ( $('#boxLostUsername').get(0).checked ) { $('#cb_step1_form').slideDown('medium'); $('#cb_line_checkusername').slideUp('medium'); if ( $('#boxLostPassword').get(0).checked ) { $('#cbsendnewuspass').val('<?php echo addslashes(_UE_BUTTON_SEND_USERNAME_PASS); ?> '); $('#cb_lost_username_password').slideDown('medium'); $('#cb_lost_username,#cb_lost_password').slideUp('medium'); } else { $('#cbsendnewuspass').val('<?php echo addslashes(_UE_BUTTON_SEND_USERNAME); ?> '); $('#cb_lost_username').slideDown('medium'); $('#cb_lost_password,#cb_lost_username_password').slideUp('medium'); } } else { if ( $('#boxLostPassword').get(0).checked ) { $('#cbsendnewuspass').val('<?php echo addslashes(_UE_BUTTON_SEND_PASS); ?> '); $('#cb_step1_form,#cb_lost_password,#cb_line_checkusername').slideDown('medium'); $('#cb_lost_username,#cb_lost_username_password').slideUp('medium'); } else { $('#cb_lost_username,#cb_lost_password,#cb_lost_username_password,#cb_step1_form').slideUp('medium'); } } return true; } ); <?php if ($usernameExists) { ?> $('#cb_lost_username,#cb_lost_password,#cb_lost_username_password,#cb_step1_form,#cb_line_checkusername').hide(); <?php } ?> $('#boxLostUsername,#boxLostPassword').cb_uncheck(); $('#checkusername,#checkemail').val(''); $('#cbsendnewuspass').attr('disabled',true); $('#cb_lost_username').html('<?php echo addslashes(defined('_UE_LOST_USERNAME_ONLY_DESC') ? _UE_LOST_USERNAME_ONLY_DESC : _UE_LOST_USERNAME_DESC); /* if we have ajax, no need for saying to leave username blank */ ?> '); $('#checkusername,#checkemail').keyup( function() { var respField = $('#'+$(this).attr('id')+'Response'); if ( respField.html() != ' ' ) { respField.fadeOut('medium', function() { respField.html(' '); } ); } if ( $.trim( $('#checkusername').val() ) == '' ) { if ( $.trim( $('#checkemail').val() ) == '' ) { $('#cbsendnewuspass').attr('disabled',true); } else { $('#cbsendnewuspass').attr('disabled',false); } } else { $('#cbsendnewuspass').attr('disabled',false); } return true; } ); <?php if ($checkUsername || $checkEmail) { ?> $('#checkusername,#checkemail').change( function() { if ( ( $(this).val() != '' ) && ( $('#'+$(this).attr('id')+'Response').length ) ) { $('#'+$(this).attr('id')+'Response').html('<img alt="" src=\"<?php echo $_CB_framework->getCfg('live_site'); ?> /components/com_comprofiler/images/wait.gif\" /> <?php echo _UE_CHECKING; ?> ').fadeIn('fast'); var cbInputField = this; $.ajax( { type: 'POST', url: '<?php echo cbSef('index.php?option=com_comprofiler', false, 'raw'); ?> &task=perform'+$(this).attr('id')+'&function=testexists', data: 'value=' + encodeURIComponent( $(this).val() ) + '&<?php echo $cbSpoofField; ?> =' + encodeURIComponent('<?php echo $cbSpoofString; ?> ') + '&<?php echo $regAntiSpamFieldName; ?> =' + encodeURIComponent('<?php echo $regAntiSpamValues[0]; ?> '), success: function(response) { var respField = $('#'+$(cbInputField).attr('id')+'Response'); respField.fadeOut('fast', function() { respField.html(response).fadeIn('fast'); } ); }, dataType: 'html' }); } else { $('#'+$(this).attr('id')+'Response').html(' '); } } ); <?php } $jsContent = ob_get_contents(); ob_end_clean(); $_CB_framework->outputCbJQuery($jsContent); //TODO: Add ability to change password on form. ?> <div class="componentheading"><?php echo $usernameExists ? _UE_LOST_USERNAME_OR_PASSWORD : _UE_LOST_YOUR_PASSWORD; ?> </div> <div class="cbPageOuter" id="cbLostPasswordPage"><div class="cbPageInner"> <div class="contentpaneopen" id="cb_lost_username_passwd_content"> <form action="<?php echo $urlLostPass; ?> " class="cb_form" id="adminForm" name="adminForm" method="post"> <?php if ($usernameExists) { ?> <div class="cb_form_line" id="cb_lost_choice"> <label for="cb_lost_choice"><?php echo _UE_REMINDER_NEEDED_FOR; ?> :</label> <div class="cb_field"> <div><input type="checkbox" id="boxLostUsername" name="typeofloose[]" value="username" /> <label for="boxLostUsername"><?php echo _UE_LOST__USERNAME; ?> </label></div> <div><input type="checkbox" id="boxLostPassword" name="typeofloose[]" value="password" /> <label for="boxLostPassword"><?php echo _UE_LOST__PASSWORD; ?> </label></div> </div> </div> <?php } else { ?> <input type="hidden" name="typeofloose[]" value="password" /> <?php } ?> <div class="cb_form_instructions"> <ul> <?php if ($usernameExists) { ?> <li id="cb_lost_username"><?php echo getLangDefinition('_UE_LOST_USERNAME_DESC'); ?> </li> <li id="cb_lost_password"><?php echo getLangDefinition('_UE_LOST_PASSWORD_DESC'); ?> </li> <li id="cb_lost_username_password"><?php echo getLangDefinition('_UE_LOST_USERNAME_PASSWORD_DESC'); ?> </li> <?php } else { ?> <li id="cb_lost_password"><?php echo getLangDefinition('_UE_LOST_PASSWORD_EMAIL_ONLY_DESC'); ?> </li> <?php } ?> </ul> </div> <div id="cb_step1_form"> <?php if ($usernameExists) { ?> <div class="cb_form_line" id="cb_line_checkusername"> <label for="checkusername"><?php echo _PROMPT_UNAME; ?> </label> <div class="cb_field"> <div><input type="text" name="checkusername" id="checkusername" class="inputbox" size="30" maxlength="255" /></div> <?php if ($checkUsername) { ?> <div class="cb_result_container"><div id="checkusernameResponse"> </div></div> <?php } ?> </div> </div> <?php } ?> <div class="cb_form_line" id="cb_line_checkemail"> <label for="checkemail"><?php echo _PROMPT_EMAIL; ?> </label> <div class="cb_field"> <div><input type="text" name="checkemail" id="checkemail" class="inputbox" size="30" maxlength="255" /></div> <?php if ($checkEmail) { ?> <div class="cb_result_container"><div id="checkemailResponse"> </div></div> <?php } ?> </div> </div> <?php if (is_array($results)) { foreach ($results as $r) { ?> <div class="cb_form_line"> <label<?php if (isset($r[2])) { echo ' for="' . $r[2] . '"'; } ?> ><?php echo $r[0]; ?> </label> <div class="cb_field"><?php echo $r[1]; ?> </div> </div> <?php } } ?> <div class="cb_form_buttons_line" id="cb_line_lostbutton"> <input type="submit" class="button" id="cbsendnewuspass" value="<?php echo $usernameExists ? _UE_BUTTON_SEND_USERNAME_PASS : _UE_BUTTON_SEND_PASS; ?> " /> </div> </div> <input type="hidden" name="option" value="<?php echo $option; ?> " /> <input type="hidden" name="task" value="sendNewPass" /> <?php echo cbGetSpoofInputTag('lostPassForm'); echo "\t\t\t" . cbGetRegAntiSpamInputTag($regAntiSpamValues); ?> </form> </div> </div></div> <div class="cbClr"> </div> <?php }
function _process( $url ) { // Clean url $reg[] = "/<span[^>]*?>/si"; $repl[] = ''; $reg[] = "/<\/span>/si"; $repl[] = ''; $url = preg_replace( $reg, $repl, trim($url) ); $origurl = JUri::root(true).$url; $origurl = preg_replace('/&/', '&', $origurl); if (strpos($url, 'index.php')!== false||$this->ignoresef=="1") { $sef=false; $url = $url.((strpos($url, '?')===false)?'?':'&').'tmpl=component'.(($this->urlprint=='1')?'&print=1':''); // Add origin too to the component so it can redirect to the origin if something goes wrong $url .= '&origin='.base64_encode( JUri::getInstance()->toString() ); } else { $sef=true; $url = $url.((substr($url, -1)!='/')?'/':'').'tmpl,component'.(($this->urlprint=='1')?'/print,1':''); // Add origin too to the component so it can redirect to the origin if something goes wrong $url .= '/origin='.base64_encode( JUri::getInstance()->toString() ); } $url = str_replace('http://', $this->protocol, JUri::root()).$url; // We need to replace the & to & because the & is not recognized $url = preg_replace('/&/', '&', $url); // Close session so the other component can use it if ($this->closesession=="1") { $session =& JFactory::getSession(); $session->close(); } $cache = & JFactory::getCache('plugin_component'); if ($this->caching=="1") $cache->setCaching( 1 ); $response = $cache->call(array ( $this, '_getURL'), $url, $sef); // Start the session again? if ($response!="") { // Clean the returned page of all html tags // get head and remove it // to do move meta tags, scripts and links to header? $reg = "/(<HEAD[^>]*>)(.*?)(<\/HEAD>)(.*)/si"; $count = preg_match_all($reg,$response,$html); if ($count>0) { $head=$html[2][0]; $response= $html[4][0]; } else { $head=''; } if ($this->doctype!="feed"&&$this->doctype!="pdf"&&$this->ignore_allscripts!='1') { // Find stylesheets and javascripts and add them to this document // javascript scripts $reg = '/<script.*src=[\'\"](.*?)[\'\"][^>]*[^<]*(<\/script>)?/i'; $count = preg_match_all($reg,$head,$scripts); if ($count>0) foreach ($scripts[1] as $script) { $this->_addScript($script); } // javascript embedded $reg = '/<script[^>]*>(.*?)<\/script>/si'; $scripts= array(); $count = preg_match_all($reg,$head,$scripts); if ($count>0) foreach ($scripts[1] as $script) { if (trim($script)!='') { // remove special contents type around scripts $script = str_replace('<!--', '', $script); $script = str_replace('-->', '', $script); $this->document->addScriptDeclaration($script); } } } if ($this->doctype!="feed"&&$this->ignore_allstyles!='1') { // stylesheet links $reg = '/<link.*href=[\'\"](.*?)[\'\"][^>]*[^<]*(<\/link>)?/i'; $count = preg_match_all($reg,$head,$styles); if ($count>0) for ($x=0;$x<$count;$x++) { if ((preg_match('/type=[\'"]text\/css[\'"]/i', $styles[0][$x])>0)||(preg_match('/rel=[\'"]stylesheet[\'"]/i', $styles[0][$x])>0)) $this->_addStyleSheet($styles[1][$x]); } // Embedded styles $reg = '/<style[^>]*>(.*?)<\/style>/si'; $styles = array(); $count = preg_match_all($reg,$head,$styles); if ($count>0) foreach ($styles[1] as $style) { if (trim($style)!='') $this->document->addStyleDeclaration($style); } } if ($this->doctype!="feed") { // Add meta tags and description to calling page $reg = '/<meta.*name=[\'\"](keywords|description)[\'\"].*content=[\'\"](.*?)[\'\"][^\/>]*/i'; $count = preg_match_all($reg,$head,$meta); if ($count>0) for ($x=0;$x<$count;$x++) { $old = $this->document->getMetaData ($meta[1][$x]); // Check if not already added? if ($meta[2][$x]!="") if (strpos($old, $meta[2][$x])===false) { if (strlen($old)>0&&strlen($meta[2][$x])>0) if ($meta[1][$x]=='keywords') $meta[2][$x] = ", ".$meta[2][$x]; else $meta[2][$x] = " ".$meta[2][$x]; $this->document->setMetaData ($meta[1][$x], $old.$meta[2][$x]); } } } // get body and remove it // to do attributes of body onload and other move to the real page? $reg = '/(<BODY[^>]*>)(.*)(<\/BODY>)/si'; $count = preg_match_all($reg,$response,$html); if ($count>0) $response=$html[2][0]; $reg = array(); $repl = array(); // clean javascript for feeds and pdf if ($this->doctype=="feed"||$this->doctype=="pdf"||$this->ignore_allscripts=='1') { // Find stylesheets and javascripts and remove them // javascript scripts $reg[] = '/<script.*src=[\'\"](.*?)[\'\"][^>]*[^<]*(<\/script>)?/i'; $repl[] = ''; // javascript embedded $reg[] = '/<script[^>]*>(.*?)<\/script>/si'; $repl[] = ''; } if ($this->doctype=="feed"||$this->ignore_allstyles=='1') { // stylesheet links $reg[] = '/<link.*href=[\'\"](.*?)[\'\"][^>]*[^<]*(<\/link>)?/i'; $repl[] = ''; // Embedded styles $reg[] = '/<style[^>]*>(.*?)<\/style>/si'; $repl[] = ''; } // Replace links if ($this->replprint=='1') { $reg[] = "/&print=1/"; $repl[] = ''; $reg[] = "/&print=1/"; $repl[] = ''; } if ($this->repltmpl=='1') { $reg[] = "/&tmpl=component/"; $repl[] = ''; $reg[] = "/&tmpl=component/"; $repl[] = ''; $reg[] = "/\?tmpl=component&/"; $repl[] = '?'; } $reg[] = "/index2.php/"; $repl[] = 'index.php'; $reg[] = '/\$/'; $repl[] = '\\\$'; $response = preg_replace( $reg, $repl, $response ); // Replace forms with empty action or no action attribute with original url $reg = '/<form[^>](.*?)>/i'; $forms = array(); $count = preg_match_all($reg,$response,$forms); if ($count>0) for ($cnt=0;$cnt<$count;$cnt++) { $reg = '/action=[\'\"](.*?)[\'\"]/i'; $actions = array(); $c = preg_match_all($reg,$forms[1][$cnt],$actions); if ($c>0) { // Check empty to replace if ($actions[1][0]=="") $newform = str_replace ($actions[0][0], 'action="'.$origurl.'"', $forms[0][$cnt]); else $newform = $forms[0][$cnt]; } else { // Toevoegen $newform = str_replace (">", ' action="'.$origurl.'">', $forms[0][$cnt]); } $response = str_replace ($forms[0][$cnt], $newform, $response); } // Replace tokes $reg = '/<input type=["\']hidden["\'] name=["\'][a-f0-9]+["\'] value=["\']1["\'] \/>/si'; $tokens = array(); $count = preg_match_all($reg,$response,$tokens); if ($count>0) foreach ($tokens[0] as $token) { $response = str_replace ($token, JHTML::_( 'form.token' ), $response); } // Replace CB tokens $cbfile0 = JPATH_ADMINISTRATOR."/components/com_comprofiler/plugin.class.php"; $cbfile1 = JPATH_ADMINISTRATOR.DS.'components'.DS.'com_comprofiler'.DS.'comprofiler.class.php'; $cbfile2 = JPATH_ADMINISTRATOR.DS.'components'.DS.'com_comprofiler'.DS.'plugin.foundation.php'; if ($this->cbreplace&&file_exists($cbfile0)&&file_exists($cbfile1)&&file_exists($cbfile2)) { require_once($cbfile0); require_once($cbfile1); require_once($cbfile2); $reg = '/<input type=["\']hidden["\'] name=["\']'.cbSpoofField().'["\'] value=["\'].*?["\'] \/>/si'; $tokens = array(); $count = preg_match_all($reg,$response,$tokens); if ($count>0) foreach ($tokens[0] as $token) { $response = str_replace ($token, cbGetSpoofInputTag('registerForm', null), $response); } $reg = '/<input type=["\']hidden["\'] name=["\']'.cbGetRegAntiSpamFieldName().'["\'] value=["\'].*?["\'] \/>/si'; $tokens = array(); $count = preg_match_all($reg,$response,$tokens); if ($count>0) foreach ($tokens[0] as $token) { $response = str_replace ($token, cbGetRegAntiSpamInputTag(), $response); } } } $content = "\n<!-- Plugin Include component version 1.13 by Mike Reumer"; $content .= "\n for: ".$url." -->"; $content .= "\n".$response; $content .= "\n<!-- End Plugin Include component -->"; return $content; }