Skip to content

Commit 4c6c543

Browse files
author
davydovct
committed
release 4.96
2 parents 3bf216f + 1bf2b03 commit 4c6c543

File tree

5 files changed

+86
-54
lines changed

5 files changed

+86
-54
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Anti-spam plugin for Joomla 2.5-3.X.
22
============
3-
Version 4.9.5
3+
Version 4.9.6
44

55
## Simple antispam test
66

antispambycleantalk.php

Lines changed: 62 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class plgSystemAntispambycleantalk extends JPlugin {
2525
/**
2626
* Plugin version string for server
2727
*/
28-
const ENGINE = 'joomla3-495';
28+
const ENGINE = 'joomla3-496';
2929

3030
/**
3131
* Default value for hidden field ct_checkjs
@@ -55,12 +55,7 @@ class plgSystemAntispambycleantalk extends JPlugin {
5555
* Flag marked JComments form initilization.
5656
*/
5757
private $JCReady = false;
58-
59-
/*
60-
* Page load label
61-
*/
62-
private $form_load_label = 'formtime';
63-
58+
6459
/*
6560
* Page load label
6661
*/
@@ -491,8 +486,7 @@ public function onAfterInitialise(){
491486
}else{
492487
if(!(isset($_GET['option']) && $_GET['option'] == 'com_extrawatch') && !(isset($_GET['checkCaptcha']) && $_GET['checkCaptcha'] == 'true') && strpos($_SERVER['REQUEST_URI'],'securimage_show.php')===false){
493488

494-
$session->set($this->form_load_label, time());
495-
$session->set('cleantalk_current_page', JURI::current());
489+
$this->apbct_cookie();
496490

497491
}
498492
}
@@ -788,8 +782,6 @@ public function onAfterInitialise(){
788782
{
789783
if ($user['email']==$mail && substr($user['registerDate'], 0, 10) == $date)
790784
{
791-
$db->setQuery("UPDATE `#__users` SET ct_marked_as_spam = 1 WHERE id = ".$user['id']);
792-
$db->query();
793785
if ($user['lastvisitDate'] == '0000-00-00 00:00:00')
794786
$user['lastvisitDate'] = '-';
795787
$spam_users[]=$user;
@@ -1438,21 +1430,11 @@ public function onAfterRoute() {
14381430
$submit_time = NULL;
14391431
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
14401432
$checkjs = $this->get_ct_checkjs();
1441-
$val = $session->get($this->form_load_label);
1442-
if ($val) {
1443-
$submit_time = time() - (int) $val;
1444-
}
14451433

14461434
if (!$val && session_id() != '') {
14471435
$this->ct_direct_post = 1;
14481436
}
1449-
} else {
1450-
if(!(isset($_GET['option']) && $_GET['option'] == 'com_extrawatch') && !(isset($_GET['checkCaptcha']) && $_GET['checkCaptcha'] == 'true') && strpos($_SERVER['REQUEST_URI'],'securimage_show.php')===false)
1451-
{
1452-
$session->set($this->form_load_label, time());
1453-
$session->set('cleantalk_current_page', JURI::current());
1454-
}
1455-
}
1437+
}
14561438
/*
14571439
Contact forms anti-spam code
14581440
*/
@@ -1664,7 +1646,6 @@ public function onValidateContact(&$contact, &$data) {
16641646
$this->sendAdminEmail("CleanTalk. Can't verify feedback message!", $ctResponse['comment']);
16651647
} else {
16661648
if ($ctResponse['allow'] == 0) {
1667-
$session->set($this->form_load_label, time()); // update session 'formtime'
16681649
$res_str = $ctResponse['comment'];
16691650
$app->setUserState('com_contact.contact.data', $data); // not used in 1.5 :(
16701651
$stub = JRequest::getString('id');
@@ -1676,11 +1657,6 @@ public function onValidateContact(&$contact, &$data) {
16761657
}
16771658
}
16781659
}
1679-
if(!(isset($_POST['itemName']) && $_POST['itemName'] == 'reginfo') && !(isset($_POST['option']) && $_POST['option'] == 'com_breezingforms'))
1680-
{
1681-
$session->clear($this->form_load_label); // clear session 'formtime'
1682-
}
1683-
16841660
}
16851661

16861662
////////////////////////////
@@ -1733,7 +1709,6 @@ public function onJCommentsCommentBeforeAdd(&$comment) {
17331709

17341710
// set new time because onJCommentsFormAfterDisplay worked only once
17351711
// and formtime in session need to be renewed between ajax posts
1736-
$session->set($this->form_load_label, time());
17371712

17381713
$checkjs = $this->get_ct_checkjs();
17391714

@@ -2210,16 +2185,14 @@ private function initTables() {
22102185
$field_presence = false;
22112186

22122187
foreach ($users_columns as $column) {
2213-
if ($column[0] == 'ct_request_id' || $column[0] == 'ct_marked_as_spam') {
2188+
if ($column[0] == 'ct_request_id') {
22142189
$field_presence = true;
22152190
}
22162191
}
22172192

22182193
if (!$field_presence) {
22192194
$db->setQuery("ALTER TABLE `#__users` ADD ct_request_id char(32) NOT NULL DEFAULT ''");
22202195
$db->query();
2221-
$db->setQuery("ALTER TABLE `#__users` ADD ct_marked_as_spam int NOT NULL DEFAULT 0");
2222-
$db->query();
22232196
}
22242197

22252198
if (!empty($arrTables)) {
@@ -2426,15 +2399,11 @@ private function validEmail($string) {
24262399
*
24272400
*/
24282401
private function submit_time_test() {
2429-
$session = JFactory::getSession();
2430-
$val = $session->get($this->form_load_label);
2431-
if ($val) {
2432-
$submit_time = time() - (int) $val;
2433-
} else {
2434-
$submit_time = NULL;
2435-
}
2436-
2437-
return $submit_time;
2402+
if($this->apbct_cookies_test() == 1){
2403+
return time() - $_COOKIE['apbct_timestamp'];
2404+
}else{
2405+
return null;
2406+
}
24382407
}
24392408

24402409
/**
@@ -2760,14 +2729,6 @@ private function swf_init($ct_apikey, $sfw_test_ip = null) {
27602729
$table->store();
27612730
exit;
27622731
}
2763-
else
2764-
{
2765-
//$sfw_log[$sender_ip]->all++;
2766-
//
2767-
// Setup secret key if the visitor doesn't exit in sfw_networks.
2768-
//
2769-
setcookie($this->sfw_cookie_lable, $sfw_key, 0, '/');
2770-
}
27712732

27722733
$params = new JRegistry($table->params);
27732734
$params->set('sfw_log',$sfw_log);
@@ -2778,7 +2739,58 @@ private function swf_init($ct_apikey, $sfw_test_ip = null) {
27782739

27792740
return null;
27802741
}
2781-
2742+
/*
2743+
* Set Cookies test for cookie test
2744+
* Sets cookies with pararms timestamp && landing_timestamp && pervious_referer
2745+
* Sets test cookie with all other cookies
2746+
*/
2747+
function apbct_cookie(){
2748+
2749+
$config = $this->getCTConfig();
2750+
2751+
// Cookie names to validate
2752+
$cookie_test_value = array(
2753+
'cookies_names' => array(),
2754+
'check_value' => $config['apikey'],
2755+
);
2756+
2757+
// Submit time
2758+
$apbct_timestamp = time();
2759+
setcookie('apbct_timestamp', $apbct_timestamp, 0, '/');
2760+
$cookie_test_value['cookies_names'][] = 'apbct_timestamp';
2761+
$cookie_test_value['check_value'] .= $apbct_timestamp;
2762+
2763+
// Cookies test
2764+
$cookie_test_value['check_value'] = md5($cookie_test_value['check_value']);
2765+
setcookie('apbct_cookies_test', json_encode($cookie_test_value), 0, '/');
2766+
}
2767+
/**
2768+
* Cookies test for sender
2769+
* Also checks for valid timestamp in $_COOKIE['apbct_timestamp'] and other apbct_ COOKIES
2770+
* @return null|0|1;
2771+
*/
2772+
function apbct_cookies_test()
2773+
{
2774+
$config = $this->getCTConfig();
2775+
2776+
if(isset($_COOKIE['apbct_cookies_test'])){
2777+
2778+
$cookie_test = json_decode(stripslashes($_COOKIE['apbct_cookies_test']), true);
2779+
2780+
$check_srting = $config['apikey'];
2781+
foreach($cookie_test['cookies_names'] as $cookie_name){
2782+
$check_srting .= isset($_COOKIE[$cookie_name]) ? $_COOKIE[$cookie_name] : '';
2783+
} unset($cokie_name);
2784+
2785+
if($cookie_test['check_value'] == md5($check_srting)){
2786+
return 1;
2787+
}else{
2788+
return 0;
2789+
}
2790+
}else{
2791+
return null;
2792+
}
2793+
}
27822794
private function update_sfw_db_networks($ct_apikey)
27832795
{
27842796
$app = JFactory::getApplication();

antispambycleantalk.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<license>GNU/GPLv2</license>
88
<authorEmail>welcome@cleantalk.org</authorEmail>
99
<authorUrl>cleantalk.org</authorUrl>
10-
<version>4.9.5</version>
10+
<version>4.9.6</version>
1111
<description>PLG_CLEANTALK_DESCRIPTION</description>
1212
<files>
1313
<filename plugin="antispambycleantalk">antispambycleantalk.php</filename>

plugin-updates.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<updates>
3+
<update>
4+
<name>Antispam by CleanTalk</name>
5+
<description>Antispam plugin for Joomla registrations and contacts, for VurtueMart, Rapid Contact, VTEM Contact, JComments 2.3, 3.0.</description>
6+
<element>antispambycleantalk</element>
7+
<type>plugin</type>
8+
<folder>system</folder>
9+
<client_id>0</client_id>
10+
<client>0</client>
11+
<version>4.9.6</version>
12+
<infourl title="Antispam by CleanTalk">https://cleantalk.org/joomla-anti-spam-plugin-without-captcha</infourl>
13+
<downloads>
14+
<downloadurl type="full" format="zip">https://github.com/CleanTalk/joomla25-3x-antispam/archive/master.zip</downloadurl>
15+
</downloads>
16+
<tags>
17+
<tag>stable</tag>
18+
</tags>
19+
<maintainer>CleanTalk</maintainer>
20+
<maintainerurl>https://cleantalk.org</maintainerurl>
21+
<targetplatform name="joomla" version="[23].*"/>
22+
</update>
323
<update>
424
<name>Antispam by CleanTalk</name>
525
<description>Antispam plugin for Joomla registrations and contacts, for VurtueMart, Rapid Contact, VTEM Contact, JComments 2.3, 3.0.</description>

spamfirewall.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ <h1 class="main">SpamFireWall is activated for your IP <a href="https://cleantal
6262

6363
<div id="js_passed">
6464
<h3>Please click bellow to pass protection</h3>
65-
<a href='' onclick="set_spamFireWallCookie();window.location.reload(1)"><script>get_current_url();</script></a>
65+
<a href='' onclick="set_spamFireWallCookie();"><script>get_current_url();</script></a>
6666
<br /><br /><br />
6767
<p class="js_notice">Or you will be automatically redirected to the requested page after %d seconds</p>
6868
</div>
@@ -75,7 +75,7 @@ <h3>Please click bellow to pass protection</h3>
7575
document.getElementById('js_passed').style.display = 'block';
7676
setTimeout(function(){
7777
set_spamFireWallCookie();
78-
window.location.reload(1);
78+
window.location.href=window.location.href + (window.location.search === '' ? '?sfw=pass' : '&sfw=pass');
7979
}, reload_timeout);
8080
</script>
8181
</body>

0 commit comments

Comments
 (0)