Skip to content

Commit

Permalink
Version 3.0
Browse files Browse the repository at this point in the history
Version 3.0
  • Loading branch information
Glomberg authored Dec 8, 2022
2 parents e08887d + 36fb02e commit 66b8c27
Show file tree
Hide file tree
Showing 74 changed files with 10,927 additions and 4,659 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
/.idea/
/vendor
/node_modules
/lib/**/composer.json
/lib/**/.gitignore
/lib/**/LICENSE
/lib/**/README.MD
/lib/**/tests
composer.lock
package-lock.json
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Anti-spam plugin for Joomla 3.X.-4.x
============
Version 2.3
Version 3.0
=======

## Simple antispam test
Expand Down
513 changes: 380 additions & 133 deletions cleantalkantispam.php

Large diffs are not rendered by default.

29 changes: 2 additions & 27 deletions cleantalkantispam.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,44 +7,19 @@
<license>GNU/GPLv2</license>
<authorEmail>[email protected]</authorEmail>
<authorUrl>cleantalk.org</authorUrl>
<version>2.3</version>
<version>3.0</version>
<description>PLG_SYSTEM_CLEANTALKANTISPAM_DESCRIPTION</description>
<scriptfile>updater.php</scriptfile>
<files>
<filename plugin="cleantalkantispam">cleantalkantispam.php</filename>
<filename>updater.php</filename>
<filename plugin="cleantalkantispam">lib/autoload.php</filename>
<filename plugin="cleantalkantispam">lib/Cleantalk/Antispam/Cleantalk.php</filename>
<filename plugin="cleantalkantispam">lib/Cleantalk/Antispam/CleantalkRequest.php</filename>
<filename plugin="cleantalkantispam">lib/Cleantalk/Antispam/CleantalkResponse.php</filename>
<filename plugin="cleantalkantispam">lib/Cleantalk/Common/API.php</filename>
<filename plugin="cleantalkantispam">lib/Cleantalk/Common/Cron.php</filename>
<filename plugin="cleantalkantispam">lib/Cleantalk/Common/DB.php</filename>
<filename plugin="cleantalkantispam">lib/Cleantalk/Common/Helper.php</filename>
<filename plugin="cleantalkantispam">lib/Cleantalk/Common/RemoteCalls.php</filename>
<filename plugin="cleantalkantispam">lib/Cleantalk/Common/Schema.php</filename>
<filename plugin="cleantalkantispam">lib/Cleantalk/Common/Variables/Cookie.php</filename>
<filename plugin="cleantalkantispam">lib/Cleantalk/Common/Variables/Get.php</filename>
<filename plugin="cleantalkantispam">lib/Cleantalk/Common/Variables/Post.php</filename>
<filename plugin="cleantalkantispam">lib/Cleantalk/Common/Variables/Request.php</filename>
<filename plugin="cleantalkantispam">lib/Cleantalk/Common/Variables/Server.php</filename>
<filename plugin="cleantalkantispam">lib/Cleantalk/Common/Variables/ServerVariables.php</filename>
<filename plugin="cleantalkantispam">lib/Cleantalk/Common/Firewall/Firewall.php</filename>
<filename plugin="cleantalkantispam">lib/Cleantalk/Common/Firewall/FirewallModule.php</filename>
<filename plugin="cleantalkantispam">lib/Cleantalk/Common/Firewall/FirewallUpdater.php</filename>
<filename plugin="cleantalkantispam">lib/Cleantalk/Common/Firewall/Modules/die_page_sfw.html</filename>
<filename plugin="cleantalkantispam">lib/Cleantalk/Common/Firewall/Modules/SFW.php</filename>
<filename plugin="cleantalkantispam">lib/Cleantalk/Common/error.html</filename>
<filename plugin="cleantalkantispam">lib/Cleantalk/ApbctJoomla/Cron.php</filename>
<filename plugin="cleantalkantispam">lib/Cleantalk/ApbctJoomla/DB.php</filename>
<filename plugin="cleantalkantispam">lib/Cleantalk/ApbctJoomla/Helper.php</filename>
<filename plugin="cleantalkantispam">lib/Cleantalk/ApbctJoomla/RemoteCalls.php</filename>
<filename plugin="cleantalkantispam">js/ct-settings.js</filename>
<filename plugin="cleantalkantispam">js/ct-functions.js</filename>
<filename plugin="cleantalkantispam">js/ct-external.js</filename>
<filename plugin="cleantalkantispam">css/ct-settings.css</filename>
<filename plugin="cleantalkantispam">img/preloader.gif</filename>
<folder>sql/mysql</folder>
<folder>lib/</folder>
</files>
<languages folder="language">
<language tag="en-GB">en-GB/en-GB.plg_system_cleantalkantispam.ini</language>
Expand Down
16 changes: 16 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"require": {
"cleantalk/antispam": "^1.0",
"cleantalk/firewall": "^1.0",
"cleantalk/dns": "^1.0",
"cleantalk/api": "^1.0",
"cleantalk/cron": "^1.0",
"cleantalk/remote-calls": "^1.0",
"cleantalk/storage-handler": "^1.0"
},
"config": {
"allow-plugins": {
"cleantalk/apbct-installer": true
}
}
}
2 changes: 1 addition & 1 deletion js/ct-external.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function ct_check_external(){
}
}

