Author Topic: [PHP]blocking ip address from viewing site  (Read 18073 times)

0 Members and 1 Guest are viewing this topic.

Offline Sidoh

  • Moderator
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: [PHP]blocking ip address from viewing site
« Reply #15 on: August 06, 2005, 08:39:32 pm »
Glad I could help. =)

Offline deadly7

  • 42
  • Moderator
  • Hero Member
  • *****
  • Posts: 6496
    • View Profile
Re: [PHP]blocking ip address from viewing site
« Reply #16 on: August 06, 2005, 10:03:17 pm »
Oh, I should add something...

echo '<meta http-equiv="refresh" content="0; URL=www.google.com" />';

If you're using that, add http:// before the website (www.google.com) or else it will redirect to www.mysite.com/folder/www.google.com
[17:42:21.609] <Ergot> Kutsuju you're girlfrieds pussy must be a 403 error for you
 [17:42:25.585] <Ergot> FORBIDDEN

on IRC playing T&T++
<iago> He is unarmed
<Hitmen> he has no arms?!

on AIM with a drunk mythix:
(00:50:05) Mythix: Deadly
(00:50:11) Mythix: I'm going to fuck that red dot out of your head.
(00:50:15) Mythix: with my nine

Offline Sidoh

  • Moderator
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: [PHP]blocking ip address from viewing site
« Reply #17 on: August 06, 2005, 10:18:19 pm »
Well, yeah. That was um... shorthand HTML. *looks around nervously*

Offline Warrior

  • supreme mac daddy of trolls
  • Hero Member
  • *****
  • Posts: 7503
  • One for a Dime two for a Quarter!
    • View Profile
Re: [PHP]blocking ip address from viewing site
« Reply #18 on: August 06, 2005, 11:44:42 pm »
The reason the header didn't work: If you're going to do something like that you need to make sure it's one of the first things done, else the page will already have sent it's header information out thus producing that error.
One must ask oneself: "do I will trolling to become a universal law?" And then when one realizes "yes, I do will it to be such," one feels completely justified.
-- from Groundwork for the Metaphysics of Trolling

Offline deadly7

  • 42
  • Moderator
  • Hero Member
  • *****
  • Posts: 6496
    • View Profile
Re: [PHP]blocking ip address from viewing site
« Reply #19 on: August 07, 2005, 12:50:23 am »
war, so I should've put that before <head>?
[17:42:21.609] <Ergot> Kutsuju you're girlfrieds pussy must be a 403 error for you
 [17:42:25.585] <Ergot> FORBIDDEN

on IRC playing T&T++
<iago> He is unarmed
<Hitmen> he has no arms?!

on AIM with a drunk mythix:
(00:50:05) Mythix: Deadly
(00:50:11) Mythix: I'm going to fuck that red dot out of your head.
(00:50:15) Mythix: with my nine

Offline Mythix

  • The Dude
  • x86
  • Hero Member
  • *****
  • Posts: 1569
  • Victory
    • View Profile
    • Dark-Wire
Re: [PHP]blocking ip address from viewing site
« Reply #20 on: August 07, 2005, 12:54:17 am »
No.

Code: [Select]

<head>
<meta http-equiv="refresh" content="5; url=refresh1.html">

<title> chapter 17 multimedia </title>

</head>


works just as well.
Philosophy, n. A route of many roads leading from nowhere to nothing.

- Ambrose Bierce


Offline Sidoh

  • Moderator
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: [PHP]blocking ip address from viewing site
« Reply #21 on: August 07, 2005, 02:13:32 am »
The reason the header didn't work: If you're going to do something like that you need to make sure it's one of the first things done, else the page will already have sent it's header information out thus producing that error.

It always works unless you've done anything with sessions or cookies (I'm sure there are other similar causes of the error, but these are the two main cuprates I've found).

And no, deadly7. He's saying it's the first routine that should be executed within PHP.

By tradition, meta tags are within the head tags, but it doesn't matter (I think W3C might care, but all browsers I use don't).

Offline Warrior

  • supreme mac daddy of trolls
  • Hero Member
  • *****
  • Posts: 7503
  • One for a Dime two for a Quarter!
    • View Profile
Re: [PHP]blocking ip address from viewing site
« Reply #22 on: August 07, 2005, 10:32:01 am »
First or near first, from what I've noticed.
One must ask oneself: "do I will trolling to become a universal law?" And then when one realizes "yes, I do will it to be such," one feels completely justified.
-- from Groundwork for the Metaphysics of Trolling

Offline Sidoh

  • Moderator
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: [PHP]blocking ip address from viewing site
« Reply #23 on: August 07, 2005, 01:07:50 pm »
First or near first, from what I've noticed.

Anything that is before a session or cookie declaration is my belief.

Offline Warrior

  • supreme mac daddy of trolls
  • Hero Member
  • *****
  • Posts: 7503
  • One for a Dime two for a Quarter!
    • View Profile
Re: [PHP]blocking ip address from viewing site
« Reply #24 on: August 07, 2005, 01:17:25 pm »
PERHAPS AN INVESTIGATION !
One must ask oneself: "do I will trolling to become a universal law?" And then when one realizes "yes, I do will it to be such," one feels completely justified.
-- from Groundwork for the Metaphysics of Trolling

Offline venox

  • Newbie
  • *
  • Posts: 16
  • RAWR!
    • View Profile
    • Shiver7
Re: [PHP]blocking ip address from viewing site
« Reply #25 on: August 23, 2005, 07:27:51 pm »
Rather than looping through the array.  Which, works just fine.  Using in_array() would be a bit faster.

Code: [Select]

if (in_array($ip, $iparray)) {
    die('You are banned!');
}


Offline Sidoh

  • Moderator
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: [PHP]blocking ip address from viewing site
« Reply #26 on: August 23, 2005, 07:44:36 pm »
Haha, yeah.  I just remembered that function a few days ago when I was doing something with arrays.

Good to see ya venox! :)

Offline venox

  • Newbie
  • *
  • Posts: 16
  • RAWR!
    • View Profile
    • Shiver7
Re: [PHP]blocking ip address from viewing site
« Reply #27 on: August 23, 2005, 09:12:49 pm »
Haha, yeah.  I just remembered that function a few days ago when I was doing something with arrays.

Good to see ya venox! :)

Likewise :)

Offline zorm

  • Hero Member
  • *****
  • Posts: 591
    • View Profile
    • Zorm's Page
Re: [PHP]blocking ip address from viewing site
« Reply #28 on: August 23, 2005, 10:46:29 pm »
Note that given things like HTTP_X_FORWARDED_FOR are headers sent by the client they can be forged and as such checking only them is likely a bad idea. One should really be checking all possible ips and not just the first found one.
"Frustra fit per plura quod potest fieri per pauciora"
- William of Ockham

Offline Sidoh

  • Moderator
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: [PHP]blocking ip address from viewing site
« Reply #29 on: August 23, 2005, 10:48:59 pm »
Note that given things like HTTP_X_FORWARDED_FOR are headers sent by the client they can be forged and as such checking only them is likely a bad idea. One should really be checking all possible ips and not just the first found one.

Blame the guy on php.net!  :)