<?php
session_start();

include("config.inc.php");

$connection = mysql_connect($config['dbServer'],$config['dbUser'],$config['dbPass']) or die("Could not connect to DB");
mysql_select_db($_SESSION['dbName'],$connection) or die("Could not find DB");


$query1="select grid_color1,grid_color2 from setup";
$result1=mysql_query($query1,$connection) or die(mysql_error());
while($rows=mysql_fetch_array($result1)){
	extract($rows);
}


$str   = $_GET['str']; if ($str == ""){$str = $_POST["str"];}
$post  = $_GET['post'];if ($post == ""){$post = $_POST["post"];}

$Pkeyword  = $_POST["Pkeyword"]; if ($Pkeyword == ""){$Pkeyword = $_GET["Pkeyword"];}  




?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>List of IP</title>
<script type="text/javascript" language="javascript">

function clearform()
{
  document.form1.Pkeyword.value='';
  document.form1.action='List_IP_Address.php';
  document.form1.submit();

}
</script>
<style type="text/css">
<!--
body,td,th {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 14px;
}
.style1 {
	color: #333333;
	font-weight: bold;
}
.style2 {
	color: #999999;
	font-weight: bold;
}
.style3 {color: #999999}
-->
</style></head>

<body>
<form id="form1" name="form1" method="post" action="">
  <table width="800" border="0" align="center">
    <tr>
      <th colspan="5" bgcolor="#DDDDDD"><span class="style1"> IP Address</span></th>
    </tr>
    <tr>
      <td bgcolor="#DDDDDD"> <span style="font-size: 11px; color: #999999; font-weight: bold;">Search for IP Address <br> </span></td>
      <td bgcolor="#DDDDDD" colspan=4><input type="text" name="Pkeyword" value="<?php echo $Pkeyword; ?>"  />
        <input name="code1" type="hidden" id="code1"  value="<?php echo $_GET['lcode']; ?> ">
        <input name="ipaddressid" type="hidden" id="ipaddressid"  value="<?php echo $_GET['ipaddressid']; ?>">
        <input name="IPAddress_UpLoad" type="hidden" id="IPAddress_UpLoad"  value="<?php echo $_GET['IPAddress_UpLoad']; ?>">
        <input name="IPAddress_DownLoad" type="hidden" id="IPAddress_DownLoad"  value="<?php echo $_GET['IPAddress_DownLoad']; ?> ">
        <input name="IPAddress_Amount" type="hidden" id="IPAddress_Amount"  value="<?php echo $_GET['IPAddress_Amount'];?>">
        <input name="Currency_Code" type="hidden" id="Currency_Code"  value="<?php echo $_GET['Currency_Code']; ?> ">
	   <input name="str" type="hidden"   value="<?php echo $str; ?>">
	
	    <input type="submit" name="Submit" value="Find" style=' background-color:#4069A7; color:#FFFFFF;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px;'/>
		<input type="button" name="cancelbtn" value="Cancel" onclick='clearform();'style=' background-color:#4069A7; color:#FFFFFF;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px;'/></td>
   
    </tr>
<?php if($post=="1") { ?>
	
		
<script type="text/javascript" language="javascript">

var s=document.form1.str.value;



if(document.form1.str.value=='1'){
	
	
	opener.document.clientdt.Clientip_IP.value=document.form1.ipaddressid.value;
	opener.document.clientdt.upload_ip.value=document.form1.IPAddress_UpLoad.value;
	opener.document.clientdt.download_ip.value=document.form1.IPAddress_DownLoad.value;
	opener.document.clientdt.clientip_amount.value=document.form1.IPAddress_Amount.value;
	opener.document.clientdt.currencyip.value=document.form1.Currency_Code.value;
}

self.close();

</script>
<?php } ?>
    <tr bgcolor="#E5E5E5">
      <td width="136"><span class="style2">IP Address </span></td>
      <td width="136" colspan="1"><span class="style2">Upload  </span></td>
      <td width="136" colspan="1"><span class="style2">Download  </span></td>
      <td width="136" colspan="1"><span class="style2">Amount  </span></td>
      <td width="136" colspan="1"><span class="style2">Currency  </span></td>
  
    </tr>
<?php
$query1=" select IPAddress_ID,IPAddress_UpLoad,IPAddress_DownLoad,IPAddress_Amount,Currency_Code ".
		" from ipaddress";
		
		$query1=$query1." where (IPAddress_ID like"."('%".$Pkeyword."%') or Code like"."('%".$Pkeyword."%') or IPAddress_UpLoad like"."('%".$Pkeyword."%') 
		
						or IPAddress_DownLoad like"."('%".$Pkeyword."%') or IPAddress_Amount like"."('%".$Pkeyword."%'))
		 order by IPAddress_ID";
	

		
