";
include('conn.php');
if(!empty($_POST['listtype'])&&isset($_POST['listtype'])){
$listtype=$_POST['listtype'];
switch($listtype){
case 'a':
$caption="Blacklist and Whitelist";
break;
case 'b':
$caption="Blacklist";
break;
case 'w':
$caption="Whitelist";
break;
}
}
else{
$listtype="a";
$caption="Blacklist and Whitelist";
}
if(!empty($_POST['IP'])&&isset($_POST['IP'])){
$ip=trim($_POST['IP']);
$ip_srch=$ip;
}
else{
$ip="";
$ip_srch="";
}
if(isset($_POST['type'])&&($_POST['type'])<>'-1'){
$type=$_POST['type'];
$sql_type="SELECT label FROM type WHERE type=$type";
$rez_type=mysqli_query($con,$sql_type);
$rd_tp=mysqli_fetch_array($rez_type);
$displaytype=$rd_tp['label'];
}
else{
$type="-1";
$displaytype="";
}
if(!empty($_POST['date'])&&isset($_POST['date'])){
$dateform=$_POST['date'];
$date=datetodigits($_POST['date']).'000000';
}
else{
$dateform="0000-00-00";
$date="00000000000000";
}
if($ip<>"" && $date=="00000000000000" && $type=="-1"){
$condition= "WHERE ip LIKE '%$ip%'";
}
elseif($ip=="" && $date<>"00000000000000" && $type=="-1"){
$condition= "WHERE adddate>=$date";
}
elseif($ip=="" && $date=="00000000000000" && $type<>"-1"){
$condition= "WHERE type.type=$type";
}
elseif($ip<>"" && $date<>"00000000000000" && $type=="-1"){
$condition= "WHERE ip LIKE '%$ip%' AND adddate>=$date";
}
elseif($ip<>"" && $date<>"00000000000000" && $type<>"-1"){
$condition= "WHERE ip LIKE '%$ip%' AND adddate>=$date AND type.type=$type";
}
elseif($ip<>"" && $date=="00000000000000" && $type<>"-1"){
$condition= "WHERE ip LIKE '%$ip%' AND type.type=$type";
}
elseif($ip=="" && $date<>"00000000000000" && $type<>"-1"){
$condition= "WHERE adddate>=$date AND type.type=$type";
}
elseif($ip=="" && $date=="00000000000000" && $type=="-1"){
$condition= "";
}
switch($listtype){
case 'a':
$sql_find_w="SELECT whitelist.*, type.label FROM whitelist
LEFT OUTER JOIN type ON whitelist.type=type.type
$condition ORDER BY ip ASC";
$rez_find_w=mysqli_query($con,$sql_find_w);
$sql_find_b="SELECT blacklist.*, type.label FROM blacklist
LEFT OUTER JOIN type ON blacklist.type=type.type
$condition ORDER BY ip ASC";
$rez_find_b=mysqli_query($con,$sql_find_b);
break;
case 'b':
$sql_find_w="";
$rez_find_w="";
$sql_find_b="SELECT blacklist.*, type.label FROM blacklist
LEFT OUTER JOIN type ON blacklist.type=type.type
$condition ORDER BY ip ASC";
$rez_find_b=mysqli_query($con,$sql_find_b);
break;
case 'w':
$sql_find_w="SELECT whitelist.*, type.label FROM whitelist
LEFT OUTER JOIN type ON whitelist.type=type.type
$condition ORDER BY ip ASC";
$rez_find_w=mysqli_query($con,$sql_find_w);
$sql_find_b="";
$rez_find_b="";
break;
}
/*echo $ip;
echo $sql_find_b;
echo "
";
echo $sql_find_w;
exit;*/
if($sql_find_b<>""){
if(mysqli_num_rows($rez_find_b)==0 && mysqli_num_rows($rez_find_w)==0){
$_SESSION['rezult_msg']="There aren't any Blacklist results for IP - $ip_srch, Type - $displaytype, Date - $dateform in the database. Please try again.
".mysqli_error($con);
$link="index.php?var=2";
header("location:$link");
return false;
}
elseif(mysqli_num_rows($rez_find_b)==0 && mysqli_num_rows($rez_find_w)<>0){
echo "There aren't any Blacklist results for IP - $ip_srch, Type - $displaytype, Date - $dateform in the database. Please try again.
".mysqli_error($con);
goto Whitelist_lbl;
}
else{
//search results
$title="Blacklist Results";
echo "
* click table row to edit
"; echo"| IP | Add Date | End Date | Type | Reason | Edit | Delete |
|---|---|---|---|---|---|---|
| ".$rd_bl['ip']." | "; echo "".$adddate." | "; echo "".$enddate." | "; echo "".$rd_bl['type']." - ".$rd_bl['label']." | "; echo "".$rd_bl['reason']." | "; echo ""; echo " | "; echo " |
* click table row to edit
"; echo"| IP | Add Date | End Date | Type | Reason | Edit | Delete |
|---|---|---|---|---|---|---|
| ".$rd_wl['ip']." | "; echo "".$adddatew." | "; echo "".$enddatew." | "; echo "".$rd_wl['type']." - ".$rd_wl['label']." | "; echo "".$rd_wl['reason']." | "; echo ""; echo " | "; echo " |