forked from fluxbb/fluxbb
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.php
More file actions
133 lines (102 loc) · 3.37 KB
/
config.php
File metadata and controls
133 lines (102 loc) · 3.37 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<?php
$db_type = 'mysqli';
$db_host = 'localhost';
$db_name = '';
$db_username = '';
$db_password = '';
$db_prefix = '';
$p_connect = false;
$cookie_name = 'punbb_cookie';
$cookie_domain = '';
$cookie_path = '/';
$cookie_secure = 0;
$cookie_seed = '';
$language = 'en';
define('PUN', 1);
//define('PUN_DEBUG', true);
define('PUN_NEW_MEMBER', 5);
include dirname(dirname(__FILE__)) . '/vendor/autoload.php';
function TextpatternForumSfs()
{
global $db_host, $db_name, $db_username, $db_password, $db_prefix;
$ip = $_SERVER['REMOTE_ADDR'];
$since = time() - 3600*24*60;
$user = $email = '';
$action = false;
if (strpos($_SERVER['REQUEST_URI'], 'register.php') !== false && isset($_POST['req_user']) && isset($_POST['req_email1']))
{
$user = (string) $_POST['req_user'];
$email = (string) $_POST['req_email1'];
$action = 'register';
}
if (isset($_POST['form_sent']) && isset($_GET['action']) && $_GET['action'] === 'in' && isset($_POST['req_username']))
{
$action = 'login';
$user = $_POST['req_username'];
}
if (!$action)
{
return;
}
$pdo = new PDO('mysql:dbname='.$db_name.';host='.$db_host, $db_username, $db_password);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// Fetch user details.
if ($action === 'login')
{
$sth = $pdo->prepare("SELECT group_id, email FROM {$db_prefix}users WHERE username = :username");
$sth->execute(array(':username' => $user));
$r = $sth->fetch();
if (!$r || $r['group_id'] != 0)
{
return;
}
$email = $r['email'];
}
// Check if the user is already banned.
$sth = $pdo->prepare("SELECT ip FROM {$db_prefix}bans WHERE ((ip != '' and ip = :ip) or (email != '' and email = :email)) and IFNULL(expire, :expires) >= :expires limit 1");
$sth->execute(array(
':ip' => $ip,
':email' => $email,
':expires' => time(),
));
if ($sth->rowCount())
{
return;
}
// Get records from StopForumSpam database.
$data = file_get_contents('http://www.stopforumspam.com/api?f=json&unix&ip='.urlencode($ip).'&email='.urlencode($email).'&username='.urlencode($user), false, stream_context_create(array('http' => array('timeout' => 15))));
if (!$data)
{
return;
}
$data = json_decode($data);
if (!$data || empty($data->success))
{
return;
}
// Add new bans to the database.
if ($ip && isset($data->ip) && $data->ip->appears && $data->ip->lastseen >= $since)
{
$pdo->prepare("INSERT INTO {$db_prefix}bans SET ip = :ip, message = :message, expire = :expires")->execute(array(
':ip' => $ip,
':message' => 'IP address found in StopForumSpam database.',
':expires' => strtotime('+2 month'),
));
@unlink(__DIR__ . '/cache/cache_bans.php');
}
if ($email && isset($data->email) && $data->email->appears && $data->email->lastseen > $since)
{
$pdo->prepare("INSERT INTO {$db_prefix}bans SET email = :email, message = :message")->execute(array(
':email' => $email,
':message' => 'Email address found in StopForumSpam database.',
));
@unlink(__DIR__ . '/cache/cache_bans.php');
}
}
try
{
TextpatternForumSfs();
}
catch (Exception $e)
{
}