Login
Username: Password:
Remember me

[Sign Up] / [Recover Password]

Theme / Language

Popular
New Torrents
new name
Size: 18.40 MB
Most active
new name
S: 74 L: 3
New Posters
[ADDON] IP Bans
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / v2.08 / v2 Only Mods Complete

Unknown User
2008-09-15 16:59:40
ALTER TABLE `bans` ADD UNIQUE `first_last1` ( `first` , `last` );


backend/functions.php, find:

/*	$nip = ip2long($ip);

$res = mysql_query("SELECT * FROM bans WHERE $nip >= first AND $nip <= last")  or die(mysql_error());

if (mysql_num_rows($res) > 0)

{

 $row = mysql_fetch_array($res);

 header("HTTP/1.0 403 Forbidden");

 print("<html><head><title>Forbidden</title></head><body><h1>Forbidden</h1>Unauthorized IP address.<br />Reason for banning: " . $row["comment"] . "</body></html>\n");

 die;

}*/
replace with:


	$nip = ip2long($ip);

$res = mysql_query("SELECT * FROM bans WHERE $nip >= first AND $nip <= last")  or die(mysql_error());

if (mysql_num_rows($res) > 0)

{

 $row = mysql_fetch_array($res);

 header("HTTP/1.0 403 Forbidden");

 print("<html><head><title>Forbidden</title></head><body><h1>Forbidden</h1>Unauthorized IP address.<br />Reason for banning: " . $row["comment"] . "</body></html>\n");

 die;

}





admincp.php, find:



<td align="center"><a href=admincp.php?action=style><img src="images/admin/themes.gif" border=0 width=32 height=32><BR>Theme Management</a><BR></td>



add after:



<td align="center"><a href=admincp.php?action=ipbans><img src="images/admin/blocked.gif" border=0 width=32 height=32><BR>Banned IPs</a><BR></td>





add before the last ?>:



