View Full Version : Wouldn't it be nice if...


Phillip
12-12-2005, 05:56 AM
Ok so dunno if you can already do this but i was thinking wouldn't it be nice to ban someone's ip for 2hours 3 hours 4 hours etc?

harmor
12-12-2005, 08:11 AM
It's possible.

putnamehere
12-12-2005, 03:12 PM
Yes it would be nice, whats your question?

maztrin
12-12-2005, 04:04 PM
y wood u want to do that though?

do u want to be banned?

Phillip
12-12-2005, 05:03 PM
y wood u want to do that though?

do u want to be banned?

Because if you just wanted to ban someone for say 2 hours it would mean you having to upload the program you ban with to take them off also is there a way of giving each user you've banned a different alert i'll get an example leter

Douglas
12-12-2005, 07:33 PM
Here is an example using PHP/MySQL:


<?php
// page.php
$servername="YOUR SERVERNAME";
$dbusername="YOUR DBUSERNAME";
$dbpassword="YOUR DBPASSWORD";
$dbname="YOUR DBNAME";
@mysql_connect("$servername","$dbusername","$dbpassword") or die(mysql_error());
@mysql_select_db("$dbname");
$ip=$_SERVER['REMOTE_ADDR'];
$current_time=time();
$result=mysql_query("SELECT * FROM table WHERE ip='$ip'") or die(mysql_error());
$row=mysql_fetch_array($result);
if ($row['id'] == "") {
if ($row['time'] < $time) {
echo "You are banned!";
}
else {
mysql_query("DELETE FROM table WHERE ip='$ip'") or die(mysql_error());
echo "You are not banned!";
}
}
else {
echo "You are banned!";
}
?>


and this is something you would use to block them:


<?php
//
// page2.php
// change the next variable to whatever you want
//
$num_hours=4;
$servername="YOUR SERVERNAME";
$dbusername="YOUR DBUSERNAME";
$dbpassword="YOUR DBPASSWORD";
$dbname="YOUR DBNAME";
@mysql_connect("$servername","$dbusername","$dbpassword") or die(mysql_error());
@mysql_select_db("$dbname");
$ip=$_POST['ip'];
$process=$_POST['process'];
if ($process == "yes") {
$time=time();
$time_b=time()+(3600*$num_hours);
mysql_query("INSERT INTO table (ip,time) VALUES('$ip','$time_b')") or die(mysql_error());
?>
Successful.
<?php
}
else {
?>
<form action="page2.php" method="post">
<input type="hidden" name="process" value="yes" />
IP Address: <input type="text" name="ip" /><br /><br />
<input type="submit" value="Go" />
</form>
<?php
}
?>