Skip to content

2.5.2 #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Sep 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cleantalk/cleantalk.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ function ct_attach_js($buffer){
global $apbct_checkjs_val;
if(
!(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') // No ajax
&& preg_match('/^\s*(<!doctype|<html)[\s\S]*html>\s*$/i', $buffer) == 1 // Only for HTML documents
&& preg_match('/^\s*(<!doctype|<html)[\s\S]*html>/i', $buffer) == 1 // Only for HTML documents
){
$html_addition =
'<script>var apbct_checkjs_val = "' . $apbct_checkjs_val . '";</script>'
.'<script src="/cleantalk/js/ct_js_test.js"></script>'
.'<script src="/cleantalk/js/ct_ajax_catch.js"></script>';
$buffer = preg_replace(
'/<\/body>\s*<\/html>\s*$/i',
'/<\/body>\s*<\/html>/i',
$html_addition.'</body></html>',
$buffer,
1
Expand Down
3 changes: 2 additions & 1 deletion cleantalk/inc/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,8 @@ function detect_cms( $path_to_index, $out = 'Unknown' ){
$out = 'phpBB';
if ( strpos( $index_file, '/wa-config/' ) && strpos( $index_file, 'waSystem::getInstance' ) )
$out = 'ShopScript';

if (preg_match('/(DATALIFEENGINE.*?)/', $index_file))
$out = 'DLE';
}

return $out;
Expand Down
2 changes: 1 addition & 1 deletion cleantalk/inc/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

define( 'CLEANTALK_INITIAL_INCLUDE_PATH', get_include_path() );
define('APBCT_PLUGIN', 'uni');
define('APBCT_VERSION', '2.5.1');
define('APBCT_VERSION', '2.5.2');
define('APBCT_AGENT', APBCT_PLUGIN . '-' . str_replace( '.', '', APBCT_VERSION ) );
define('APBCT_USER_AGENT', 'Cleantalk-Antispam-Universal-Plugin/' . APBCT_VERSION);

Expand Down
22 changes: 19 additions & 3 deletions cleantalk/inc/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,8 @@ function apbct_get_fields_any($arr, $message=array(), $email = null, $nickname =
'CSRFToken',
'page',
'id',
'skin',
'sec_code'
);

// Reset $message if we have a sign-up data
Expand Down Expand Up @@ -316,9 +318,10 @@ function apbct_get_fields_any($arr, $message=array(), $email = null, $nickname =
$not_reg = true;
}else{
foreach($registration as $needle){
if(stripos($key, $needle) !== false ||
( $key == 'page' && $value == 'register' ) || //OsClass
( $key == 'task' && $value == 'registration.register' ) // Joomla!
if(stripos($key, $needle) !== false ||
( $key == 'page' && $value == 'register' ) || //OsClass
( $key == 'task' && $value == 'registration.register' ) || // Joomla!
( $key == 'do' && $value == 'register' ) // DLE!
){
$reg = true;
continue(2);
Expand Down Expand Up @@ -511,6 +514,19 @@ function apbct_die($comment, $registration = false, $additional_text = null){
die(json_encode(array('status' =>'ok', 'data' => array('errors' => $comment))));
}

// DLE integration
if( $detected_cms === 'DLE' ) {
if( ! headers_sent() ) {
header('Content-Type:application/json' );
}

if (isset($_REQUEST['mod']) && $_REQUEST['mod'] === 'addcomments') {
die(json_encode(array("error" => true, "content" => "<script>\nvar form = document.getElementById('dle-comments-form');\n\n DLEalert('" . $comment . "', 'Добавление комментария');\n var timeval = new Date().getTime();\n\n\n\t\t\n\tif ( dle_captcha_type == \"1\" ) {\n\t\tif ( typeof grecaptcha != \"undefined\" ) {\n\t\t grecaptcha.reset();\n\t\t}\n } else if (dle_captcha_type == \"2\") {\n\t\tif ( typeof grecaptcha != \"undefined\" ) {\n\t\t\tvar recaptcha_public_key = $('#g-recaptcha-response').data('key');\n\t\t\tgrecaptcha.execute(recaptcha_public_key, {action: 'comments'}).then(function(token) {\n\t\t\t$('#g-recaptcha-response').val(token);\n\t\t\t});\n\t\t}\n\t}\n\n\tif ( form.question_answer ) {\n\n\t form.question_answer.value ='';\n jQuery('#dle-question').text('');\n }\n\n\tif ( document.getElementById('dle-captcha') ) {\n\t\tform.sec_code.value = '';\n\t\tdocument.getElementById('dle-captcha').innerHTML = '<img src=\"' + dle_root + 'engine/modules/antibot/antibot.php?rand=' + timeval + '\" width=\"160\" height=\"80\" alt=\"\">';\n\t}\n\t\t\n </script>" ), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES ));
}

die(json_encode(array('status' =>'ok', 'text' => $comment)));
}

die(json_encode(array('apbct' => array('blocked' => true, 'comment' => $comment,))));

// File exists?
Expand Down
3 changes: 3 additions & 0 deletions cleantalk/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@
case 'Question2Answer':
$exclusions['dologin'] = '1';
break;
case 'DLE':
array_push( $files_to_mod, $_SERVER['DOCUMENT_ROOT'] . "/engine/ajax/controller.php" );
break;
}

install( $files_to_mod, $api_key, $cms, $exclusions );
Expand Down