diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7848165 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +#Password files +config.php +conn.php + diff --git a/add_ip_bulk_frm.php b/add_ip_bulk_frm.php new file mode 100644 index 0000000..e15cf31 --- /dev/null +++ b/add_ip_bulk_frm.php @@ -0,0 +1,161 @@ + + + + + + + + +
+

Add IP to Blacklist / Whitelist in Bulk

+
+
+
+
+ +
+
+
+
+ + +
+
+
+
+ +
+ Years +
+
+ Months +
+
+ Days +
+
+   +
+
+
+
+ +
+
+
+
+ +
+ +
+
+
+
+ + +
+
+
+ +
+
+
+
+ + +
+
+
+
+
+ diff --git a/add_ip_bulk_save.php b/add_ip_bulk_save.php new file mode 100644 index 0000000..e6e7527 --- /dev/null +++ b/add_ip_bulk_save.php @@ -0,0 +1,140 @@ +"" && $bulk<>""){ + $bulk_array=explode("\r\n",$bulk); + $bulk_array=array_filter($bulk_array, 'trim'); + $no_of_rows=count($bulk_array); + + $dupes = 0; + $nodupes = 0; + for($i=0;$i<$no_of_rows;$i++){ + $columns=explode(",",$bulk_array[$i]); + //print_r($columns); + $ip=$columns[0]; + + //verify if ip has /value + if(strpos($ip,"/")==false){ + $ip=$ip."/32"; + } + + $sql_ins="INSERT INTO $table_name (ip,type,adddate,enddate,reason) VALUES ('$ip','$type','$now','$enddate','$reason')"; + //echo $sql_ins; + //echo "
"; + if(!mysqli_query($con,$sql_ins)){ + // Ignore the error if it is a duplicate entry, just continue. + if(substr_compare(mysqli_error($con),"Duplicate",0,9,FALSE) !== 0) { + $_SESSION['rezult_msg']="There was an error while recording the row ".$i." in the database. Please try again.
".mysqli_error($con); + $_SESSION['ret_link']="add_ip_bulk_frm.php"; + header("location:error.php?var=2"); + return false; + } + else { + $dupes++; + } + } + else { + $nodupes++; + } + + if($i==($no_of_rows-1)){ + $sql_last_upd="UPDATE info SET last=$now WHERE list='$list'"; + $rez_last_upd=mysqli_query($con,$sql_last_upd); + $_SESSION['rezult_msg']=" OK! ( " . $nodupes . " ) records were successfully added to the " . $table_name . " database. Ignored ( " . $dupes . " ) duplicates in ( " . $no_of_rows . " ) lines."; + $link="add_ip_bulk_frm.php"; + header("location:$link?var=1"); + return false; + } + } +} +else{ + $_SESSION['rezult_msg']="There is insuficient information to be able to add records to the database. Please try again.
".mysqli_error($con); + $_SESSION['ret_link']="add_ip_bulk_frm.php"; + header("location:error.php?var=2"); + return false; +} +?> \ No newline at end of file diff --git a/add_ip_frm.php b/add_ip_frm.php new file mode 100644 index 0000000..ef2c93e --- /dev/null +++ b/add_ip_frm.php @@ -0,0 +1,133 @@ +level >= $PageLevel) { + $PageAccess=true; + } +?> + + + + + +
+

You do not have sufficient rights to access this page.

+
+ +
+

+
+
+
+ + +
+
+
+
+
+ +
+ Years +
+
+ Months +
+
+ Days +
+
+   +
+
+
+
+ +
+
+
+
+ +
+ +
+
+
+ +
+
+
+ + +
+
+
+
+
+ diff --git a/add_ip_save.php b/add_ip_save.php new file mode 100644 index 0000000..6c6275d --- /dev/null +++ b/add_ip_save.php @@ -0,0 +1,120 @@ +".mysqli_error($con); + $_SESSION['ret_link']="add_ip_frm.php"; + header("location:error.php?var=2&tbl=$tbl"); + return false; + } + +?> \ No newline at end of file diff --git a/add_type_frm.php b/add_type_frm.php new file mode 100644 index 0000000..e4d5b18 --- /dev/null +++ b/add_type_frm.php @@ -0,0 +1,174 @@ + + + + + + + +'-1')){ + $old_type=$_GET['tp']; + $sql_find_type="SELECT * FROM type WHERE type='$old_type'"; + $rez_find_type=mysqli_query($con,$sql_find_type); + + if(mysqli_num_rows($rez_find_type)==1){ + //echo "here"; + $rd_t=mysqli_fetch_array($rez_find_type); + $lbl=$rd_t['label']; + $stat=$rd_t['status']; + + if($stat==1){ + $status_sel_a="checked"; + $status_sel_i=""; + } + else{ + $status_sel_a=""; + $status_sel_i="checked"; + } + } + else{ + $type=""; + $lbl=""; + $stat=""; + $status_sel_a=""; + $status_sel_i=""; + } + $update="yes"; +} +else{ + //echo "here 2"; + $old_type=""; + $lbl=""; + $stat=""; + $status_sel_a=""; + $status_sel_i=""; + $update="no"; +} + +?> +
+

Add /Edit Type of entry

+
+
+
+
+
+ + +
+
+ + +
+
+ +
+ +
+
+
+
+
+ + +

+
+
+ +
+
+
+ + +
+
+
+
+ +0){ + echo "
+
+
+
+
"; + echo "
"; + echo "
"; + echo " + + + + + "; + while($rd_tp=mysqli_fetch_array($rez_type)){ + + echo ""; + $tp=$rd_tp['type']; + echo ""; + echo ""; + + if($rd_tp['status']==1){ + echo ""; + } + else{ + echo ""; + } + + echo ""; + echo ""; + } + + echo "
TypeLabelStatusEdit
".$rd_tp['type']."".$rd_tp['label']."ActiveInactive
"; + echo "
+
"; +} +?> +
+ diff --git a/add_type_save.php b/add_type_save.php new file mode 100644 index 0000000..9611c00 --- /dev/null +++ b/add_type_save.php @@ -0,0 +1,83 @@ +".mysqli_error($con); + $_SESSION['ret_link']="add_type_frm.php"; + header("location:error.php?var=2"); + return false; +} + +if(mysqli_query($con,$sql_action)){ + $_SESSION['rezult_msg']="Type successfully added/updated to the database."; + $link="add_type_frm.php"; + echo $_SESSION['rezult_msg']; + header("location:$link?var=1"); + return false; +} +else{ + $_SESSION['rezult_msg']="The value was not added/updated to the database. Please try again.
".mysqli_error($con); + $_SESSION['ret_link']="add_type_frm.php"; + header("location:error.php?var=2"); + return false; +} + +?> \ No newline at end of file diff --git a/blacklist.php b/blacklist.php new file mode 100644 index 0000000..44ccdfa --- /dev/null +++ b/blacklist.php @@ -0,0 +1,193 @@ +format('D, d M Y H:i:s T'); + + $lMod = "Last-Modified: " . $fStamp; + header($lMod); + if($_SERVER['REQUEST_METHOD']=='HEAD') { + $con->close(); + echo("Something to make php quit and return head.."); + } + + $dPart = date("YmdHis"); + + if(!isset($_GET["a"])) + { + $action = "display"; + } + if(isset($_GET["a"])) + { + $action = strtolower($_GET["a"]); + } + + if ($action == "display") { + + //echo "; Expires: Sun, 29 Sep 2019 05:01:00 GMT"; + //echo "\r\n"; + + $SQL ="SELECT blacklist.ip, blacklist.adddate, blacklist.reason FROM blacklist WHERE blacklist.adddate < ".$dPart." AND blacklist.enddate > ".$dPart." ORDER BY blacklist.ip ASC"; + $result = mysqli_query($con,$SQL); + $num_rows = mysqli_num_rows($result); + + header("Content-Type: text/plain"); + + echo "; https://www.home.daprogs.net/api/ipban199/blacklist.php"; + echo "\r\n"; + +// echo "; DAProgs BlackList ".date("Y/m/d")." - (c) 2019 DAProgs.com"; + echo "; DAProgs BlackList - (c) 2019 DAProgs.com"; + echo "\r\n"; + + echo "; Last-Modified: ".$fStamp; +// echo "; Last-Modified: ".substr($UpdateDate,0,4)."/".substr($UpdateDate,4,2)."/".substr($UpdateDate,6,2)." ".substr($UpdateDate,8,2).":".substr($UpdateDate,10,2).":".substr($UpdateDate,12,2)." EST."; + echo "\r\n"; + + echo "; Blacklist contains ".$num_rows." elements."; + echo "\r\n"; + + while($row = mysqli_fetch_array($result)) + { + echo $row['ip']." ; ".$row['reason']." - ".substr($row['adddate'],0,4)."/".substr($row['adddate'],4,2)."/".substr($row['adddate'],6,2).""; + echo "\r\n"; + //echo $row['ip']; + //echo "\r\n"; + } + mysqli_close($con); + + //echo ""; + //echo "\r\n"; + } + elseif ($action == "add") { + if(!isset($_GET["ip"])) + { + die("Missing parameters 1."); + } + $ip = strtolower($_GET["ip"]); + + if(!isset($_GET["type"])) + { + die("Missing parameters 2."); + } + $type = $_GET["type"]; + + if(!isset($_GET["date"])) + { + die("Missing parameters 3."); + } + $enddate = $_GET["date"]; + + if(!isset($_GET["reason"])) + { + die("Missing parameters 4."); + } + $reason = urldecode($_GET["reason"]); + + $SQL ="INSERT INTO blacklist (ip, type, adddate, enddate, reason) VALUES ('".$ip."', ".$type.", ".$dPart.", ".$enddate.", '".$reason."')"; + + if ($con->query($SQL) === TRUE) { + $SQL = "UPDATE info SET last=".$dPart." WHERE list=0;"; + $con->query($SQL); + echo "SUCCESS"; + } else { + $SQL = "UPDATE blacklist SET enddate=".$enddate.", type=".$type.", reason='".$reason."' WHERE ip='".$ip."';"; + if ($con->query($SQL) === TRUE) { + $SQL = "UPDATE info SET last=".$dPart." WHERE list=0;"; + $con->query($SQL); + echo "SUCCESS UPDATE"; + } else { + echo "Error: " . $SQL . "
" . $con->error; + } + } + + + $con->close(); + } + elseif ($action == "log") { + + //'50.238.150.110 [1C28] 09:12:06 Authentication [IMAP] - Result=1 User=miniservice@theautomaster.com Method=4 + //'0 1 2 3 4 5 6 7 8 + + // time + // ip + // type + // sf + // account + + if(!isset($_GET["ip"])) + { + die("Missing parameters 1."); + } + $ip = strtolower($_GET["ip"]); + + if(!isset($_GET["date"])) + { + die("Missing parameters 2."); + } + $datetime = $_GET["date"]; + + if(!isset($_GET["sf"])) + { + die("Missing parameters 3."); + } + $sf = $_GET["sf"]; + + if(!isset($_GET["type"])) + { + die("Missing parameters 4."); + } + $logtype = $_GET["type"]; + + if(!isset($_GET["account"])) + { + die("Missing parameters 5."); + } + $account = urldecode($_GET["account"]); + + $SQL ="INSERT INTO iplog (time, ip, type, sf, account) VALUES ('".$datetime."', '".$ip."', '".$logtype."', ".$sf.", '".$account."')"; + + if ($con->query($SQL) === TRUE) { + echo "SUCCESS"; + } else { + echo "Error: " . $SQL . "
" . $con->error; + } + $con->close(); + } + elseif ($action == "rem") { + if(!isset($_GET["ip"])) + { + die("Missing parameters 1."); + } + $ip = strtolower($_GET["ip"]); + + $SQL ="DELETE FROM blacklist WHERE blacklist.ip = '".$ip."';"; + + if ($con->query($SQL) === TRUE) { + $SQL = "UPDATE info SET last=".$dPart." WHERE list=0;"; + $con->query($SQL); + echo "SUCCESS"; + } else { + echo "Error: " . $SQL . "
" . $con->error; + } + $con->close(); + } +?> + diff --git a/delete.php b/delete.php new file mode 100644 index 0000000..d742651 --- /dev/null +++ b/delete.php @@ -0,0 +1,58 @@ +"" && $ip<>""){ + $sql_del="DELETE FROM $table_name WHERE ip='$ip'"; + $sql_last_upd="UPDATE info SET last=$now WHERE list='$list'"; + + if(mysqli_query($con,$sql_del)){ + $_SESSION['rezult_msg']="IP successfully deleted in the database."; + $rez_last_upd=mysqli_query($con,$sql_last_upd); + echo $_SESSION['rezult_msg']; + $link="index.php?var=1"; + header("location:$link"); + return false; + } + else{ + $_SESSION['rezult_msg']="The value was not deleted from the database. Please try again.
".mysqli_error($con); + $_SESSION['ret_link']="index.php"; + header("location:error.php?var=2"); + return false; + } +} +else{ + $_SESSION['rezult_msg']="There are not enough parameters to erase the value from the database."; + $_SESSION['ret_link']="index.php"; + header("location:error.php?var=2"); + return false; +} +?> \ No newline at end of file diff --git a/edit_ip_frm.php b/edit_ip_frm.php new file mode 100644 index 0000000..ae30766 --- /dev/null +++ b/edit_ip_frm.php @@ -0,0 +1,130 @@ + + + + + + +

Edit IP Info in -

+
+
+
+ +
+ "; + echo ""; + ?> +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+ +
+
+
+ +
+
+
+ + +
+
+
+
+ diff --git a/edit_ip_save.php b/edit_ip_save.php new file mode 100644 index 0000000..e1f8546 --- /dev/null +++ b/edit_ip_save.php @@ -0,0 +1,96 @@ +".mysqli_error($con); + $_SESSION['ret_link']="search_db.php?"; + header("location:error.php?var=2"); + return false; + } + +?> \ No newline at end of file diff --git a/error.php b/error.php new file mode 100644 index 0000000..2b607ab --- /dev/null +++ b/error.php @@ -0,0 +1,11 @@ + + +

Error

+

Return

+
+ \ No newline at end of file diff --git a/export.php b/export.php new file mode 100644 index 0000000..79f20d8 --- /dev/null +++ b/export.php @@ -0,0 +1,38 @@ + \ No newline at end of file diff --git a/footer.php b/footer.php new file mode 100644 index 0000000..d733a1f --- /dev/null +++ b/footer.php @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/functions.php b/functions.php new file mode 100644 index 0000000..7cdf088 --- /dev/null +++ b/functions.php @@ -0,0 +1,60 @@ + \ No newline at end of file diff --git a/header.php b/header.php new file mode 100644 index 0000000..328fad0 --- /dev/null +++ b/header.php @@ -0,0 +1,36 @@ + + + + + + DAProgs.net IP whitelist/backlist + + + + + + + + + + + + + + \ No newline at end of file diff --git a/img/bg.jpg b/img/bg.jpg new file mode 100644 index 0000000..6105a29 Binary files /dev/null and b/img/bg.jpg differ diff --git a/img/bg_txt.jpg b/img/bg_txt.jpg new file mode 100644 index 0000000..a3bc49a Binary files /dev/null and b/img/bg_txt.jpg differ diff --git a/index.php b/index.php new file mode 100644 index 0000000..8be1891 --- /dev/null +++ b/index.php @@ -0,0 +1,178 @@ + + + + +
+

Find IP records

+ +
+
+
+
+
+
+ +
+
+ +
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+ +
+
+

Last 20 Entries

+
+
+
+
+
+
+ + "; + echo "
"; + echo ""; + echo " + + + + "; + while($rd_w=mysqli_fetch_array($rez_w)){ + echo ""; + if($rd_w['enddate']=='99999999999999') { + $enddate='Permanent'; + } + else + { + $enddate=print_datetime($rd_w['enddate']); + } + echo ""; + echo ""; + echo ""; + echo ""; + } + + echo "
IPEnd DateReason
".$rd_w['ip']."".$enddate."".$rd_w['reason']."
"; + echo "
"; + echo "
"; + + ?> +
+
+ + "; + echo "
"; + echo ""; + echo " + + + + "; + while($rd_b=mysqli_fetch_array($rez_b)){ + echo ""; + if($rd_b['enddate']=='99999999999999') { + $enddate_b='Permanent'; + } + else + { + $enddate_b=print_datetime($rd_b['enddate']); + } + echo ""; + echo ""; + echo ""; + echo ""; + } + + echo "
IPEnd DateReason
".$rd_b['ip']."".$enddate_b."".$rd_b['reason']."
"; + echo "
"; + echo "
"; + + ?> +
+
+
+ diff --git a/last_info.php b/last_info.php new file mode 100644 index 0000000..599576e --- /dev/null +++ b/last_info.php @@ -0,0 +1,46 @@ + +
+

Info - Last Entries for Blacklist and Whitelist

+
+
+
+
+
+
+ + + + + + "; + if($row_i['list']==1){ + echo ""; + } + else{ + echo ""; + } + $datetime=print_datetime($row_i['last']); + echo ""; + echo ""; + } + ?> +
TableEdit Date
WhitelistBlacklist$datetime
+
+
+
+
+
+ diff --git a/login.php b/login.php new file mode 100644 index 0000000..57f5cd8 --- /dev/null +++ b/login.php @@ -0,0 +1,80 @@ +prepare("SELECT * FROM users WHERE username = ?"); + $stmt->bind_param('s', $_POST['username']); + $stmt->execute(); + $result = $stmt->get_result(); + $user = $result->fetch_object(); + + if ( password_verify( $_POST['password'], $user->password ) ) { + $_SESSION['user_id'] = $user->ID; + $_SESSION['user'] = $user; + $_SESSION['logged'] = true; + header("Location: index.php"); + die(); + } + } +} + +include('header.php'); +session_destroy(); +?> + + + + +
+

