<?php session_start();  //Developed by ITechScripts
?>
<?
if(strlen($_SESSION["adminuser"])==0)
{
//echo '<meta http-equiv="refresh" content="0; url=index.php">';
//exit();
}
require 'include/configurations.php'; // ITECHBIDS Configuration File

$mode=$_GET['mode'];
$id=$_GET['id'];
if($mode=='revoke') {
	$del_sql="delete from blocked_domain where block_id=$id";
	$del_res=mysql_query($del_sql);
}

if(isset($_POST['btn_Block'])) {
	$ip=$_POST['txtIP'];
	if($ip=='') $ip_flag=1;
	if($ip_flag!=1) {
		$chk_sql="select * from  blocked_domain where  blocked_domain='$ip'";
		$chk_res=mysql_query($chk_sql);
		if(mysql_num_rows($chk_res)<=0) {
			 $up_sql="insert into blocked_domain(blocked_domain) values('$ip')";
			$up_res=mysql_query($up_sql);
			if($up_res) $suc_flag=1;
			else $err_flag=1;
		}
		else {
			$dup_ip=1;
		}
	}
}
?>

<style type="text/css">
<!--
.style1 {
	color: #666666;
	font-weight: bold;
}
-->
</style><?php
require 'include/header.php';
?>
<br>
<table border="0" align="center" cellpadding="5" cellspacing="2" width="80%">
<tr>
<td valign="top">
<table border="0" align="center" width="100%" cellpadding="5" cellspacing="2" class="ft">
<form name="frmBlock" action="domainblock.php" method="post"  onsubmit="return per();">
<?
	if($ip_flag==1) {
?>
<tr >
<td><font color="red">Please Fill the Information denoted in Red</font></td>
</tr>
<?	
	}
	if($dup_ip==1) {
?>
<tr >
<td><font color="red">The domain you have entered has been already blocked by you</font></td>
</tr>
<?
	}
	if($suc_flag==1) {

 ?>
<tr >
<td><font color="red">Domain  Blocked </font></td>
</tr>
<?
	}
	if($err_flag==1) {
?>
<tr >
<td><font color="red">There is a Problem in Blocking in the domain this time, Please try again Later</font></td>
</tr>
<?
	}
?><tr class="ct"><td>Please Enter the domain you like to Block</td></tr>
<tr ><td align="center"><input type="text" class="bluetext"name="txtIP" ></td>
</tr>
<tr ><td colspan="2" align="center"><input type="submit" class="button"   name="btn_Block" value=" Block " ></td></tr>
</form>
</table>
</td>
</tr><TR>
<td valign="top">
<table border="0" align="center" cellpadding="5" cellspacing="2" width="100%" class="ft">
<tr >
<td colspan="3" class="ct" height="25">Block domain Address</td>
</tr>
<tr >
<td colspan="3">You have Already Blocked the Following domain's</td>
</tr>
<?
	$sel_query="select * from blocked_domain";
	$sel_result=mysql_query($sel_query);
	$sno=1;
?>
<tr >
<td>S.no</td>
<td>Blocked domain</td>
<td>Status</td>
</tr>
<?
	if(mysql_num_rows($sel_result)>0) {
	while($sel_row=mysql_fetch_array($sel_result)) {
?>
<tr >
<td><?=$sno?></td><td><?=$sel_row['blocked_domain']?></td><td><a href="domainblock.php?mode=revoke&id=<?=$sel_row['block_id']?>" onClick="return condel();">Allow this domain</a></td>
</tr>
<?
	$sno+=1;
	}
	}
	else {
?>
<tr ><td colspan="3" align="center">You have not Blocked any domain yet</td></tr>
<?
	}
?>
</table>
</td></tr>
</table>
<?
	require 'include/footer.php';
?>
<script language="javascript">
function condel() {
	a=confirm("Are you Sure to Allow this domain to Access your Site");
	return a;
}
function per() {
	a=confirm("you want to send email to Existing User to change their email id, Who are registered with this domain email-id");
/*	if(a)
	{
		b=prompt("Please Enter how many days before the user need to submit their alter mail id","0")
		return b;
	}
	else
	{*/
//	alert(a);
	return a;
//	}
}
</script>