-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheditbannedips.php
More file actions
181 lines (173 loc) · 7.08 KB
/
Copy patheditbannedips.php
File metadata and controls
181 lines (173 loc) · 7.08 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<?php
/************************************************************************/
/* Oscailt */
/* Indepenent Media Centre Content Management System */
/* ==================================================================== */
/* Copyright (c)2003-2005 by Independent Media Centre Ireland */
/* http://www.indymedia.ie */
/* Development List: oscailt@lists.indymedia.org */
/* See contributions.txt for the list of contributors */
/* */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation. http://www.gnu.org/copyleft/gpl.html */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/************************************************************************/
require_once("oscailt_init.inc");
require_once("objects/bannedip.inc");
require_once("objects/adminutilities.inc");
require_once("objects/indyobjects/indydataobjects.inc");
$OSCAILT_SCRIPT = "editbannedips.php";
addToPageTitle("Manage Blocked IP addresses");
function writeBannedIPList()
{
global $ipBanList, $system_config;
$timeMsg = strftime($system_config->default_strftime_format, time() + $system_config->timezone_offset);
?>
<table align=center>
<tr class=admin>
<th class=admin colspan="6">Banned IPs (publish and contact form bans) Total = <?=count($ipBanList->banned_list)?>
<br> <?=$timeMsg?>
</td>
</tr>
<tr class=admin>
<th class=admin> IP Address </th>
<th class=admin> Ban Began </th>
<th class=admin> Ban Expires </th>
<th class=admin> Ban Reason </th>
<th class=admin> Lift Ban </th>
<th class=admin> Change Ban Length </th>
</tr>
<?
foreach($ipBanList->banned_list as $one_ban)
{
$ip = $one_ban->ip;
$reason = htmlspecialchars($one_ban->reason);
// The system offset time has already been added to the ban begin time.
$ban_began = strftime($system_config->default_strftime_format, $one_ban->begin_ban);
$expires = strftime($system_config->default_strftime_format, $one_ban->time_limit + $system_config->timezone_offset);
$lift_str = "<a href='editbannedips.php?subpage=unban&target_ip=$ip'><img src='graphics/delete.gif' /></a>";
$extend_str = "<a href='editbannedips.php?subpage=ban&target_ip=$ip'><img src='graphics/unhide.gif' /></a>";
if (time() > ($one_ban->time_limit + $system_config->timezone_offset))
{
$expires = "<b>Expired: </b>" . $expires;
// $ip = "<i>" . $ip ."</i>";
}
?>
<tr class=admin>
<td class=admin align=center> <?=$ip?> </td>
<td class=admin align=right ><?=$ban_began?></td>
<td class=admin align=right ><?=$expires?></td>
<td class=admin align=center> <?=$reason?> </td>
<td class=admin align=center> <?=$lift_str?> </td>
<td class=admin align=center> <?=$extend_str?> </td>
</tr>
<?
}
?>
<tr>
<td colspan="6" align="center">
<form action="editbannedips.php" method=post>
<input type="hidden" name="subpage" value="ban">
<input type="submit" name="go" value="Ban IP">
<input type="text" name="target_ip" value="">
</form>
</td>
</tr>
</table>
<?
}
ob_start();
if($editor_session->isSessionOpen())
{
writeAdminHeader("editbannedauthors.php","Ban Authors");
if($editor_session->editor->allowedReadAccessTo("editbannedips"))
{
$ipBanList = new BannedIPList();
$ipBanList->load();
if(isset($_REQUEST['subpage']) && isset($_REQUEST['confirm']))
{
$target_ip = cleanseIP($_REQUEST['target_ip']);
if($target_ip === false)
{
writeError("No valid IP Address was input!");
writeBannedIPList();
return;
}
if($editor_session->editor->allowedWriteAccessTo("editbannedips"))
{
if($_REQUEST['subpage']=="unban")
{
$ipBanList->unbanIP($target_ip);
// echo "<P>unban</p>";
$logMsg = $editor_session->editor->editor_name.":\tunban:\tIP:\t" . $target_ip . ":\tban lifted.";
logAction(null, $target_ip, "IP", "unban", "ban lifted");
// logMessage($logMsg,"actionlog.txt");
}
else
{
$time_limit = cleanseNumericalQueryField($_REQUEST['ban_period']);
if($time_limit <= 0)
{
$time_limit = 10000 * 24;
}
$ban_end = time() + ($time_limit * 60 * 60);
$r = trim($_REQUEST['ban_reason']);
if($r == "") $r = "<not specified>";
# If Ban begins not found then it is probably a new ban..
if (strstr($r, "Ban begins") != true )
{
$r = $editor_session->editor->editor_name.": ". "(Ban begins: " . strftime($system_config->default_strftime_format, time() + $system_config->timezone_offset) .") " . $r;
}
else
{
$r = $editor_session->editor->editor_name.": ". $r;
}
$ipBanList->banIP($target_ip, $ban_end, $r);
$logMsg = $editor_session->editor->editor_name.":\tban:\tIP:\t" . $target_ip . ":\t " .$r;
logAction(null, $target_ip, "IP", "ban", $r);
// logMessage($logMsg, "actionlog.txt");
$ipBanList->notifyByEmail($target_ip, $time_limit, $r);
}
}
else
{
$editor_session->writeNoWritePermissionError();
}
writeBannedIPList();
}
else if(isset($_REQUEST['subpage']) && isset($_REQUEST['cancel']))
{
writeBannedIPList();
}
else if(isset($_REQUEST['subpage']))
{
# Go through the list to get the reason.
$reason = "";
if (isset($_REQUEST['target_ip']))
{
foreach($ipBanList->banned_list as $one_ban)
{
if ($_REQUEST['target_ip'] == $one_ban->ip )
{
$reason = htmlspecialchars($one_ban->reason);
break;
}
}
}
writeConfirmBanBox($reason);
}
else
{
writeBannedIPList();
}
}
else $editor_session->writeNoReadPermissionError();
}
else $editor_session->writeNoSessionError();
include_once("adminfooter.inc");
?>