Upcoming IP-ban PHP script

09/01/2009 23:53 janvier123#16
ipban script for your website is easy, here's a bit code

PHP Code:
<?
echo '<table align="center" class="content" cellspacing="0" cellpadding="0">
<tr>
<td>'
;
if (
$_GET['do'] == "add"){
if (
$_POST['ip'] == ""){
echo 
'<center><strong>Please set an IP.</strong></center>';
} else {
$ip $_POST['ip'];
$query mssql_query("SELECT * FROM site_ipban WHERE ip = '".$ip."'");
while(
$r mssql_fetch_array($query)){
$excist 1;
}
if (
$excist == 1){
echo 
'<center><strong>The IP is already banned.</strong></center>';
} else {
mssql_query("INSERT INTO site_ipban (ip) VALUES ('".$ip."')");
echo 
'<center><strong>The IP is banned.</strong></center>';
}
}
}
if (
$_GET['do'] == "remove"){
mssql_query("DELETE FROM site_ipban WHERE id = '".$_GET['id']."'");
echo 
'<center><strong>The IP is deleted.</strong></center>';
}
echo 
'<table align="center" width="150">
<tr><td width="100"><strong>IP:</strong></td><td></td></tr>'
;
$query mssql_query("SELECT * FROM site_ipban");
while(
$r mssql_fetch_array($query)){
echo 
'<tr><td>'.$r['ip'].'</td><td><a href="?site=ipban&do=remove&id='.$r['id'].'">Remove</a></td></tr>';
}
echo 
'</table>
<center><form method="post" action="?site=ipban&do=add">'
;
echo 
'<br />IP: <input type="text" name="ip" /><br />
<input type="submit" value="Add" /></form></center>
</td>
</tr>
</table><br />'
;
?>

PHP Code:
<?
include("iplist.php"); 
if(
in_array($_SERVER['REMOTE_ADDR'], $ip)) {
exit(
"You are banned from this site."); 

?>
09/02/2009 19:17 lelothebest#17
go ahead it will be amazing ...
09/02/2009 19:25 Zombe#18
I still have to download the SQL itself, SP4, all databases, restore it, test it and make it retard friendly, if you know what I mean...
PHP Code:
mysql_connect("localhost""root""exapmple123") or die(mysql_error()); // your IP, account and password
mysql_select_db("server") or die(mysql_error()); //your database's name 

And my method adds the IP to the user_account table when a user registers, however I didn't get a regpage to work yet, it just reloads itself... So yeah, a lot of work before I can release it.