Skip to content

Commit

Permalink
Merge pull request #45 from CleanTalk/dev
Browse files Browse the repository at this point in the history
Update to version 2.31.
  • Loading branch information
safronik authored Mar 27, 2020
2 parents fbe1aa7 + 856e81e commit 20b377c
Show file tree
Hide file tree
Showing 46 changed files with 4,940 additions and 117 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Version 2.31 Mar 04, 2020
------------------------------
- Setting "Check registration" added.
- Fix for ut8_decode function.

Version 2.30 Dec 24, 2019
------------------------------
- Bug fixes and other minor improvements
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.30
* **Version:** 2.31
* **License:** GNU General Public License
* **Compatible with:** SMF 2.0 and up
* **Languages:** English, Russian
Expand Down
4 changes: 2 additions & 2 deletions 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.30';
const VERSION = '2.31';

const SMF_VERSION = '2.0.14'; // for forumPrepare

Expand Down Expand Up @@ -99,7 +99,7 @@ public function versionCheck()
$errors[] = 'Not found version in CHANGELOG';
}
$ctVersion = str_replace('.', '', $version);
if (!preg_match("#'smf-" . preg_quote($ctVersion) . "'\);#m", file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'cleantalkMod.php'))) {
if (!preg_match("#'smf-" . preg_quote($ctVersion) . "'\);#m", file_get_contents( __DIR__ . DIRECTORY_SEPARATOR . '/cleantalk/cleantalkMod.php' ))) {
$errors[] = 'Not found CT_AGENT_VERSION in cleantalkMod.php';
}
if (count($errors)) {
Expand Down
File renamed without changes
32 changes: 17 additions & 15 deletions cleantalkMod.php → cleantalk/cleantalkMod.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,20 @@
* @license GNU/GPL: http://www.gnu.org/copyleft/gpl.html
*/

use CleantalkAP\Variables\Post;

if (!defined('SMF')) {
die('Hacking attempt...');
}

// Fixes for old PHP versions
require_once(dirname(__FILE__) . '/phpFix.php');
require_once(dirname(__FILE__) . '/lib/phpFix.php');

// Base classes
require_once(dirname(__FILE__) . '/Cleantalk.php');
require_once(dirname(__FILE__) . '/CleantalkRequest.php');
require_once(dirname(__FILE__) . '/CleantalkResponse.php');
require_once(dirname(__FILE__) . '/CleantalkHelper.php');
require_once(dirname(__FILE__) . '/CleantalkSFW.php');
// Classes autoloader
require_once(dirname(__FILE__) . '/lib/autoloader.php');

// Common CleanTalk options
define('CT_AGENT_VERSION', 'smf-230');
define('CT_AGENT_VERSION', 'smf-231');
define('CT_SERVER_URL', 'http://moderate.cleantalk.org');
define('CT_DEBUG', false);
define('CT_REMOTE_CALL_SLEEP', 10);
Expand Down Expand Up @@ -422,8 +420,12 @@ function cleantalk_check_register(&$regOptions, $theme_vars){
if (SMF == 'SSI')
return;

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

if ($executed_check_register)
{
$executed_check_register = false;
Expand Down Expand Up @@ -982,7 +984,7 @@ function cleantalk_load()
if(!empty($user_info['is_admin'])){

// Deleting selected users
if(isset($_POST['ct_del_user']))
if(Post::get('ct_del_user'))
{
checkSession('request');

Expand All @@ -991,7 +993,7 @@ function cleantalk_load()

if (isset($db_connection) && $db_connection != false)
{
foreach($_POST['ct_del_user'] as $key=>$value)
foreach(Post::get('ct_del_user') as $key=>$value)
{
$result = $smcFunc['db_query']('', 'delete from {db_prefix}members where id_member='.intval($key),Array('db_error_skip' => true));
$result = $smcFunc['db_query']('', 'delete from {db_prefix}topics where id_member_started='.intval($key),Array('db_error_skip' => true));
Expand All @@ -1001,7 +1003,7 @@ function cleantalk_load()
}

// Deleting all users
if(isset($_POST['ct_delete_all']))
if(Post::get('ct_delete_all'))
{
checkSession('request');

Expand Down Expand Up @@ -1222,12 +1224,12 @@ function cleantalk_buffer($buffer)
{

global $modSettings, $user_info, $smcFunc, $txt, $forum_version, $db_connection;

if (SMF == 'SSI')
return $buffer;

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

$html='';
Expand Down
27 changes: 13 additions & 14 deletions cleantalkModAdmin.php → cleantalk/cleantalkModAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
* @license GNU/GPL: http://www.gnu.org/copyleft/gpl.html
*/

use CleantalkAP\Variables\Post;

if (!defined('SMF')) {
die('Hacking attempt...');
}
Expand Down Expand Up @@ -67,6 +69,7 @@ function cleantalk_general_mod_settings($return_config = false)
$config_vars = array(
array('title', 'cleantalk_settings'),
array('text', 'cleantalk_api_key'),
array('check', 'cleantalk_check_registrations', 'subtext' => $txt['cleantalk_check_registrations']),
array('check', 'cleantalk_first_post_checking', 'subtext' => $txt['cleantalk_first_post_checking_postinput']),
array('check', 'cleantalk_check_personal_messages', 'subtext' => $txt['cleantalk_check_personal_messages_postinput']),
array('check', 'cleantalk_automod', 'subtext' => $txt['cleantalk_automod_postinput']),
Expand Down Expand Up @@ -99,7 +102,7 @@ function cleantalk_general_mod_settings($return_config = false)

}
}
$save_key = $key_is_valid ? $save_key : $_POST['cleantalk_api_key'];
$save_key = $key_is_valid ? $save_key : Post::get( 'cleantalk_api_key' );
if(!$key_is_valid)
{
$result = CleantalkHelper::apbct_key_is_correct($save_key);
Expand All @@ -109,9 +112,10 @@ function cleantalk_general_mod_settings($return_config = false)
{
$result = CleantalkHelper::api_method__notice_paid_till($save_key, preg_replace('/http[s]?:\/\//', '', $_SERVER['HTTP_HOST'], 1));

if (empty($result['error']))
{
if( $result['valid'] ) {
if (empty($result['error'])){

if($result['valid']){

$key_is_ok = true;
$settings_array = array(
'cleantalk_api_key' => ($save_key) ? $save_key : '',
Expand All @@ -128,34 +132,29 @@ function cleantalk_general_mod_settings($return_config = false)
'cleantalk_account_name_ob' => isset($result['account_name_ob']) ? $result['account_name_ob'] : '',
'cleantalk_last_account_check' => time(),
);
if (isset($_POST['cleantalk_sfw']) && $_POST['cleantalk_sfw'] == 1)
{

if (Post::get( 'cleantalk_sfw' ) == 1){
$settings_array['cleantalk_sfw'] = '1';
$settings_array['cleantalk_sfw_last_update'] = time();
$settings_array['cleantalk_sfw_last_logs_sent'] = time();
$sfw = new CleantalkSFW;
$sfw->sfw_update($save_key);
$sfw->send_logs($save_key);
}
}
else
{
}else{
// @ToDo have to handle errors!
// return array('error' => 'KEY_IS_NOT_VALID');
}

}
else
{
}else{
// @ToDo have to handle errors!
// return array('error' => $result);
}
}
$settings_array['cleantalk_api_key_is_ok'] = ($key_is_ok) ? '1' : '0';
updateSettings($settings_array, false);
}



if (isset($_GET['save'])) {
checkSession();
saveDBSettings($config_vars);
Expand Down
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 20b377c

Please sign in to comment.