Login

+ +
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+
+
+
+ +
+
+ +
+ diff --git a/search_db.php b/search_db.php new file mode 100644 index 0000000..9237712 --- /dev/null +++ b/search_db.php @@ -0,0 +1,263 @@ + + + + +"; +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 "

$title

"; + + $sqltoexport=trim($sql_find_b); + + //echo "

* click table row to edit

"; + + echo"
+ +

"; + + echo "
"; + echo "
"; + echo ""; + echo " + + + + + + + + "; + while($rd_bl=mysqli_fetch_array($rez_find_b)){ + echo ""; + $adddate=print_datetime($rd_bl['adddate']); + $enddate=print_datetime($rd_bl['enddate']); + $ip=$rd_bl['ip']; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + } + + echo "
IPAdd DateEnd DateTypeReasonEditDelete
".$rd_bl['ip']."".$adddate."".$enddate."".$rd_bl['type']." - ".$rd_bl['label']."".$rd_bl['reason']."
"; + echo "
"; + echo "
"; + } + } + + if($sql_find_w<>""){ + if(mysqli_num_rows($rez_find_w)==0 && mysqli_num_rows($rez_find_b)==0){ + $_SESSION['rezult_msg']="There aren't any Whitelist 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_w)==0 && mysqli_num_rows($rez_find_b)<>0){ + echo "There aren't any Whitelist results for IP - $ip_srch, Type - $displaytype, Date - $dateform in the database. Please try again.
".mysqli_error($con); + } + else{ + Whitelist_lbl: + //search results + $title="Whitelist Results"; + echo "