jQuery(document).ready( function(){
document.addEventListener('DOMContentLoaded', function() {
setTimeout(function () {
ct_check_external();
}, 1500);
Expand Down
101 changes: 81 additions & 20 deletions js/ct-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,94 @@ function animate_banner(to){
jQuery('#feedback_notice').fadeTo(300,to);
}
}
function banner_check() {
var bannerChecker = setInterval( function() {
jQuery.ajax({
type: "POST",
url: location.href,
data: {'check_renew_banner' : 1},
// dataType: 'json',
success: function(msg){
msg=jQuery.parseJSON(msg);
if (msg.close_renew_banner == 1) {
jQuery('.alert-info').hide('slow');
clearInterval(bannerChecker);
}

// Get system messages and handle these
document.addEventListener('DOMContentLoaded', () => {
setTimeout(dispatchJoomlaNotices, 0);
});
function dispatchJoomlaNotices() {
const joomlaAlertWrapper = document.getElementById("system-message-container");
if ( joomlaAlertWrapper !== null ) {
let joomlaAlerts = joomlaAlertWrapper.getElementsByTagName('joomla-alert');
if ( joomlaAlerts.length === 0 ) {
joomlaAlerts = joomlaAlertWrapper.getElementsByClassName('alert');
}
if ( joomlaAlerts.length > 0 ) {
for ( let i = 0; i < joomlaAlerts.length; i++ ) {
dispatchApbctJoomlaNotice(joomlaAlerts[i]);
}
});
}, 60000);
}
}
}
function dispatchApbctJoomlaNotice(element) {
const apbctNotice = element.querySelector("#apbct_joomla_notice");
let oldWay = element.tagName !== 'JOOMLA-ALERT';

if ( apbctNotice !== null ) {
// Disable notice dismissing on the plugin settings page
const currentUrl = new URL(location.href);
if ( currentUrl.searchParams.get('layout') === 'edit' && +currentUrl.searchParams.get('extension_id') === ct_extension_id ) {
if ( typeof element.destroyCloseButton === "function" ) {
element.destroyCloseButton();
} else {
element.getElementsByClassName('close')[0].remove();
}
}

// Listen close event only on the TRIAL of RENEW banner
if ( apbctNotice.dataset.noticeType === 'trial' || apbctNotice.dataset.noticeType === 'renew' ) {
const dispatchedElement = oldWay ? element.getElementsByClassName('close')[0] : element;
const dispatchedEvent = oldWay ? 'click' : 'joomla.alert.close';

if ( typeof dispatchedElement === 'undefined' ) {
return;
}

dispatchedElement.addEventListener(dispatchedEvent, (event) => {
let data = {
'action' : 'dismiss_notice',
'data': {
'notice_type' : apbctNotice.dataset.noticeType
}
};
Joomla.request({
url: 'index.php?option=com_ajax&plugin=cleantalkantispam&format=json',
method: 'POST',
data: JSON.stringify(data),
headers: {
'Cache-Control' : 'no-cache'
},
onSuccess: function (response, xhr){
try {
let responseData = JSON.parse(response);
responseData = responseData.data[0];
if ( responseData.error ) {
// Do something with the error
} else {
// Do something with the regular result
}
} catch (e) {
console.log(e.toString());
console.log(e.fileName);
console.log(e.lineNumber);
}
}
})
});
}
}
}

jQuery(document).ready(function(){
var ct_auth_key = jQuery('.cleantalk_auth_key').prop('value'),
ct_notice_cookie = ct_getCookie('ct_notice_cookie');
//notice about exclusion rules
jQuery('#attrib-exclusions,#options-exclusions').append("<br><p>" + ct_exclusions_common_notice + "</p>")
// misc notices
jQuery('#attrib-checkuserscomments,#options-checkuserscomments').append("<center><button id=\"check_spam_users\" class=\"btn btn-success \" type=\"button\"><span class=\"icon-users levels\"></span>"+ct_spamcheck_checksusers+"</button>&nbsp;&nbsp;&nbsp;<button id=\"check_spam_comments\" class=\"btn btn-success\" type=\"button\"><span class=\"icon-archive\"></span>"+ct_spamcheck_checkscomments+"</button><br /><br />"+ct_spamcheck_notice+"<br/><br/><input type='checkbox' name ='ct_impspamcheck_checkbox' value='0'>"+ct_impspamcheck_label+"</center><br/><br/>")
jQuery('#attrib-connectionreports,#options-connectionreports').append("<div id='connection_reports'></div>");
jQuery('<br/><h3>'+ct_form_settings_title+'</h3><label id="jform_params_hr_spacer-lbl" class=""><hr></label>').insertBefore(jQuery('.control-group')[2]);
jQuery('<br/><h3>'+ct_form_settings_title+'</h3><label id="jform_params_hr_spacer-lbl" class=""><hr></label>')
.insertBefore(jQuery('#jform_params_apikey').closest('.control-group').next().next());
jQuery('#attrib-checkuserscomments,#options-checkuserscomments').append("<center><div id ='spam_results'></div>");
jQuery('#attrib-checkuserscomments,#options-checkuserscomments,#attrib-connectionreports,#options-connectionreports').append("<img class='display_none' id='ct_preloader_spam_results' src='../plugins/system/cleantalkantispam/img/preloader.gif' />");
//dev
Expand Down Expand Up @@ -141,10 +206,6 @@ jQuery(document).ready(function(){
if(ct_moderate_ip == 1)
jQuery('#jform_params_apikey').parent().parent().append("<br /><h4>The anti-spam service is paid by your hosting provider. License #"+ct_ip_license+"</h4>");

//Check banner
if (jQuery('.alert').length && jQuery('.alert').hasClass('alert-info'))
banner_check();

// Handler for review banner
jQuery('#ct_review_link').click(function(){
var data = {
Expand Down
1 change: 1 addition & 0 deletions language/en-GB/en-GB.plg_system_cleantalkantispam.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ PLG_SYSTEM_CLEANTALKANTISPAM_EXCLUSIONS_FIELDS="Fields exclusions"
PLG_SYSTEM_CLEANTALKANTISPAM_EXCLUSIONS_FIELDS_DESC="Exclude fields from spam check. List them separated by commas. Works on forms except for registration and comment forms."
PLG_SYSTEM_CLEANTALKANTISPAM_EXCLUSIONS_ROLES="User's groups exclusions"
PLG_SYSTEM_CLEANTALKANTISPAM_EXCLUSIONS_ROLES_DESC="Exclude user's groups from spam check. List them separated by commas."
PLG_SYSTEM_CLEANTALKANTISPAM_EXCLUSIONS_COMMON_NOTICE="Important: Fields exclusion works on forms except for comment and registration forms!"
PLG_SYSTEM_CLEANTALKANTISPAM_JS_PARAM_AUTOKEY_LABEL="Get the access key automatically!"
PLG_SYSTEM_CLEANTALKANTISPAM_JS_PARAM_NOTICE1="Admin e-mail ("
PLG_SYSTEM_CLEANTALKANTISPAM_JS_PARAM_NOTICE2=") will be used for registration"
Expand Down
1 change: 1 addition & 0 deletions language/ru-RU/ru-RU.plg_system_cleantalkantispam.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ PLG_SYSTEM_CLEANTALKANTISPAM_EXCLUSIONS_FIELDS="Исключения по пол
PLG_SYSTEM_CLEANTALKANTISPAM_EXCLUSIONS_FIELDS_DESC="Указанные поля (по атрибуту name) будут исключены из проверки. Перечислите через запятую."
PLG_SYSTEM_CLEANTALKANTISPAM_EXCLUSIONS_ROLES="Исключения по группам пользователей"
PLG_SYSTEM_CLEANTALKANTISPAM_EXCLUSIONS_ROLES_DESC="Указанные группы пользователей будут исключены из проверки. Перечислите через запятую."
PLG_SYSTEM_CLEANTALKANTISPAM_EXCLUSIONS_COMMON_NOTICE="Внимание! Исключения по полям не работают для формы регистрации и комментариев."
PLG_SYSTEM_CLEANTALKANTISPAM_PARAM_APIKEY_HINT = "Введите ключ"
PLG_SYSTEM_CLEANTALKANTISPAM_PARAM_APIKEY_DESC="Ключ доступа к сервису модерации и защиты от спама. Чтобы получить новый ключ зарегистрируйтесь на сайте http://cleantalk.org"
PLG_SYSTEM_CLEANTALKANTISPAM_JS_PARAM_AUTOKEY_LABEL="Получить ключ автоматически"
Expand Down
Loading

0 comments on commit 66b8c27

Please sign in to comment.