Location: PHPKode > scripts > PHP bans and trap > php-bans-and-trap/index.example.php
<?php
require_once('data/class.ban_embed_sql.php'); // include bans class file
$bans = new Ban_Control(); // call the class
$banarray = array(
				'proxy_check' => 1,
				'robot_check' => 0,
				'ban_check' => 1
		 );
$bans->Ban($banarray); // check and do the bans
echo '<html><head>';
echo '<title>php bans and robot trap system demo</title>';
echo '</head><body>';
echo '<h1>php bans and robot trap system demo</h1>';
echo '<p><a href="'.$bans->List_Link.'">List</a></p>';
echo '<p><a href="'.$bans->Create_Link.'">Create</a></p>';

if(isset($_GET['list'])){
	echo $bans->Ban_List();
}
if(isset($_GET['info'])){
if(!empty($_GET['info'])){
	echo '<br />ID: '.$bans->Ban_Info($_GET['info'], 'id');
	echo '<br />IP: '.$bans->Ban_Info($_GET['info'], 'ip');
	echo '<br />Hostname: '.$bans->Ban_Info($_GET['info'], 'host');
	echo '<br />last refer: '.$bans->Ban_Info($_GET['info'], 'last_ref');
	echo '<br />last url visted: '.$bans->Ban_Info($_GET['info'], 'last_url');
	echo '<br />last agent used: '.$bans->Ban_Info($_GET['info'], 'last_agent');
	echo '<br />reason for ban: '.$bans->Ban_Info($_GET['info'], 'reason');
	echo '<br />date Banned: '.$bans->Ban_Info($_GET['info'], 'add_date2');
	echo '<br />attempts made: '.$bans->Ban_Info($_GET['info'], 'attempts');
	echo '<br />last attempt: '.$bans->Ban_Info($_GET['info'], 'last_attempt');
	echo '<br />expiry time: '.$bans->Ban_Info($_GET['info'], 'expiry').' days';
	}else{
	echo 'Error: no ban id selected, Please return and select a ban id to get ban information';
	}
}
if(isset($_GET['remove'])){
if(!empty($_GET['remove'])){
if($bans->Ban_Destroy($_GET['remove'])){
	echo 'Ban Deleted';
	}
	}else{
	echo 'Error: no ban id selected, Please return and select a ban id to remove a ban';
	}
}
if(isset($_GET['update'])){
if(!empty($_GET['update'])){
	if(isset($_POST['edit'])){
		$bans_array = array(
						'id' => $_GET[update],
						'expiry' => $_POST[expiry],
						'ip' => $_POST[ip],
						'host' => $_POST[host],
						'reason' => $_POST[reason]
						);
if($bans->Ban_Update($bans_array)){
	echo 'Ban Updated';
	}
	}else{
	echo $bans->Ban_Update_Form($_GET['update']);
	}
	}else{
	echo 'Error: no ban id selected, Please return and select a ban id to update a ban';
	}
}
if(isset($_GET['create'])){
if(isset($_POST['add'])){
	$bans_array = array(
						'expiry' => $_POST[expiry],
						'ip' => $_POST[ip],
						'host' => $_POST[host],
						'reason' => $_POST[reason]
						);
if($bans->Ban_Create($bans_array)){
	echo 'Ban Added';
	}
	}else{
	echo $bans->Ban_Create_Form();
}
}
?>
</body></html>
Return current item: PHP bans and trap