Skip to content

Commit f6c32b9

Browse files
author
davydovct
committed
Merge branch 'dev'
2 parents 91868b0 + b230bfe commit f6c32b9

9 files changed

+77
-64
lines changed

.gitignore

-6
This file was deleted.

CHANGELOG

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
Version 2.15 October 05, 2017
1+
Version 2.16 Septebmer 14, 2017
22
------------------------------
3-
- Fix auto-update
3+
- Update fix.
44

55
Version 2.14 Septebmer 14, 2017
66
------------------------------

RoboFile.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
class RoboFile extends \Robo\Tasks
99
{
1010
const PACKAGE = 'antispam_cleantalk_smf';
11-
const VERSION = '2.15';
11+
const VERSION = '2.16';
1212

13-
const SMF_VERSION = '2.0.15'; // for forumPrepare
13+
const SMF_VERSION = '2.0.14'; // for forumPrepare
1414

1515
/**
1616
* Build SMF zip-package

CleantalkMod.php cleantalkMod.php

+12-13
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
require_once(dirname(__FILE__) . '/CleantalkSFW.php');
2525

2626
// Common CleanTalk options
27-
define('CT_AGENT_VERSION', 'smf-215');
27+
define('CT_AGENT_VERSION', 'smf-216');
2828
define('CT_SERVER_URL', 'http://moderate.cleantalk.org');
2929
define('CT_DEBUG', false);
3030

@@ -201,7 +201,7 @@ function cleantalk_check_message(&$msgOptions, $topicOptions, $posterOptions){
201201
$ct_request->sender_ip = $ct->ct_session_ip($ip);
202202

203203
$ct_request->sender_nickname = isset($posterOptions['name']) ? $posterOptions['name'] : '';
204-
$ct_request->message = $msgOptions['body'];
204+
$ct_request->message = preg_replace('/\s+/', ' ',str_replace("<br />", " ", $msgOptions['body']));
205205

206206
$ct_request->submit_time = cleantalk_get_form_submit_time();
207207

@@ -591,9 +591,9 @@ function cleantalk_load()
591591
$ct_request->feedback = '0:'.CT_AGENT_VERSION;
592592
$ct_result = $ct->sendFeedback($ct_request);
593593
unset($ct, $ct_request);
594-
594+
$curr_key = isset($modSettings['cleantalk_api_key'])?$modSettings['cleantalk_api_key']:'';
595595
// Check if key is valid
596-
if($_POST['cleantalk_api_key'] != $modSettings['cleantalk_api_key']){
596+
if($_POST['cleantalk_api_key'] != $curr_key){
597597

598598
$key_to_validate = strval($_POST['cleantalk_api_key']);
599599
$result = CleantalkHelper::noticeValidateKey($key_to_validate);
@@ -608,8 +608,7 @@ function cleantalk_load()
608608
'cleantalk_api_key' => $key_to_validate
609609
),
610610
false
611-
);
612-
611+
);
613612
}else{
614613
updateSettings(
615614
array(
@@ -644,7 +643,11 @@ function cleantalk_load()
644643

645644
// If key is valid doing noticePaidTill(), sfw update and sfw send logs via cron
646645
if(!empty($modSettings['cleantalk_api_key_is_ok']))
646+
{
647+
if (isset($_POST['cleantalk_sfw']) && $_POST['cleantalk_sfw'] == 1)
648+
updateSettings(array('cleantalk_sfw' => '1'), false);
647649
$doing_cron = true;
650+
}
648651

649652
}
650653

@@ -690,7 +693,6 @@ function cleantalk_load()
690693

691694
/* Cron for update SFW */
692695
if(!empty($modSettings['cleantalk_sfw']) && (!empty($doing_cron) || (!empty($modSettings['cleantalk_api_key_is_ok']) && ((isset($modSettings['cleantalk_sfw_last_update']) && $modSettings['cleantalk_sfw_last_update'] < time()) || !isset($modSettings['cleantalk_sfw_last_update']) ) ))){
693-
694696
$sfw = new CleantalkSFW;
695697
$sfw->sfw_update($modSettings['cleantalk_api_key']);
696698
unset($sfw);
@@ -891,14 +893,13 @@ function cleantalk_buffer($buffer)
891893

892894
if(isset($_GET['ctcheckspam'])){
893895

894-
if($modSettings['cleantalk_api_key_is_ok'] == '1' && $modSettings['cleantalk_api_key'] != ''){
896+
if(isset($modSettings['cleantalk_api_key_is_ok']) && $modSettings['cleantalk_api_key_is_ok'] == '1' && $modSettings['cleantalk_api_key'] != ''){
895897

896898
db_extend('packages');
897899

898900
// Unmark all users
899-
$sql = 'UPDATE {db_prefix}members SET ct_marked = 0';
900-
$result = $smcFunc['db_query']('', $sql, Array());
901-
$smcFunc['db_free_result']($result);
901+
$sql = 'UPDATE {db_prefix}members SET ct_marked = {int:default_value}';
902+
$result = $smcFunc['db_query']('', $sql, array('default_value' => 0));
902903

903904
// Cicle params
904905
$offset = 0;
@@ -937,13 +938,11 @@ function cleantalk_buffer($buffer)
937938
if($value['appears'] == 1){
938939
$sql = 'UPDATE {db_prefix}members set ct_marked=1 where member_ip="'.$key.'"';
939940
$sub_result = $smcFunc['db_query']('', $sql, Array('db_error_skip' => true));
940-
$smcFunc['db_free_result']($sub_result);
941941
}
942942
}else{
943943
if($value['appears'] == 1){
944944
$sql = 'UPDATE {db_prefix}members set ct_marked=1 where email_address="'.$key.'"';
945945
$sub_result = $smcFunc['db_query']('', $sql, Array('db_error_skip' => true));
946-
$smcFunc['db_free_result']($sub_result);
947946
}
948947
}
949948
}

install.php

+2-17
Original file line numberDiff line numberDiff line change
@@ -77,23 +77,7 @@
7777

7878
/* SFW data table */
7979
$smcFunc['db_drop_table']('{db_prefix}cleantalk_sfw');
80-
$columns = array(
81-
array(
82-
'name' => 'network',
83-
'type' => 'int',
84-
'size' => 11,
85-
'unsigned' => true
86-
),
87-
array(
88-
'name' => 'mask',
89-
'type' => 'int',
90-
'size' => 11,
91-
'unsigned' => true
92-
),
93-
);
94-
$indexes = array();
95-
$parameters = array();
96-
$smcFunc['db_create_table']('{db_prefix}cleantalk_sfw', $columns, $indexes, $parameters, 'update_remove');
80+
$smcFunc['db_query']('','CREATE TABLE {db_prefix}cleantalk_sfw (network int(11) unsigned not null, mask int(11) unsigned not null)',array());
9781

9882
/* SFW logs table */
9983
$smcFunc['db_drop_table']('{db_prefix}cleantalk_sfw_logs');
@@ -157,5 +141,6 @@
157141
$smcFunc['db_drop_table']('{db_prefix}cleantalk_sfw');
158142
$smcFunc['db_drop_table']('{db_prefix}cleantalk_sfw_logs');
159143
$smcFunc['db_remove_column']('{db_prefix}members', 'ct_marked', array(), '');
144+
$smcFunc['db_query']('',"DELETE FROM {db_prefix}settings WHERE variable LIKE '%cleantalk%'",array());
160145
}
161146
}

lib/sfw_die_page.html

+26-18
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,37 @@
44
<head>
55
<meta charset='utf-8' />
66
<meta name='viewport' content='width=device-width, initial-scale=1' />
7-
<meta http-equiv='сache-сontrol' content='no-cache'>
8-
<meta http-equiv='сache-сontrol' content='private'>
9-
<meta http-equiv='сache-сontrol' content='max-age=0, must-revalidate'>
10-
<meta http-equiv='сache-сontrol' content='max-age=0, proxy-revalidate'>
11-
<meta http-equiv='expires' content='0' />
12-
<meta http-equiv='expires' content='Tue, 01 Jan 1980 1:00:00 GMT' />
13-
<meta http-equiv='pragma' content='no-cache' />
7+
<meta http-equiv='сache-сontrol' content='no-cache'>
8+
<meta http-equiv='сache-сontrol' content='private'>
9+
<meta http-equiv='сache-сontrol' content='max-age=0, must-revalidate'>
10+
<meta http-equiv='сache-сontrol' content='max-age=0, proxy-revalidate'>
11+
<meta http-equiv='expires' content='0' />
12+
<meta http-equiv='expires' content='Tue, 01 Jan 1980 1:00:00 GMT' />
13+
<meta http-equiv='pragma' content='no-cache' />
1414

1515
<!--[if lt IE 9]>
1616
<script src='http://html5shiv.googlecode.com/svn/trunk/html5.js'></script>
1717
<![endif]-->
1818
<style>
19-
html{font-size: 14pt;}
19+
html{font-size: 10pt;font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;background: #f1f1f1;}
2020
h1{text-align:center}
21+
a:hover,
22+
a:active {
23+
color: #00a0d2;
24+
}
2125
h1.main{margin-top: 1em;margin-bottom: 3em;}
22-
div.container {text-align:center;}
23-
div.container p.js_notice{width: 60%; display: inline-block;}
24-
div.footer {color: #666; position: absolute; bottom: 1em; text-align: center; width: 100%;}
26+
div.container {text-align:center;
27+
background: #fff;
28+
color: #444;
29+
margin: 2em auto;
30+
padding: 1em 2em;
31+
max-width: 700px;
32+
-webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.13);
33+
box-shadow: 0 1px 3px rgba(0,0,0,0.13);}
34+
div.container p.js_notice{width: 100%%; display: inline-block;}
35+
div.footer {color: #666; position: fixed; bottom: 1em; text-align: center; width: 100%%;}
2536
div.footer a {color: #666; vertical-align:bottom; text-align: center;}
2637
div#js_passed {display:none;}
27-
2838
@media (max-width: 600px) {
2939
}
3040
</style>
@@ -49,8 +59,8 @@ <h1 class='main'>{SFW_DIE_NOTICE_IP}<a href='https://cleantalk.org/blacklists/{R
4959

5060
<div id='js_passed'>
5161
<h3>{SFW_DIE_CLICK_TO_PASS}</h3>
52-
<a href='{REQUEST_URI}'><script>get_current_url();</script></a>
53-
{GENERATED}
62+
<a href='{REQUEST_URI}' onclick="set_spamFireWallCookie('{COOKIE_PREFIX}ct_sfw_pass_key','{SFW_COOKIE}');set_spamFireWallCookie('{COOKIE_PREFIX}ct_sfw_passed','1'); window.location.reload(1)"><script>get_current_url();</script></a>
63+
{GENERATED}
5464
<br /><br /><br />
5565
<p class='js_notice'>{SFW_DIE_YOU_WILL_BE_REDIRECTED}</p>
5666
</div>
@@ -61,11 +71,9 @@ <h3>{SFW_DIE_CLICK_TO_PASS}</h3>
6171
<script type='text/javascript'>
6272
document.getElementById('js_info').style.display = 'none';
6373
document.getElementById('js_passed').style.display = 'block';
64-
setTimeout(function(){
65-
set_spamFireWallCookie('{COOKIE_PREFIX}ct_sfw_pass_key','{SFW_COOKIE}');
66-
set_spamFireWallCookie('{COOKIE_PREFIX}ct_sfw_passed','1');
67-
}, 2000);
6874
setTimeout(function(){
75+
set_spamFireWallCookie('{COOKIE_PREFIX}ct_sfw_pass_key','{SFW_COOKIE}');
76+
set_spamFireWallCookie('{COOKIE_PREFIX}ct_sfw_passed','1');
6977
window.location.reload(1);
7078
}, reload_timeout);
7179
</script>

modification.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<!DOCTYPE modification SYSTEM "http://www.simplemachines.org/xml/modification">
33
<modification xmlns="www.simplemachines.org/xml/modification">
44
<id>cleantalk:antispam</id>
5-
<version>2.15</version>
5+
<version>2.16</version>
66
<file name="$sourcedir/Post.php">
77
<operation error="fatal">
88
<search position="after"><![CDATA[createPost($msgOptions, $topicOptions, $posterOptions);]]></search>

package-info.xml

+31-4
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<id>cleantalk:antispam</id>
55
<name>Anti-spam by CleanTalk</name>
66
<type>modification</type>
7-
<version>2.15</version>
8-
<install for="2.0 - 2.0.99">
7+
<version>2.16</version>
8+
<install for="2.0 - 2.1.99">
99
<readme type="file" parsebbc="true">readme.txt</readme>
1010
<create-dir name="cleantalk" destination="$sourcedir"/>
1111
<require-file name="cleantalkMod.php" destination="$sourcedir/cleantalk">Mod main file</require-file>
@@ -27,7 +27,7 @@
2727
you are being redirected to this mod configuration settings.
2828
</redirect>
2929
</install>
30-
<uninstall for="2.0 - 2.0.99">
30+
<uninstall for="2.0 - 2.1.99">
3131
<database>install.php</database>
3232
<modification format="xml" type="file" reverse="true">modification.xml</modification>
3333
<modification format="xml" type="file" reverse="true">languages/english.xml</modification>
@@ -36,9 +36,36 @@
3636
<modification format="xml" type="file" reverse="true">languages/russian-utf8.xml</modification>
3737
<remove-dir name="$sourcedir/cleantalk/"/>
3838
</uninstall>
39-
<upgrade from="2.0 - 2.0.99">
39+
<upgrade from="1.80 - 2.11">
4040
<readme type="inline" parsebbc="true">
4141
<![CDATA[[size=14pt][color=red]Please uninstall old version cleantalk mod when installing newer version![/color][/size]]]>
4242
</readme>
4343
</upgrade>
44+
<upgrade from="2.12 - 2.15">
45+
<readme type="inline" parsebbc="true">This upgrade for Antispam by Cleantalk to 2.16 version:
46+
- Fix SFW update on save settings
47+
- Change SFW template
48+
- Remove plugin settings on uninstall
49+
- Fix sfw_create_table query
50+
</readme>
51+
<create-dir name="cleantalk" destination="$sourcedir"/>
52+
<require-file name="cleantalkMod.php" destination="$sourcedir/cleantalk">Mod main file</require-file>
53+
<require-file name="lib/Cleantalk.php" destination="$sourcedir/cleantalk">Base class</require-file>
54+
<require-file name="lib/CleantalkRequest.php" destination="$sourcedir/cleantalk">Extend for base class</require-file>
55+
<require-file name="lib/CleantalkResponse.php" destination="$sourcedir/cleantalk">Extend for base class</require-file>
56+
<require-file name="lib/CleantalkHelper.php" destination="$sourcedir/cleantalk">Helper functions</require-file>
57+
<require-file name="lib/CleantalkSFW.php" destination="$sourcedir/cleantalk">SFW class</require-file>
58+
<require-file name="lib/phpFix.php" destination="$sourcedir/cleantalk">Fix for old PHP versions</require-file>
59+
<require-file name="lib/sfw_die_page.html" destination="$sourcedir/cleantalk">SFW die page</require-file>
60+
<require-file name="attention.png" destination="$sourcedir/cleantalk">attention picture</require-file>
61+
<modification format="xml" type="file">modification.xml</modification>
62+
<modification format="xml" type="file">languages/english.xml</modification>
63+
<modification format="xml" type="file">languages/english-utf8.xml</modification>
64+
<modification format="xml" type="file">languages/russian.xml</modification>
65+
<modification format="xml" type="file">languages/russian-utf8.xml</modification>
66+
<database>install.php</database>
67+
<redirect url="$boardurl/index.php?action=admin;area=modsettings" type="inline">Please stand by while
68+
you are being redirected to this mod configuration settings.
69+
</redirect>
70+
</upgrade>
4471
</package-info>

readme.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
MOD [b]Anti-spam by CleanTalk[/b]
2-
Version: 2.15
2+
Version: 2.16
33

44
Anti-spam by CleanTalk mod with protection against spam bots and manual spam.
55
No Captcha, no questions, no counting animals, no puzzles, no math.

0 commit comments

Comments
 (0)