if ($action == "ipbans") {

stdhead("Banned IPs");

navmenu();



if ($do == "del") {

$delids = implode(", ", array_map("intval", $_POST["delids"]));

$res = mysql_query("SELECT * FROM bans WHERE id IN ($delids)");

while ($row = mysql_fetch_assoc($res)) {

mysql_query("DELETE FROM bans WHERE id=$row[id]");

write_log("IP Ban (".long2ip($row["first"])." - ".long2ip($row["last"]).") was removed by $CURUSER[id] ($CURUSER[username])");

}

show_error_msg("Success", "Ban(s) deleted.", 0);

}



if ($do == "add") {

$first = trim($_POST["first"]);

$last = trim($_POST["last"]);

$comment = trim($_POST["comment"]);

if ($first == "" || $last == "" || $comment == "")

show_error_msg("Error", "Missing form data. Go back and try again", 1);

$first = ip2long($first);

$last = ip2long($last);

if ($first == -1 || $last == -1)

show_error_msg("Error", "Bad IP address.");

$comment = sqlesc($comment);

$added = sqlesc(get_date_time());

mysql_query("INSERT INTO bans (added, addedby, first, last, comment) VALUES($added, $CURUSER[id], $first, $last, $comment)");

switch (mysql_errno()) {

case 1062:

show_error_msg("Error", "Duplicate ban.", 0);

break;

case 0:

show_error_msg("Success", "Ban added.", 0);

break;

default:

show_error_msg("Error", "Database error: ".htmlspecialchars(mysql_error()), 0);

}

}



begin_frame("Banned IPs", "center");

echo "<p align=\"justify\">This page allows you to prevent individual users or groups of users from accessing your tracker by placing a block on their IP or IP range.<BR>

If you wish to temporarily disable an account, but still wish a user to be able to view your tracker, you can use the 'Disable Account' option which is found in the user's profile page.</p><BR>";



$count = get_row_count("bans");

if ($count == 0)

print("<b>No Bans Found</b><br />\n");

else {

list($pagertop, $pagerbottom, $limit) = pager(50, $count, "admincp.php?action=ipbans&"); // 50 per page

echo $pagertop;



echo "<form action='admincp.php?action=ipbans&do=del' method='POST'><table border=1 cellspacing=0 cellpadding=5 align=center class=ttable_headinner>

<tr>

<td class=ttable_head>".DATE_ADDED."</td>

<td class=table_head align=left>First IP</td>

<td class=ttable_head align=left>Last IP</td>

<td class=ttable_head align=left>".ADDED_BY."</td>

<td class=ttable_head align=left>Comment</td>

<td class=ttable_head>Del?</td>

</tr>";



$res = mysql_query("SELECT bans.*, users.username FROM bans LEFT JOIN users ON bans.addedby=users.id ORDER BY added $limit");

while ($arr = mysql_fetch_assoc($res)) {

$arr["first"] = long2ip($arr["first"]);

$arr["last"] = long2ip($arr["last"]);

echo "<tr>

<td align=center class=ttable_col1>".date('d/m/Y<\B\R>H:i:s', utc_to_tz_time($arr["added"]))."</td>

<td align=center class=ttable_col2>$arr[first]</td>

<td align=center class=ttable_col1>$arr[last]</td>

<td align=center class=ttable_col2><a href='account-details.php?id=$arr[addedby]'>$arr[username]</a></td>

<td align=center class=ttable_col1>$arr[comment]</td>

<td align=center class=ttable_col2><input type='checkbox' name='delids[]' value='$arr[id]'></td>

</tr>";

}

echo "</table><BR><input type='submit' value='Delete Checked'>&nbsp;<input type='button' onclick='this.value=check(form)' value='Check All'></form>";

echo $pagerbottom;

}



echo "<BR><BR>";

begin_frame("Add Ban", "center");

print("<table border=1 cellspacing=0 cellpadding=5>\n");

print("<form method=post action=admincp.php?action=ipbans&do=add>\n");

print("<tr><td class=rowhead>First IP</td><td><input type=text name=first size=40></td>\n");

print("<tr><td class=rowhead>Last IP</td><td><input type=text name=last size=40></td>\n");

print("<tr><td class=rowhead>Comment</td><td><input type=text name=comment size=40></td>\n");

print("<tr><td colspan=2><input type=submit value='Okay' class=btn></td></tr>\n");

print("</form>\n</table>\n");

end_frame();



end_frame();

stdfoot();

}



Untested but should work properly, if someone can confirm it works i'll move it Mods Complete (and probably add it to SVN).

Added to SVN (R195) and v2.05+
Unknown User
2011-03-30 15:18:42
i have  a question here . if i want to bann a single ip thn how i will put it in? i mean in which field?  like - if a ip is 98.85.76.125

thn what i will put in 1st range and what in last range?
Unknown User
2011-03-30 16:28:34
"buzz_me, post: 71712":
i have  a question here . if i want to bann a single ip thn how i will put it in? i mean in which field?  like - if a ip is 98.85.76.125thn what i will put in 1st range and what in last range?


Hi,

you have to put in first and last 98.85.76.125

that how i do it for single ip
Unknown User
2011-09-03 18:12:08
I have an issue the ip ban not working when I put the ip and it will register other than what it was to be registered

v2.06

03/09/2011

17:41:14 127.255.255.255 127.255.255.255
Unknown User
2011-09-04 00:01:18
are you banning a range or a single ip ?
Users online

No users online

Search



Statistics

    Torrents

  • Tracking: 3
  • Todays torrents: 0
  • Seeders: 0
  • Leechers: 0
  • Peers: 0
  • Downloaded: 89.96 GB
  • Uploaded: 9.86 GB

  • Members

  • We have: 838
  • New today: 0
  • Guest today: 9

  • Online

  • Total online: 1
  • Members: 0
  • Guests online: 1
  • Comments: 3
  • Messages: 1,728