$title

"; + + $sqltoexportw=trim($sql_find_w); + + //echo "

* click table row to edit

"; + + echo"
+ +

"; + + echo "
"; + echo "
"; + echo ""; + echo " + + + + + + + + "; + while($rd_wl=mysqli_fetch_array($rez_find_w)){ + $ip=$rd_wl['ip']; + echo ""; + $adddatew=print_datetime($rd_wl['adddate']); + $enddatew=print_datetime($rd_wl['enddate']); + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + } + + echo "
IPAdd DateEnd DateTypeReasonEditDelete
".$rd_wl['ip']."".$adddatew."".$enddatew."".$rd_wl['type']." - ".$rd_wl['label']."".$rd_wl['reason']."
"; + echo "
"; + echo "
"; + } + } + echo "
"; +?> \ No newline at end of file diff --git a/sfunctions.php b/sfunctions.php new file mode 100644 index 0000000..cce95af --- /dev/null +++ b/sfunctions.php @@ -0,0 +1,9 @@ + \ No newline at end of file diff --git a/stil.css b/stil.css new file mode 100644 index 0000000..6831a69 --- /dev/null +++ b/stil.css @@ -0,0 +1,71 @@ +html { + height: 100%; +} +body { + min-height: 100%; + position:relative; +} +.bg_pic{ + background-image: url('img/bg_txt.jpg'), url('img/bg.jpg'); + background-repeat: no-repeat , repeat-x; + position:0px top, 1024px top ; + height:194px; +} +.bg_footer{ + width:100%; + height:40px; + background-image: url('img/footer.jpg'); + background-repeat: repeat-x; + position:left,bottom; + margin-left:100px; +} +.navclr{ + background-color: #267488; +} + +.navbar-default .navbar-nav > li > a { + color: #FFF; +} +.navbar-default .navbar-nav > li > a:hover, +.navbar-default .navbar-nav > li > a:focus { + color: #267488; + background-color:#FFF; +} +.navbar-default .navbar-nav > .active > a, +.navbar-default .navbar-nav > .active > a:hover, +.navbar-default .navbar-nav > .active > a:focus { + color: #FFF; + background-color: #267488; +} +.navbar-default .navbar-nav > .open > a, +.navbar-default .navbar-nav > .open > a:hover, +.navbar-default .navbar-nav > .open > a:focus { + color: #FFF; + background-color: #267488; +} + +a.linkblue:link { + color: #267488; +} +a.linkblue:visited { + color: #267488; +} +a.linkblue:hover { + color: #267488; +} +a.linkblue:active { + color: #FFFFFF; +} +.bg_footer{ + width:100%; + height:40px; + background-image: url('img/footer.jpg'); + background-repeat: repeat-x; + position:left,bottom; + margin-left:100px; +} + +.padding{ + padding-top: 3px; + padding-bottom: 3px; +} \ No newline at end of file diff --git a/test.php b/test.php new file mode 100644 index 0000000..bcabce2 --- /dev/null +++ b/test.php @@ -0,0 +1,7 @@ + + diff --git a/topmenu.php b/topmenu.php new file mode 100644 index 0000000..b28f5cd --- /dev/null +++ b/topmenu.php @@ -0,0 +1,65 @@ + + +
+ +
+ +
+ + + +
+
+ +
+ ".$_SESSION['rezult_msg']."

