![]() |
|
| |||||||
| Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| PHP/HTML/CSS/JavaScript and Servers Pick up tips and exchange info on the technical side of having a web presence. |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Hi
I've never posted on a forum before so here goes. I have a mini (3 pages) custom built store but have a problem with someone abusing it, he/she keeps using different contact details but their IP is always the same. I've lost contact with the web designer so I can't ask him to do it for me. The site is written in php, I'm quite good with html but I haven't a clue about php. Can this IP be blocked with php and if so, how do I do it? |
|
|||
|
Hi Peter
This is the simplest way to block a single IP with PHP. PHP Code:
You can also replace the "exit()" function with a page redirect to send your unwanted visitor to another location of your choice. To change the code to handle multiple IPs or even whole IP blocks e.g. 127.0.0.* requires a slight modification of the code, if you need this done let me know and I'll post the solution. Note that if the top of your source code already begins with "<?php" then you can leave out the "<?php" & "?>" parts of the above code as these two lines designate the start and end of a PHP segment. As long as you place the rest of the code after the first "<?php" it will work.
__________________
Lawrence |
|
|||
|
Thank you very much, I tested it with my own ip and it worked a treat. I only need the one IP blocked but if I need more I may come back to you.
One more question, how can I make it display a message instead of a blank page? |
|
|||
|
Hi Pete
You can add a message to the exit() function like this exit("Go Away"); If you want something more elaborate then you can do something like this. PHP Code:
You can place an entire HTML page is that space.
__________________
Lawrence |
![]() |
| Tags |
| php |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to use .htaccess to block IPs and domains from your website. | Lawrence | PHP/HTML/CSS/JavaScript and Servers | 1 | 04-07-2008 10:40 PM |
| How to use mod_rewrite to block bad bots with .htaccess | Lawrence | PHP/HTML/CSS/JavaScript and Servers | 0 | 30-10-2007 04:25 AM |