Message Board Basketball Forum - InsideHoops

Go Back   Message Board Basketball Forum - InsideHoops > InsideHoops Main Basketball Forums > Off the Court Lounge

Off the Court Lounge Basketball fans talk about everything EXCEPT basketball here

Reply
 
Thread Tools
Old 11-13-2008, 05:57 PM   #1
loot
H.U.M.A.N. World
 
loot's Avatar
 
Join Date: Jun 2006
Posts: 8,374
Default Helping ISH out: vBulletin Version 3.5.4 IP banning

Let's look at the Admin CP.


Quote:
IP Number Ban Lists: You may ban any IP numbers from registering and posting. Type in the complete IP number (as in 243.21.31.7), or use a partial IP number (as in 243.21.31). The BB will do matches from the beginning of each IP number that you enter. Thus, If you enter a partial IP of 243.21.31, someone attempting to register who has an IP number of 243.21.31.5 will not be able to register. Similarly, if you have an IP ban on 243.21, someone registering who has an IP of 243.21.3.44 will not be able to register. Thus, be careful when you add IPs to your ban list and be as specific as possible. As with the email ban list, put a space between each IP number. The IP Ban prevents anyone with matching IP number from registering and posting.

Enter in the appropriate field in the Admin CP (found under vBulletin options).

To completely ban users, use an .htaccess file.

Quote:
<Limit GET POST>
Allow from all
Deny from 243.21.31.7
Deny from 243.21.31
</Limit>

Advanced IP banning:

The first step is to make the mysql table, this will contain the bans.