"; + $_SESSION['rezult_msg']=""; + + + } + else{ + $_SESSION['rezult_msg']=""; + } + ?> +
+
+ \ No newline at end of file diff --git a/whitelist.php b/whitelist.php new file mode 100644 index 0000000..5584677 --- /dev/null +++ b/whitelist.php @@ -0,0 +1,142 @@ +format('D, d M Y H:i:s T'); + + $lMod = "Last-Modified: " . $fStamp; + header($lMod); + if($_SERVER['REQUEST_METHOD']=='HEAD') { + $con->close(); + echo("Something to make php quit and return head.."); + } + + $dPart = date("YmdHis"); + + if(!isset($_GET["a"])) + { + $action = "display"; + } + if(isset($_GET["a"])) + { + $action = strtolower($_GET["a"]); + } + + if ($action == "display") { + + $SQL ="SELECT whitelist.ip, whitelist.reason FROM whitelist WHERE whitelist.adddate < ".$dPart." AND whitelist.enddate > ".$dPart." ORDER BY whitelist.ip ASC"; + $result = mysqli_query($con,$SQL); + + $num_rows = mysqli_num_rows($result); + +// $SQL2 ="SELECT info.last FROM info WHERE info.list = 1"; +// $result2 = mysqli_query($con,$SQL2); +// $UpdateDate2 = mysqli_fetch_array($result2); +// $UpdateDate = $UpdateDate2['last']; + + header("Content-Type: text/plain"); + + echo "; https://www.daprogs.com/ipbansw/whitelist.php"; + echo "\n"; + +// echo "; DAProgs WhiteList ".date("Y/m/d")." - (c) 2019 DAProgs.com"; + echo "; DAProgs WhiteList - (c) 2019 DAProgs.com"; + echo "\n"; + + echo "; Last-Modified: ".$fStamp; +// echo "; Last-Modified: ".substr($UpdateDate,0,4)."/".substr($UpdateDate,4,2)."/".substr($UpdateDate,6,2)." ".substr($UpdateDate,8,2).":".substr($UpdateDate,10,2).":".substr($UpdateDate,12,2)." EST."; + echo "\n"; + + echo "; WhiteList contains ".$num_rows." elements."; + //echo "\n"; + + while($row = mysqli_fetch_array($result)) + { + echo "\n"; + echo $row['ip']." ; ".$row['reason']; + } + mysqli_close($con); + + //echo ""; + //echo "\r\n"; + } + elseif ($action == "add") { + if(!isset($_GET["ip"])) + { + die("Missing parameters 1."); + } + $ip = strtolower($_GET["ip"]); + + if(!isset($_GET["type"])) + { + die("Missing parameters 2."); + } + $type = $_GET["type"]; + + if(!isset($_GET["date"])) + { + die("Missing parameters 3."); + } + $enddate = $_GET["date"]; + + if(!isset($_GET["reason"])) + { + die("Missing parameters 4."); + } + $reason = urldecode($_GET["reason"]); + + $SQL ="INSERT INTO whitelist (ip, type, adddate, enddate, reason) VALUES ('".$ip."', ".$type.", ".$dPart.", ".$enddate.", '".$reason."');"; + + if ($con->query($SQL) === TRUE) { + $SQL = "UPDATE info SET last=".$dPart." WHERE list=1;"; + $con->query($SQL); + echo "SUCCESS"; + } else { + $SQL = "UPDATE whitelist SET enddate=".$enddate.", type=".$type.", reason='".$reason."' WHERE ip='".$ip."';"; + if ($con->query($SQL) === TRUE) { + $SQL = "UPDATE info SET last=".$dPart." WHERE list=1;"; + $con->query($SQL); + echo "SUCCESS UPDATE"; + } else { + echo "Error: " . $SQL . "
" . $con->error; + } + } + $con->close(); + } + elseif ($action == "rem") { + if(!isset($_GET["ip"])) + { + die("Missing parameters 1."); + } + $ip = strtolower($_GET["ip"]); + + $SQL ="DELETE FROM whitelist WHERE whitelist.ip = '".$ip."';"; + + if ($con->query($SQL) === TRUE) { + $SQL = "UPDATE info SET last=".$dPart." WHERE list=1;"; + $con->query($SQL); + echo "SUCCESS"; + } else { + echo "Error: " . $SQL . "
" . $con->error; + } + $con->close(); + } +?> +