This repository has been archived by the owner on Oct 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplugin.php
56 lines (43 loc) · 1.57 KB
/
plugin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
// Copyright 2013-2014 Joshua Rüsweg
// This file is part of esoTalk. Please see the included license file for usage information.
if (!defined('IN_ESOTALK')) exit;
ET::$pluginInfo['StopForumSpam'] = array(
'name' => 'StopForumSpam',
'description' => 'Suspends a member if the member is listed in StopForumSpam',
'version' => '1.0.1',
'author' => 'Joshua Rüsweg',
'authorEmail' => '[email protected]',
'authorURL' => 'http://esotalk.org/forum/member/928-josh',
'license' => 'GPLv2'
);
class ETPlugin_StopForumSpam extends ETPlugin {
const APIDOMAIN = 'http://www.stopforumspam.com/api';
public function handler_memberModel_createAfter($sender, $values)
{
// check wheater the user is a spammer
$email = $values['email'];
$ip = $_SERVER['REMOTE_ADDR'];
$query_string = 'ip='.$ip.'&email='.trim($email).'&f=json';
$result = $this->request($query_string);
$result = json_decode($result, true);
if (is_array($result) && isset($result['success']) && $result['success'] == 1) {
unset($result['success']);
foreach ($result AS $value) {
if (isset($value['appears']) && $value['appears'] > 0) {
// suspend
ET::memberModel()->setGroups(ET::memberModel()->getById($values['memberId']), ACCOUNT_SUSPENDED);
return;
}
}
}
}
public function request($query_string) {
$curl = curl_init(self::APIDOMAIN.'?'.$query_string);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_USERAGENT, 'CURL (StopForumSpam; EsoTalk/'.ESOTALK_VERSION.')');
$res = curl_exec($curl);
curl_close($curl);
return $res;
}
}