@@ -25,7 +25,7 @@ class plgSystemAntispambycleantalk extends JPlugin {
25
25
/**
26
26
* Plugin version string for server
27
27
*/
28
- const ENGINE = 'joomla3-495 ' ;
28
+ const ENGINE = 'joomla3-496 ' ;
29
29
30
30
/**
31
31
* Default value for hidden field ct_checkjs
@@ -55,12 +55,7 @@ class plgSystemAntispambycleantalk extends JPlugin {
55
55
* Flag marked JComments form initilization.
56
56
*/
57
57
private $ JCReady = false ;
58
-
59
- /*
60
- * Page load label
61
- */
62
- private $ form_load_label = 'formtime ' ;
63
-
58
+
64
59
/*
65
60
* Page load label
66
61
*/
@@ -491,8 +486,7 @@ public function onAfterInitialise(){
491
486
}else {
492
487
if (!(isset ($ _GET ['option ' ]) && $ _GET ['option ' ] == 'com_extrawatch ' ) && !(isset ($ _GET ['checkCaptcha ' ]) && $ _GET ['checkCaptcha ' ] == 'true ' ) && strpos ($ _SERVER ['REQUEST_URI ' ],'securimage_show.php ' )===false ){
493
488
494
- $ session ->set ($ this ->form_load_label , time ());
495
- $ session ->set ('cleantalk_current_page ' , JURI ::current ());
489
+ $ this ->apbct_cookie ();
496
490
497
491
}
498
492
}
@@ -788,8 +782,6 @@ public function onAfterInitialise(){
788
782
{
789
783
if ($ user ['email ' ]==$ mail && substr ($ user ['registerDate ' ], 0 , 10 ) == $ date )
790
784
{
791
- $ db ->setQuery ("UPDATE `#__users` SET ct_marked_as_spam = 1 WHERE id = " .$ user ['id ' ]);
792
- $ db ->query ();
793
785
if ($ user ['lastvisitDate ' ] == '0000-00-00 00:00:00 ' )
794
786
$ user ['lastvisitDate ' ] = '- ' ;
795
787
$ spam_users []=$ user ;
@@ -1438,21 +1430,11 @@ public function onAfterRoute() {
1438
1430
$ submit_time = NULL ;
1439
1431
if ($ _SERVER ['REQUEST_METHOD ' ] == 'POST ' ) {
1440
1432
$ checkjs = $ this ->get_ct_checkjs ();
1441
- $ val = $ session ->get ($ this ->form_load_label );
1442
- if ($ val ) {
1443
- $ submit_time = time () - (int ) $ val ;
1444
- }
1445
1433
1446
1434
if (!$ val && session_id () != '' ) {
1447
1435
$ this ->ct_direct_post = 1 ;
1448
1436
}
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
+ }
1456
1438
/*
1457
1439
Contact forms anti-spam code
1458
1440
*/
@@ -1664,7 +1646,6 @@ public function onValidateContact(&$contact, &$data) {
1664
1646
$ this ->sendAdminEmail ("CleanTalk. Can't verify feedback message! " , $ ctResponse ['comment ' ]);
1665
1647
} else {
1666
1648
if ($ ctResponse ['allow ' ] == 0 ) {
1667
- $ session ->set ($ this ->form_load_label , time ()); // update session 'formtime'
1668
1649
$ res_str = $ ctResponse ['comment ' ];
1669
1650
$ app ->setUserState ('com_contact.contact.data ' , $ data ); // not used in 1.5 :(
1670
1651
$ stub = JRequest::getString ('id ' );
@@ -1676,11 +1657,6 @@ public function onValidateContact(&$contact, &$data) {
1676
1657
}
1677
1658
}
1678
1659
}
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
-
1684
1660
}
1685
1661
1686
1662
////////////////////////////
@@ -1733,7 +1709,6 @@ public function onJCommentsCommentBeforeAdd(&$comment) {
1733
1709
1734
1710
// set new time because onJCommentsFormAfterDisplay worked only once
1735
1711
// and formtime in session need to be renewed between ajax posts
1736
- $ session ->set ($ this ->form_load_label , time ());
1737
1712
1738
1713
$ checkjs = $ this ->get_ct_checkjs ();
1739
1714
@@ -2210,16 +2185,14 @@ private function initTables() {
2210
2185
$ field_presence = false ;
2211
2186
2212
2187
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 ' ) {
2214
2189
$ field_presence = true ;
2215
2190
}
2216
2191
}
2217
2192
2218
2193
if (!$ field_presence ) {
2219
2194
$ db ->setQuery ("ALTER TABLE `#__users` ADD ct_request_id char(32) NOT NULL DEFAULT '' " );
2220
2195
$ db ->query ();
2221
- $ db ->setQuery ("ALTER TABLE `#__users` ADD ct_marked_as_spam int NOT NULL DEFAULT 0 " );
2222
- $ db ->query ();
2223
2196
}
2224
2197
2225
2198
if (!empty ($ arrTables )) {
@@ -2426,15 +2399,11 @@ private function validEmail($string) {
2426
2399
*
2427
2400
*/
2428
2401
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
+ }
2438
2407
}
2439
2408
2440
2409
/**
@@ -2760,14 +2729,6 @@ private function swf_init($ct_apikey, $sfw_test_ip = null) {
2760
2729
$ table ->store ();
2761
2730
exit ;
2762
2731
}
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
- }
2771
2732
2772
2733
$ params = new JRegistry ($ table ->params );
2773
2734
$ params ->set ('sfw_log ' ,$ sfw_log );
@@ -2778,7 +2739,58 @@ private function swf_init($ct_apikey, $sfw_test_ip = null) {
2778
2739
2779
2740
return null ;
2780
2741
}
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
+ }
2782
2794
private function update_sfw_db_networks ($ ct_apikey )
2783
2795
{
2784
2796
$ app = JFactory::getApplication ();
0 commit comments