| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| NamePros Regular Join Date: Apr 2004 Location: IL
Posts: 348
![]() | PHP IP block I wanting to create a better ip blocker but can't seem to figure it out. First here is the code that I get the ip with PHP Code: $ip = "216.86.152.216"; When an ip is blocked it is added to a table in the database. When the page is accessed it checks for the ip output from the above line against what is in the table. PHP Code: |
| |
| | #2 (permalink) |
| Senior Member Join Date: Aug 2005 Location: East Yorkshire, England
Posts: 2,689
![]() ![]() ![]() ![]() ![]() ![]() ![]() | Edit: Oh, I just saw you said without re-doing the db. Ah well... ????: NamePros.com http://www.namepros.com/showthread.php?t=325542 There is probably a better way than this: PHP Code: |
| |
| | #3 (permalink) |
| NamePros Member Join Date: Mar 2007 Location: Finland
Posts: 29
![]() | There will most definitely be tidier ways of doing this, but PHP Code:
__________________ Regards Jamie Let the might of your compassion arise to bring a quick end to the flowing stream of the blood and tears ..... Please hear my anguished words of truth.
Last edited by jabba_29; 05-08-2007 at 11:00 AM.
|
| |
| | #5 (permalink) |
| NamePros Member Join Date: Mar 2007 Location: Finland
Posts: 29
![]() | Of course. If you use file() you can open a text file as an array. Using in_array from there should do the trick. What exactly do you need to know? What is your coding level?... Do you need to know how to write the files or have you got something concrete already?
__________________ Regards Jamie Let the might of your compassion arise to bring a quick end to the flowing stream of the blood and tears ..... Please hear my anguished words of truth. |
| |
| | #6 (permalink) | ||||
| Senior Member Join Date: Oct 2006 Location: http://akshayjain.org
Posts: 2,830
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
can u please give me a proper code which i can insert in my already existing php files and use a text file to list out all the ip addresses that i need banned? | ||||
| |
| | #7 (permalink) | ||||
| Traveller Join Date: Mar 2007 Location: Yet another city
Posts: 1,419
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
PHP Code: BTW Twizted, you could probably go a bit easier on your DB by doing: banip LIKE '$ip%'" (No percent sign at the start) This assumes your `banip` field contains only a single IP, with no whitespace.
__________________ NameCooler.com | ||||
| |
| | #8 (permalink) |
| NamePros Regular Join Date: Jul 2005 Location: Tucson, AZ
Posts: 689
![]() | Why do you want to do this in PHP? Why not just use the .htaccess file to prevent access from certain IP blocks? That way you don't need to waste server resources handling the request and passing it to PHP, since it's handled by the httpd. |
| |
| | THREAD STARTER #9 (permalink) | ||||||||
| NamePros Regular Join Date: Apr 2004 Location: IL
Posts: 348
![]() |
| ||||||||
| |
| | #10 (permalink) |
| Senior Member Join Date: Oct 2006 Location: http://akshayjain.org
Posts: 2,830
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | well in my case i use a Centos VPS and it does not seem to take any command from the .htaccess file.. it does not even redirect www. to the root of my site ![]() therefore without .htaccess working i think php is the only way i can achieve it |
| |
| | #13 (permalink) | ||||
| Senior Member Join Date: Jan 2006 Location: Portland, Oregon
Posts: 2,102
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
http://www.webhostgear.com/61.html
__________________ HostingFuze.com Premium Master Reseller Services | 99.9% Uptime Guaranteed SLA | Starting at $4.95/mo Basic Reseller Hosting @ HostFz.com - Services starting as low as $1.95/mo! | ||||
| |