Skip to content

Commit

Permalink
Release 5.5
Browse files Browse the repository at this point in the history
  • Loading branch information
davydovct committed Dec 21, 2017
2 parents e88f8ed + ae76eb8 commit 85ab5c3
Show file tree
Hide file tree
Showing 13 changed files with 296 additions and 255 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
CleanTalk Antispam extension for phpbb v.3.1.
============================================
## Version 5.4
## Version 5.5

## How to install.
* Follow standard instruction at https://www.phpbb.com/extensions/installing/
Expand Down
6 changes: 3 additions & 3 deletions cleantalk/antispam/acp/cleantalkHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

namespace cleantalk\antispam\acp;

class cleantalkHelper
class CleantalkHelper
{

const URL = 'https://api.cleantalk.org'; // CleanTalk's API url
Expand Down Expand Up @@ -122,7 +122,7 @@ static public function spamCheckCms($api_key, $data, $do_check = true){
$request = array(
'method_name' => 'spam_check_cms',
'auth_key' => $api_key,
'data' => $data
'data' => implode(',',$data),
);

$result = self::sendRawRequest(self::URL, $request);
Expand Down Expand Up @@ -315,4 +315,4 @@ static public function sendRawRequest($url, $data, $isJSON = false, $timeout = 3

return $result;
}
}
}
2 changes: 1 addition & 1 deletion cleantalk/antispam/acp/main_info.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function module()
return array(
'filename' => '\cleantalk\antispam\acp\main_module',
'title' => 'ACP_CLEANTALK_TITLE',
'version' => '5.4',
'version' => '5.5',
'modes' => array(
'settings' => array('title' => 'ACP_CLEANTALK_SETTINGS', 'auth' => 'ext_cleantalk/antispam && acl_a_board', 'cat' => array('ACP_CLEANTALK_TITLE')),
),
Expand Down
73 changes: 39 additions & 34 deletions cleantalk/antispam/acp/main_module.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function main($id, $mode)

if($request->is_set_post('get_key_auto')){

$result = \cleantalk\antispam\acp\cleantalkHelper::getApiKey(
$result = \cleantalk\antispam\acp\CleantalkHelper::getApiKey(
$config['board_email'],
$request->server('SERVER_NAME'),
'phpbb31',
Expand All @@ -67,7 +67,7 @@ function main($id, $mode)
if($savekey != ''){

if(!$key_is_valid){
$result = \cleantalk\antispam\acp\cleantalkHelper::noticeValidateKey($savekey);
$result = \cleantalk\antispam\acp\CleantalkHelper::noticeValidateKey($savekey);
if(empty($result['error'])){
$key_is_valid = $result['valid'] ? true : false;
}
Expand All @@ -84,7 +84,7 @@ function main($id, $mode)

if(!$user_token_is_valid){

$result = \cleantalk\antispam\acp\cleantalkHelper::noticePaidTill($savekey);
$result = \cleantalk\antispam\acp\CleantalkHelper::noticePaidTill($savekey);

if(empty($result['error'])){
$config->set('cleantalk_antispam_show_notice', $result['show_notice']);
Expand Down Expand Up @@ -154,57 +154,62 @@ function main($id, $mode)
include_once($phpbb_root_path . 'includes/functions_user.' . $phpEx);
}
foreach($ct_del_user as $key=>$value){
user_delete('retain', $key);
user_delete('remove', $key);
}
}
if(isset($_GET['check_users_spam'])){
if($request->is_set('check_users_spam')){
$sql = 'UPDATE ' . USERS_TABLE . '
SET ct_marked=0';
$result = $db->sql_query($sql);
$sql = "SELECT *
$sql = "SELECT user_id, username, user_regdate, user_lastvisit, user_ip, user_email
FROM " . USERS_TABLE . "
WHERE user_password<>'';";
WHERE user_password<>''
ORDER BY user_regdate DESC;";
$result = $db->sql_query($sql);

$users = array(0 => array());
$data = array(0 => array());
$cnt = 0;
while($row = $db->sql_fetchrow($result))
{
$users[$cnt][] = array('name' => $row['username'],
'id' => $row['user_id'],
'email' => $row['user_email'],
'ip' => $row['user_ip'],
'joined' => $row['user_regdate'],
'visit' => $row['user_lastvisit'],
);
$users[$cnt][] = array(
'name' => $row['username'],
'id' => $row['user_id'],
'email' => $row['user_email'],
'ip' => $row['user_ip'],
'joined' => $row['user_regdate'],
'visit' => $row['user_lastvisit'],
);
$data[$cnt][]=$row['user_email'];
$data[$cnt][]=$row['user_ip'];

if(sizeof($users[$cnt])>450)
{
$cnt++;
$users[$cnt]=array();
$data[$cnt]=array();
}
}

$db->sql_freeresult($result);

$error="";
for($i=0;$i<sizeof($users);$i++)
{

$result = \cleantalk\antispam\acp\cleantalkHelper::spamCheckCms($config['cleantalk_antispam_apikey'], implode(',',$data[$i]));
$result = \cleantalk\antispam\acp\CleantalkHelper::spamCheckCms($config['cleantalk_antispam_apikey'], $data[$i]);

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

if(!empty($result['error']))
{
if($result['error_string'] == 'CONNECTION_ERROR')
$error = $user->lang('ACP_CHECKUSERS_DONE_3');
else
$error = $result['error_message'];

}else{
}
else
{
foreach($result as $key => $value)
{
if($key === filter_var($key, FILTER_VALIDATE_IP))
Expand All @@ -214,7 +219,7 @@ function main($id, $mode)
$sql = "UPDATE " . USERS_TABLE . "
SET ct_marked=1
WHERE user_ip='".$db->sql_escape($key)."'";
$result = $db->sql_query($sql);
$db->sql_query($sql);
}
}
else
Expand All @@ -224,7 +229,7 @@ function main($id, $mode)
$sql = "UPDATE " . USERS_TABLE . "
SET ct_marked=1
WHERE user_email='".$db->sql_escape($key)."'";
$result = $db->sql_query($sql);
$db->sql_query($sql);
}
}
}
Expand All @@ -241,22 +246,22 @@ function main($id, $mode)
}
}
$start_entry = '0';
if(isset($_GET['start_entry']) && intval($request->variable('start_entry',1)))
$start_entry = strval(intval($request->variable('start_entry',1)));
$on_page = '20';
$end_entry = strval(intval($start_entry) + intval($on_page));
if($request->is_set('start_entry', \phpbb\request\request_interface::GET))
{
$start_entry = $request->variable('start_entry', 1);
}
$on_page = 20;
$sql = 'SELECT COUNT(user_id) AS user_count
FROM ' . USERS_TABLE . '
where ct_marked = 1';
$result = $db->sql_query($sql);
WHERE ct_marked = 1';
$db->sql_query($sql);
$spam_users_count = (int)$db->sql_fetchfield('user_count');

$sql = 'SELECT *
FROM ' . USERS_TABLE . '
where ct_marked = 1
LIMIT '.$start_entry.','.$end_entry.'';
$result = $db->sql_query($sql);
if($request->variable('finish_check', '', false, \phpbb\request\request_interface::GET)!='')
WHERE ct_marked = 1';
$result = $db->sql_query_limit($sql, $on_page, $start_entry);
if($request->variable('finish_check', '', false, \phpbb\request\request_interface::GET) != '')
{
$template->assign_var('CT_ACP_CHECKUSERS_DONE_1', '1');
}
Expand All @@ -276,18 +281,18 @@ function main($id, $mode)
));
}
$db->sql_freeresult($result);
$pages = ceil(intval($spam_users_count) / $on_page);
$pages = ceil($spam_users_count / $on_page);
$server_uri = 'index.php?sid='.$request->variable('sid','1').'&i='.$request->variable('i','1');
if ($pages>1)
{
$pages_str = "<ul><li style='display: inline-block; margin: 10px 5px;'>Pages:</li>";
for($i=1; $pages >= $i; $i++){
$pages_str .= "
<li style='display: inline-block; padding: 3px 5px; background: rgba(23,96,147,".((isset($_GET['curr_page']) && $request->variable('start_entry',1) == $i) || (!isset($_GET['curr_page']) && $i == 1) ? "0.6" : "0.3")."); border-radius: 3px;'>
<li style='display: inline-block; padding: 3px 5px; background: rgba(23,96,147,".(($request->is_set('curr_page', \phpbb\request\request_interface::GET) && $request->variable('start_entry',1) == $i) || (!$request->is_set('curr_page', \phpbb\request\request_interface::GET) && $i == 1) ? "0.6" : "0.3")."); border-radius: 3px;'>
<a href=".$server_uri."&start_entry=".($i-1)*$on_page."&curr_page=$i>$i</a>
</li>";
}
$page_str.="</ul>";
$pages_str.="</ul>";
$template->assign_var('CT_CHECKUSERS_PAGES', $pages_str);
}
if ($found)
Expand Down
2 changes: 1 addition & 1 deletion cleantalk/antispam/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "phpbb-extension",
"description": "Antispam by CleanTalk",
"homepage": "https://cleantalk.org",
"version": "5.4",
"version": "5.5",
"time": "2017-06-07",
"license": "GPL-2.0",
"authors": [
Expand Down
14 changes: 7 additions & 7 deletions cleantalk/antispam/license.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991

Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.

Preamble
Preamble

The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Expand Down Expand Up @@ -56,7 +56,7 @@ patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.

GNU GENERAL PUBLIC LICENSE
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

0. This License applies to any program or other work which contains
Expand Down Expand Up @@ -255,7 +255,7 @@ make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.

NO WARRANTY
NO WARRANTY

11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
Expand All @@ -277,9 +277,9 @@ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.

END OF TERMS AND CONDITIONS
END OF TERMS AND CONDITIONS

How to Apply These Terms to Your New Programs
How to Apply These Terms to Your New Programs

If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
Expand Down
2 changes: 1 addition & 1 deletion cleantalk/antispam/migrations/release_5_4_0.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function revert_schema()
{
return array(
'drop_columns' => array(
phpbb_config_text => array(
$this->table_prefix . 'config_text' => array(
'cleantalk_antispam_js_keys'
)
)
Expand Down
4 changes: 2 additions & 2 deletions cleantalk/antispam/model/Cleantalk.php
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ private function httpRequest($msg) {
|| $this->stay_on_server == true) {

$url = (!empty($this->work_url)) ? $this->work_url : $this->server_url;

$result = $this->sendRequest($msg, $url, $this->server_timeout);
}

Expand Down Expand Up @@ -721,7 +721,7 @@ static function apache_request_headers(){

$_SERVER = $request->get_super_global(\phpbb\request\request_interface::SERVER);

$to_return = array();
$headers = array();
foreach($_SERVER as $key => $val){
if(preg_match('/\AHTTP_/', $key)){
$server_key = preg_replace('/\AHTTP_/', '', $key);
Expand Down
Loading

0 comments on commit 85ab5c3

Please sign in to comment.