Quote:
Code:
CREATE TABLE `banned` (
`id` int(11) NOT NULL auto_increment,
`ip` varchar(255) NOT NULL default '',
`time` varchar(255) NOT NULL default '',
`long` varchar(255) NOT NULL default '',
`reason` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM;

1: For the coding, make the config file:


Quote:
[b]PHP Code:
<?php
// config
$config['host'] = "localhost"; // host name of your mysql server
$config['user'] = "username"; // your mysql username
$config['pass'] = "password"; // your mysql password
$config['db'] = "database"; // the database your table is in.

// the @ sign is an error supressor, meaning we can use our own error messages, this connects and selects db
@mysql_connect("$config[host]","$config[user]","$config[pass]") or die("There was an error connecting to the database, MySql said:<br />".mysql_error()."");
@mysql_select_db("$config[db]") or die("There was an error connecting to the database, MySql said:<br />".mysql_error()."");
?>


That holds the variables, and connects to the database, now you need to do the functions, make a new file and save this file as 'func.ban.php':


Quote:
PHP Code:
<?php
// func.ban.php
// checks the ip to see if it is banned
function checkban($ip)
{
// querys database
$q = mysql_query("SELECT * FROM `banned` WHERE `ip` = '$ip' LIMIT 1");
$get = mysql_num_rows($q);
// if found
if ($get == "1")
{
// deny user access
$r=mysql_fetch_array($q);
die("You have been banned from this website until $r[legnth]. If you feel this is in error, please contact the webmaster.");
}
}
// places a ban in the database
function addban($ip,$reason,$legnth)
{
// get current time
$time = time();
// inserts code into database
$insert = mysql_query("INSERT INTO `banned` (`ip`,`time`,`long`,`reason`) VALUES ('$ip', '$time', '$legnth', '$reason')") or die("Could not add ban.<br />".mysql.error()."");
echo "The ip address, $ip, has been added to the ban list.";
}
// deletes a ban from the database
function delban($id)
{
// runs a delete query
$delete = mysql_query("DELETE FROM `banned` WHERE `id` = '$id' LIMIT 1") or die("Could not remove ban.<br />".mysql.error()."");
echo "The ip address has been removed from the ban list.";
}
// lists the bans in the ban admin
function listbans()
{
// link to add ban
echo "<a href='banadmin.php?x=add'>Add Ban</a><p>";
// loop to show all band
$query = mysql_query("SELECT * FROM `banned` ORDER BY time DESC");
$num = mysql_num_rows($query);
if ($num)
{
while ($r=mysql_fetch_array($query))
{
echo "$r[ip] - $r[reason] - <a href='banadmin.php?x=delete&id=$r[id]'>Delete</a><br />";
}
}
}
?>

Now you have to make the admin panel do this, so make sure to place this in a secured directory.
Save this file as 'banadmin.php'


Quote:
PHP Code:
<?php
// banadmin.php

// include the files
include "config.php";
include "func.ban.php";
// switch statement to do pages in admin
switch ($_GET['x'])
{
// if no page show bans
default:
listbans();
break;
// if add ban, show the form
case "add":
// if posted, insert it
if ($_POST['add'])
{
$ip = $_POST['ip'];
if (!$ip)
{
echo "You must put an ip address at least";
}
addban($ip,$_POST[reason],$_POST[legnth]);
}
// otherwise show form
else
{
echo "Add a ban.<br />";
echo "<form method='post' action='banadmin.php?x=add'>";
echo "IP Address<br /><input type='text' name='ip'><br />";
echo "Reason<br /><input type='text' name='reason'><br />";
echo "Legnth<br /><input type='text' name='legnth'><br />";
echo "<input type='submit' name='add' value='Add Ban'>";
}
break;
// delete ban
case "delete":
// got the id, preform the action
if ($_GET['id'])
{
delban($_GET['id']);
}
// show error
else
{
echo "No ip selected to remove";
}
break;
}
?>

Add that code at the top of the page, before any content is displayed, and it will check for the IP bans.


Quote:
PHP Code:
<?
include "config.php";
include "func.ban.php";
checkban($_SERVER['REMOTE_ADDR']);
?>


With thanks to http://codinghub.com/
loot is offline   Reply With Quote
Old 11-13-2008, 05:59 PM   #2
Richie2k6
Smooth Like Butter
 
Richie2k6's Avatar
 
Join Date: Mar 2007
Posts: 9,903
Default Re: Helping ISH out: vBulletin Version 3.5.4 IP banning

Thank God.. now there are no excuses.
Richie2k6 is offline   Reply With Quote
Old 11-13-2008, 06:00 PM   #3
loot
H.U.M.A.N. World
 
loot's Avatar
 
Join Date: Jun 2006
Posts: 8,374
Default Re: Helping ISH out: vBulletin Version 3.5.4 IP banning

I posted in the main forum already. It seems someone accidently deleted that one!
loot is offline   Reply With Quote
Old 11-13-2008, 06:02 PM   #4
Richie2k6
Smooth Like Butter
 
Richie2k6's Avatar
 
Join Date: Mar 2007
Posts: 9,903
Default Re: Helping ISH out: vBulletin Version 3.5.4 IP banning

Butterfingers... watch out for that delete button, mods. I think they meant to sticky it.
Richie2k6 is offline   Reply With Quote
Old 11-13-2008, 06:02 PM   #5
StroShow4
Certified ISHiot.
 
StroShow4's Avatar
 
Join Date: Jul 2006
Location: NBA247365.COM
Posts: 26,174
Default Re: Helping ISH out: vBulletin Version 3.5.4 IP banning

Quote:
Originally Posted by Richie2k6
Butterfingers... watch out for that delete button, mods. I think they meant to sticky it.

StroShow4 is offline   Reply With Quote
Old 11-13-2008, 07:18 PM   #6
gencbiba
Very good NBA starter
 
gencbiba's Avatar
 
Join Date: Sep 2007
Posts: 8,054
Default Re: Helping ISH out: vBulletin Version 3.5.4 IP banning

Quote:
Originally Posted by Richie2k6
Butterfingers... watch out for that delete button, mods. I think they meant to sticky it.

gencbiba is offline   Reply With Quote
Old 11-13-2008, 07:33 PM   #7
bigboi_baller
NBA rookie of the year
 
bigboi_baller's Avatar
 
Join Date: Jun 2006
Location: Cold side of the pillow
Posts: 6,851
Default Re: Helping ISH out: vBulletin Version 3.5.4 IP banning

I think they tried this but there was a system overload...

bigboi_baller is offline   Reply With Quote
Old 11-13-2008, 07:34 PM   #8
bigkingsfan
Gif-ted
 
bigkingsfan's Avatar
 
Join Date: Jun 2006
Location: Land of 1 NBA Championship*
Posts: 12,842
Default Re: Helping ISH out: vBulletin Version 3.5.4 IP banning

You can still go through proxy.
bigkingsfan is offline   Reply With Quote
Old 11-13-2008, 07:36 PM   #9
bigboi_baller
NBA rookie of the year
 
bigboi_baller's Avatar
 
Join Date: Jun 2006
Location: Cold side of the pillow
Posts: 6,851
Default Re: Helping ISH out: vBulletin Version 3.5.4 IP banning

Quote:
Originally Posted by bigkingsfan
You can still go through proxy.
Been there, done that.

A lot of forums completely ban proxies though.
bigboi_baller is offline   Reply With Quote
Old 11-13-2008, 07:36 PM   #10
Sicknote
National High School Star
 
Sicknote's Avatar
 
Join Date: Jan 2008
Location: 21 Shump St
Posts: 2,015
Default Re: Helping ISH out: vBulletin Version 3.5.4 IP banning

Jeff probably doesn't even give a ****.
Sicknote is offline   Reply With Quote
Old 05-16-2015, 11:14 AM   #11
$LakerGold
#TeamMir #TeamRousey
 
$LakerGold's Avatar
 
Join Date: Apr 2011
Location: Glendale
Posts: 6,076
Default Re: Helping ISH out: vBulletin Version 3.5.4 IP banning

asdasd
$LakerGold is offline   Reply With Quote
This NBA Basketball News Website Sponsored by:
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 06:09 PM.




NBA Basketball Forum Key Links:
InsideHoops Home
NBA Rumors
Basketball Blog
NBA Daily Recaps
NBA Videos
Fantasy Basketball
NBA Mock Draft
NBA Free Agents
All-Star Weekend
---
High School Basketball
Streetball
---
InsideHoops Twitter
Search Our Site















Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2015, Jelsoft Enterprises Ltd. Terms of Use/Service | Privacy Policy