Skip to content

Commit

Permalink
Update version.
Browse files Browse the repository at this point in the history
  • Loading branch information
davydovct committed Feb 19, 2021
1 parent 20b377c commit fe1ac7e
Show file tree
Hide file tree
Showing 13 changed files with 128 additions and 35 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Version 2.32 Jun 02, 2020
------------------------------
- Trait usage fixed.

Version 2.31 Mar 04, 2020
------------------------------
- Setting "Check registration" added.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

[![Build Status](https://travis-ci.org/CleanTalk/smf-antispam.svg)](https://travis-ci.org/CleanTalk/smf-antispam)

* **Version:** 2.31
* **Version:** 2.32
* **License:** GNU General Public License
* **Compatible with:** SMF 2.0 and up
* **Languages:** English, Russian
Expand Down
2 changes: 1 addition & 1 deletion RoboFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class RoboFile extends \Robo\Tasks
{
const PACKAGE = 'antispam_cleantalk_smf';
const VERSION = '2.31';
const VERSION = '2.32';

const SMF_VERSION = '2.0.14'; // for forumPrepare

Expand Down
59 changes: 38 additions & 21 deletions cleantalk/cleantalkMod.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
require_once(dirname(__FILE__) . '/lib/autoloader.php');

// Common CleanTalk options
define('CT_AGENT_VERSION', 'smf-231');
define('CT_AGENT_VERSION', 'smf-232');
define('CT_SERVER_URL', 'http://moderate.cleantalk.org');
define('CT_DEBUG', false);
define('CT_REMOTE_CALL_SLEEP', 10);
Expand All @@ -35,7 +35,7 @@ function cleantalk_sfw_check()
{
global $modSettings, $language, $user_info;

if ($user_info['is_admin'])
if (isset($user_info) && $user_info['is_admin'])
return;
// Remote calls
if(isset($_GET['spbc_remote_call_token'], $_GET['spbc_remote_call_action'], $_GET['plugin_name']) && in_array($_GET['plugin_name'], array('antispam','anti-spam', 'apbct'))){
Expand Down Expand Up @@ -86,6 +86,10 @@ function cleantalk_sfw_check()
&& strpos($_SERVER['REQUEST_URI'], 'action=login') === false
&& strpos($_SERVER['REQUEST_URI'], 'action=post') === false
&& strpos($_SERVER['REQUEST_URI'], 'action=pm') === false
/* Skip checking search requests */
/* @ToDo implement "Search protection" integration */
&& strpos($_SERVER['REQUEST_URI'], 'action=search') === false
&& strpos($_SERVER['REQUEST_URI'], 'action=search2') === false
){

$ct_temp_msg_data = cleantalkGetFields($_POST);
Expand Down Expand Up @@ -269,15 +273,15 @@ function cleantalkGetFields($arr, $message=array(), $email = null, $nickname = a


// Removes whitespaces
$value = urldecode( trim( $value ) ); // Fully cleaned message
$value_for_email = trim( $value );
$value = urldecode( trim( $value ) ); // Fully cleaned message
$value_for_email = trim( $value );

// Email
if ( ! $email && preg_match( "/^\S+@\S+\.\S+$/", $value_for_email ) ) {
$email = $value_for_email;
// Email
if ( ! $email && preg_match( "/^\S+@\S+\.\S+$/", $value_for_email ) ) {
$email = $value_for_email;

// Names
}elseif (preg_match("/name/i", $key)){
// Names
}elseif (preg_match("/name/i", $key)){

preg_match("/(first.?name)?(name.?first)?(forename)?/", $key, $match_forename);
preg_match("/(last.?name)?(family.?name)?(second.?name)?(surname)?/", $key, $match_surname);
Expand Down Expand Up @@ -421,8 +425,8 @@ function cleantalk_check_register(&$regOptions, $theme_vars){
return;

if (
$regOptions['interface'] == 'admin' || // Skip admin
! $modSettings['cleantalk_check_registrations'] // Skip if registrations check are disabled
$regOptions['interface'] == 'admin' || // Skip admin
! $modSettings['cleantalk_check_registrations'] // Skip if registrations check are disabled
)
return;

Expand Down Expand Up @@ -946,15 +950,27 @@ function cleantalk_log($message)
* Logging message into SMF log
* @param string $message
*/
function cleantalk_after_create_topic($message)
{
function cleantalk_after_create_topic( $message ){
global $sourcedir, $modSettings;

if (array_key_exists('cleantalk_email_notifications', $modSettings) && $modSettings['cleantalk_email_notifications'] && $message) {
if(
array_key_exists( 'cleantalk_email_notifications', $modSettings ) &&
$modSettings['cleantalk_email_notifications'] &&
$message
){
require_once($sourcedir . '/Subs-Admin.php');
if (is_array($message))
$message = implode("\n", $message);
emailAdmins('send_email', array('EMAILSUBJECT' => '[Cleantalk antispam for the board]', 'EMAILBODY' => "CleanTalk antispam checking result: \n$message"));

if( is_array( $message ) )
$message = CleantalkHelper::array_implode__recursive( "\n", $message );

emailAdmins(
'send_email',
array(
'EMAILSUBJECT' => '[Cleantalk antispam for the board]',
'EMAILBODY' => "CleanTalk antispam checking result: \n$message",
)
);
}
}
/**
Expand Down Expand Up @@ -1060,7 +1076,8 @@ function cleantalk_load()
'cleantalk_service_id' => isset($result['service_id']) ? $result['service_id'] : '0',
'cleantalk_ip_license' => isset($result['ip_license']) ? $result['ip_license'] : '0',
'cleantalk_account_name_ob' => isset($result['account_name_ob']) ? $result['account_name_ob'] : '',
'cleantalk_last_account_check' => time(),
'cleantalk_last_account_check' => time(),
'cleantalk_errors' => '',
);
updateSettings($settings_array, false);
}
Expand Down Expand Up @@ -1229,7 +1246,7 @@ function cleantalk_buffer($buffer)
return $buffer;

if(isset($_GET['action'], $_GET['area']) && $_GET['action'] == 'admin' && $_GET['area'] == 'modsettings'){
if(strpos($forum_version, 'SMF 2.0')===false){

$html='';
Expand Down Expand Up @@ -1318,7 +1335,7 @@ function cleantalk_buffer($buffer)
if(!empty($api_result['error'])){
$html.='<center>'
.'<div style="border:2px solid red;color:red;font-size:16px;width:300px;padding:5px;">'
.'<b>'.$api_result['error'].'</b>'
.'<b>'.$api_result['error_string'].'</b>'
.'</div>'
.'<br>'
.'</center>';
Expand Down Expand Up @@ -1435,7 +1452,7 @@ function cleantalk_buffer($buffer)
}
else
{
$cleantalk_key_html .= "&nbsp<span style='color: red;'>".$txt['cleantalk_key_not_valid']."</span>";
$cleantalk_key_html .= "&nbsp<span style='color: red;'>".((isset($modSettings['cleantalk_errors']) && !empty($modSettings['cleantalk_errors'])) ? $modSettings['cleantalk_errors'] : $txt['cleantalk_key_not_valid'])."</span>";
$cleantalk_key_html .= "<br><br><a target='_blank' href='https://cleantalk.org/register?platform=smf&email=".urlencode($user_info['email'])."&website=".urlencode($_SERVER['SERVER_NAME'])."&product_name=antispam'>
<input type='button' value='".$txt['cleantalk_get_access_manually']."' />
</a> {$txt['cleantalk_get_access_key_or']} ";
Expand Down
8 changes: 8 additions & 0 deletions cleantalk/cleantalkModAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ function cleantalk_general_mod_settings($return_config = false)
$key_is_valid = true;
$save_key = $result['auth_key'];

} else {
$settings_array['cleantalk_errors'] = $result['error_string'];
updateSettings($settings_array, false);
}
}
$save_key = $key_is_valid ? $save_key : Post::get( 'cleantalk_api_key' );
Expand Down Expand Up @@ -131,6 +134,7 @@ function cleantalk_general_mod_settings($return_config = false)
'cleantalk_ip_license' => isset($result['ip_license']) ? $result['ip_license'] : '0',
'cleantalk_account_name_ob' => isset($result['account_name_ob']) ? $result['account_name_ob'] : '',
'cleantalk_last_account_check' => time(),
'cleantalk_errors' => '',
);

if (Post::get( 'cleantalk_sfw' ) == 1){
Expand All @@ -144,11 +148,15 @@ function cleantalk_general_mod_settings($return_config = false)
}else{
// @ToDo have to handle errors!
// return array('error' => 'KEY_IS_NOT_VALID');
$settings_array['cleantalk_errors'] = 'Key is not valid!';
updateSettings($settings_array, false);
}

}else{
// @ToDo have to handle errors!
// return array('error' => $result);
$settings_array['cleantalk_errors'] = $result['error_string'];
updateSettings($settings_array, false);
}
}
$settings_array['cleantalk_api_key_is_ok'] = ($key_is_ok) ? '1' : '0';
Expand Down
1 change: 0 additions & 1 deletion cleantalk/lib/CleantalkAP/Common/Err.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class Err{

use \CleantalkAP\Templates\Singleton;

static $instance;
public $errors = [];

/**
Expand Down
2 changes: 0 additions & 2 deletions cleantalk/lib/CleantalkAP/Variables/SuperGlobalVariables.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ class SuperGlobalVariables{

use \CleantalkAP\Templates\Singleton;

static $instance;

/**
* @var array Contains saved variables
*/
Expand Down
37 changes: 34 additions & 3 deletions cleantalk/lib/CleantalkHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ static public function api_check_response($result, $method_name = null)
if($result && (isset($result['error_no']) || isset($result['error_message']))){
return array(
'error' => true,
'error_string' => "SERVER_ERROR NO: {$result['error_no']} MSG: {$result['error_message']}",
'error_string' => $result['error_message'],
'error_no' => $result['error_no'],
'error_message' => $result['error_message']
);
Expand Down Expand Up @@ -531,5 +531,36 @@ static function apache_request_headers(){
}
}
return $headers;
}
}
}

/**
* Recuresevly "implodes" array or object
*
* @param $glue
* @param $array
*
* @return string
*/
static function array_implode__recursive( $glue, $array ){

$out = '';

foreach( $array as $item ){

if( is_array( $item ) || is_object( $item ) )
$out .= self::array_implode__recursive( $glue, $item );

else{

// Skip empty strings
if( ! (string) $item )
continue;
else
$out .= (string) $item;

}
}

return $out;
}
}
1 change: 1 addition & 0 deletions install.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
updateSettings(array('cleantalk_sfw' => isset($modSettings['cleantalk_sfw']) ? $modSettings['cleantalk_sfw'] : '0'), false);
updateSettings(array('cleantalk_email_notifications' => isset($modSettings['cleantalk_email_notifications']) ? $modSettings['cleantalk_email_notifications'] : '0'), false);
updateSettings(array('cleantalk_ccf_checking' => isset($modSettings['cleantalk_ccf_checking']) ? $modSettings['cleantalk_ccf_checking'] : '0'), false);
updateSettings(array('cleantalk_errors' => isset($modSettings['cleantalk_errors']) ? $modSettings['cleantalk_errors'] : ''), false);

// Cleantalk's secondary data
updateSettings(array('cleantalk_js_keys' => isset($modSettings['cleantalk_js_keys']) ? $modSettings['cleantalk_js_keys'] : ''), false);
Expand Down
2 changes: 1 addition & 1 deletion modification.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!DOCTYPE modification SYSTEM "http://www.simplemachines.org/xml/modification">
<modification xmlns="www.simplemachines.org/xml/modification">
<id>cleantalk:antispam</id>
<version>2.30</version>
<version>2.32</version>
<file name="$sourcedir/Post.php">
<operation error="fatal">
<search position="after"><![CDATA[createPost($msgOptions, $topicOptions, $posterOptions);]]></search>
Expand Down
41 changes: 38 additions & 3 deletions package-info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<id>cleantalk:antispam</id>
<name>Anti-spam by CleanTalk</name>
<type>modification</type>
<version>2.31</version>
<version>2.32</version>
<install for="2.0 - 2.1.99">
<readme type="file" parsebbc="true">readme.txt</readme>
<readme type="file" parsebbc="true" lang="russian-utf8">readme_russian.txt</readme>
Expand Down Expand Up @@ -491,11 +491,11 @@
</redirect>
</upgrade>
<upgrade from="2.30">
<readme type="inline" parsebbc="true">This upgrade for Antispam by Cleantalk from 2.29 to 2.31 version:
<readme type="inline" parsebbc="true">This upgrade for Antispam by Cleantalk from 2.30 to 2.31 version:
- Setting "Check registration" added.
- Fix for ut8_decode function.
</readme>
<readme type="inline" parsebbc="true" lang="russian-utf8">Обновление Анти-спама от Cleantalk с версии 2.29 до 2.30:
<readme type="inline" parsebbc="true" lang="russian-utf8">Обновление Анти-спама от Cleantalk с версии 2.30 до 2.31:
- Добавлена опция "Проверка регистраций"
- Исправления для функции ut8_decode.
</readme>
Expand All @@ -519,6 +519,41 @@
<!-- Database updates -->
<database>install.php</database>

<redirect url="$boardurl/index.php?action=admin;area=modsettings;sa=cleantalk" type="inline">Please stand by while
you are being redirected to this mod configuration settings.
</redirect>
</upgrade>
<upgrade from="2.31">
<readme type="inline" parsebbc="true">This upgrade for Antispam by Cleantalk from 2.31 to 2.32 version:
- Trait fixes.
- Search requests.
- Fix php notices.
</readme>
<readme type="inline" parsebbc="true" lang="russian-utf8">Обновление Анти-спама от Cleantalk с версии 2.31 до 2.32:
- Ошибки трейта.
- Проверка поиска.
- Исправление php ошибок.
</readme>

<!-- Cleaning up old data -->
<remove-dir name="$sourcedir/cleantalk" />
<create-dir name="cleantalk" destination="$sourcedir"/>

<!-- Copying new source files -->
<require-dir name="cleantalk" destination="$sourcedir">Copying extension files</require-dir>

<!-- Translations -->
<modification format="xml" type="file">modification.xml</modification>
<modification format="xml" type="file">languages/english.xml</modification>
<modification format="xml" type="file">languages/english-utf8.xml</modification>
<modification format="xml" type="file">languages/russian.xml</modification>
<modification format="xml" type="file">languages/russian-utf8.xml</modification>
<modification format="xml" type="file">languages/spanish_es.xml</modification>
<modification format="xml" type="file">languages/spanish_es-utf8.xml</modification>

<!-- Database updates -->
<database>install.php</database>

<redirect url="$boardurl/index.php?action=admin;area=modsettings;sa=cleantalk" type="inline">Please stand by while
you are being redirected to this mod configuration settings.
</redirect>
Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
MOD [b]Anti-spam by CleanTalk[/b]
Version: 2.30
Version: 2.32

Anti-spam by CleanTalk mod with protection against spam bots and manual spam.
No Captcha, no questions, no counting animals, no puzzles, no math.
Expand Down
2 changes: 1 addition & 1 deletion readme_russian.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
MOD [b]Анти-спам от Cleantalk[/b]
Версия: 2.30
Версия: 2.32

Анти-спам от Cleantalk с защитой против автоматического и ручного спама.
Без капчи, без вопросов, без подсчета животных, без паззлов и т.д
Expand Down

0 comments on commit fe1ac7e

Please sign in to comment.