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."') ON DUPLICATE KEY UPDATE enddate=".$enddate.", type=".$type.", reason='".$reason."'"; if ($con->query($SQL) === TRUE) { $SQL = "UPDATE info SET last=".$dPart." WHERE list=0;"; $con->query($SQL); if ($con->affected_rows == 1) { echo "SUCCESS"; } else { 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(); } ?>