Suggestions & Feedback
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsForum InformationSuggestions & Feedback

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old June 17th, 2003, 04:11 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
PHP: IP Redirection

Hi, I was wondering if I can make a statement so that if a user is using a certain IP or is on a certain IP, I can make them see something else rather than what is normal for the page they try to access.

For example, everyone else accesses my site, normally. But say there is a malacious user or someone you hate and you just want him to stay out of the site, then what do you do?
Can you make an IF statement or something that checks for IP address?

I am really hoping this can be possible without the use of MySQL.

For the 'bad' person I want them to see something other than normal and everyone else will be unaffected. Is this even possible?

Thanks ahead of time.

Reply With Quote
  #2  
Old June 17th, 2003, 04:13 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: PHP: IP Redirection

***CANT EDIT MY OWN POST***

What is the code for this? I've seen it done before...

Reply With Quote
  #3  
Old June 17th, 2003, 04:51 AM
jorgen jorgen is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Hardenberg, Holland<marquee>
Posts: 284 jorgen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: PHP: IP Redirection

Make a textfile called "block.txt"
Insert on every line an IP address you want to block.

php Code:
Original - php Code
  1.  
  2. $fBlock = "block.txt";
  3. $aBlockedIp = file($fBlock);
  4.  
  5. if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { 
  6.   $userIp = $_SERVER['HTTP_X_FORWARDED_FOR']
  7. } else { 
  8.   $userIp = $_SERVER['REMOTE_ADDR']
  9. } 
  10.  
  11. if (in_array($userIp, $aBlockedIp)) {
  12.   exit("You are blocked");
  13. }
  14.  
  15. ?> 

Reply With Quote
  #4  
Old July 28th, 2005, 01:15 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: PHP: IP Redirection

Where it says YOUR BLOCKED how would I send them and html page instead?

Reply With Quote
  #5  
Old July 28th, 2005, 03:08 PM
scaRFhogg scaRFhogg is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Bochum, NRW, Germany, EU
Posts: 117 scaRFhogg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via ICQ to scaRFhogg
RE: PHP: IP Redirection

instead of exit("You are blocked");
use
header('Location: http://yoursite.com/blocked.html');
exit();

To use the header() function you have to make sure no other contents is send before. So you have to either put the code jorgen posted on the very top of your PHP script or use output buffering.

Reply With Quote
Reply

Viewing: Codewalkers ForumsForum InformationSuggestions & Feedback > PHP: IP Redirection


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT