Block multiple IP addresses with PHP

Today I’m going to give you a quick and very useful snipped on how to block multiple IP addresses with PHP.

First off you will have to implement this custom function in your code, preffered in the file that initializes the script.

After that, you need to define an array which contains the ip’s you want to block and then call out the function with the array parameter.

add this code to your header so that every page the specific user access, he will be blocked and will get this message:

Your IP( has been blocked !

Thanks for reading my mini tutorial, enjoy.

Check server status with PHP

Hi, today I’m going to give you a little snippet on testing if a server with a specific port is online or not.First of all this is going to be a function with 2 parameters, server ip and port.We are going to test if the server is online or not with the fsockopen() function that will require you to have PHP Sockets activated on your host.

to  access the function you simple replace the $ip with the domain or the ip and the $port with the port you want to check.

and thats it, thanks for following me.

How to disable errors for FSOCKOPEN

Hi, today I want to share with you a little tip on the FSOCKOPEN function.You know that when fsockopen function fails on php it always gives you a warning like this:

Warning: fsockopen(): unable to connect to (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ) in E:\xampp\htdocs\test.php on line 2

You can simply block only the fsockopen function warnings/ notices or another errors from that line of the code by simply adding “@” symbol in the front of the variable or function, like this:

@$fp = fsockopen(“”,”8440″,$errno,$errstr,5);

or like this:

$fp = @fsockopen(“”,”8440″,$errno,$errstr,5);

Hope this helps you, thanks for reading my tutorial.