//echo$query1;
$result1=mysql_query($query1,$connection) or die(mysql_error());
while($rows=mysql_fetch_array($result1)){


$ct+=1;

if($ct%2==0)
{
	$Color="style='color:#0000FF;background-color:".$grid_color1."'";
	
	}else{
		
	$Color="style='color:#0000FF;background-color:".$grid_color2."'";	
}

?>
    <tr <?php echo $Color; 
	
	
	?>>
	
	 <?php
		//$desc=ereg_replace("'","%27",$rows[1]);
		?>
		
		
      <td align="left"><a href="List_IP_Address.php?str=<?php echo $str; ?>&post=1&lcode=<?php echo $rows[0]; ?>&IPAddress_UpLoad=<?php echo $rows[1]; ?>&IPAddress_DownLoad=<?php echo $rows[2]; ?>&IPAddress_Amount=<?php echo $rows[3]; ?>&Currency_Code=<?php echo $rows[4]; ?>&ipaddressid=<?php echo $rows[0]; ?>"><?php echo $rows[0]; ?></a></td>
      <td colspan="1"><a href="List_IP_Address.php?str=<?php echo $str; ?>&post=1&lcode=<?php echo $rows[0]; ?>&IPAddress_UpLoad=<?php echo $rows[1]; ?>&IPAddress_DownLoad=<?php echo $rows[2]; ?>&IPAddress_Amount=<?php echo $rows[3]; ?>&Currency_Code=<?php echo $rows[4]; ?>&ipaddressid=<?php echo $rows[0]; ?>"><?php echo $rows[1]; ?></a></td>
      <td colspan="1"><a href="List_IP_Address.php?str=<?php echo $str; ?>&post=1&lcode=<?php echo $rows[0]; ?>&IPAddress_UpLoad=<?php echo $rows[1]; ?>&IPAddress_DownLoad=<?php echo $rows[2]; ?>&IPAddress_Amount=<?php echo $rows[3]; ?>&Currency_Code=<?php echo $rows[4]; ?>&ipaddressid=<?php echo $rows[0]; ?>"><?php echo $rows[2]; ?></a></td>
      <td colspan="1"><a href="List_IP_Address.php?str=<?php echo $str; ?>&post=1&lcode=<?php echo $rows[0]; ?>&IPAddress_UpLoad=<?php echo $rows[1]; ?>&IPAddress_DownLoad=<?php echo $rows[2]; ?>&IPAddress_Amount=<?php echo $rows[3]; ?>&Currency_Code=<?php echo $rows[4]; ?>&ipaddressid=<?php echo $rows[0]; ?>"><?php echo $rows[3]; ?></a></td>
      <td colspan="1"><a href="List_IP_Address.php?str=<?php echo $str; ?>&post=1&lcode=<?php echo $rows[0]; ?>&IPAddress_UpLoad=<?php echo $rows[1]; ?>&IPAddress_DownLoad=<?php echo $rows[2]; ?>&IPAddress_Amount=<?php echo $rows[3]; ?>&Currency_Code=<?php echo $rows[4]; ?>&ipaddressid=<?php echo $rows[0]; ?>"><?php echo $rows[4]; ?></a></td>

    </tr>
	
<?php }?>
  </table>
</form>
</body>
</html>
