Perhaps if you or Minifrij could implement a walkthrough of this Nastyhost/GetIPIntels thing, it'd be good.
I don't understand how to implement Nastyhosts, it's need a bit of a walkthrough.
NastyHosts/GetIPIntel is just a JSON API. There's lots of ways to do it, though something like this would do the trick:
//Get the contents of the page
$nastyHostsPage = file_get_contents('http://v1.nastyhosts.com/' . $_SERVER['REMOTE_ADDR']);
//Turn it into a usable JSON object
$nastyHostsJson = json_decode($nastyHostsPage);
//Now do checks
if($nastyHostsJson->status == '200'){
if($nastyHostsJson->suggestion == 'allow'){
//allow the user through
}else{
die('Your IP is blocked, sorry');
}
}else{
die('NastyHosts has failed');
}
//Now do GetIPIntel, which just has a more complicated URL
//The contact query is just for the admin to contact you about changes. flags=m gives you the basic information on whether to block or not, which is best for when you're just starting out, as the other information it gives is somewhat confusing
$GetIPIntelPage = file_get_contents('http://check.getipintel.net/check.php?ip=' . $_SERVER['REMOTE_ADDR'] . '&contact=CONTACTEMAILHERE&format=json&flags=m');
//Now just do the same as you did with NastyHosts
$GetIPIntelJson = json_decode($GetIPIntelPage);
//Do checks
if($GetIPIntelJson->status == 'success'){
if($GetIPIntelJson->result == '0'){
//allow the user through
}else{
die('Your IP is blocked, sorry');
}
}else{
die('GetIPIntel has failed');
}
?>
This is very basic in getting the IP as it doesn't take anything into account. I think that FaucetInABox has a
getIP(); function, perhaps that would be better to use. Apologies if there are any syntax errors, I just coded this directly into BitcoinTalk. I will code the solution I posted earlier and add it to the end of this post/make a new one. I just need some time to get it right.
E: Alright, I'm done with what I was doing. Here's the code to my solution. It uses text files which probably isn't the best way to do it, however it is the easiest to convey through here. It could easily be adapted for MySQL databases, and should be if it's going to be used.
Also, keep in mind, this will only work if 15 or less unique IPs are getting through NastyHosts per minute, as this is the hard limit for GetIPIntel.
//The syntax will be awful to save space, but it will work I should think. Individual checks for the status and suggestion would be better for both services, simply to deal with if the services are down better.
$nhJ = json_decode(file_get_contents('http://v1.nastyhosts.com/' . $_SERVER['REMOTE_ADDR']));
$giiJ = json_decode(file_get_contents('http://check.getipintel.net/check.php?ip=' . $_SERVER['REMOTE_ADDR'] . '&contact=CONTACTEMAILHERE&format=json&flags=m'));
$ipFile = 'ips.txt';
//Lets start by using NastyHosts to filter out the immediate baddies
//If NastyHosts returns 200 and allows
if($nhJ->status == '200' && $nhJ->suggestion != 'deny'){ //Put any TOR/other checks you like here
//They passed the NastyHosts test, now let's check if their IP has already visited the site
if(!in_array($_SERVER['REMOTE_ADDR'], file($ipFile, FILE_IGNORE_NEW_LINES))){
//They haven't visited, now lets check GetIPIntel
//Same thing, if GetIPIntel returns 200 and allows
if($giiJ->status == 'success' && $giiJ->result == '0'){
//Then they're safe, lets add them to the visited list
file_put_contents($ipFile, $_SERVER['REMOTE_ADDR'] . "\n", FILE_APPEND);
}else{
//Blocked by GetIPIntel
die('Something has gone wrong with GetIPIntel and/or you have been blocked. Sorry');
}
}
}else{
//Blocked by NastyHosts
die('Something has gone wrong with NastyHosts and/or you have been blocked. Sorry');
}
?>
Then you'd need a CRON job running every 24 hours to wipe the file clean. This will keep the file from clogging, taking up too much disk space or becoming inaccurate. Every 24 hours as GetIPIntel has a daily limit. This can just be something like this:
//Check the time really is midnight to prevent abuse
if(date(H) == '00'){
//Delete the file and/or just wipe it, up to you.
unlink('ips.txt'); //Delete
file_put_contents('', 'ips.txt'); //Wipe
}
?>
Again, sorry for any syntax errors, I just typed it straight into the reply box. With luck this should work fine, though I'm open to suggestions as always.
Hello. I recently tried to add a faucet
http://thekittens.96.lt to the promo list... but it has been stuck on "We need to verify the faucet's details you provided." and has not shown in the list. it has been like this For several days. Is this normal?
It can take up to a week for your faucet to be added to the list if there's no problems. Just gotta be patient.