Jump to content

Recommended Posts

so is the way i'm checking the IP now correct? or how about an IP unique to every computer that can change?

 

on-the-side question1: how do i tab in an echo? <t> doesnt work.

on-the-side question2: how do i get the length of a varchar?

im sure it can, because i just saw after all my posts this site has my IP address! and i tried strlen("$row['IP']") but it doesnt work =S

 

EDIT:

changed to $ip = $row['IP'];
if(strlen($ip) == 0)

and works! so now down to one question: how do i get the IP like this site does?

What?  There's only one way to get the IP of the remote agent, and you already posted it.  If you happen to be surfing via some proxy or spoofing your IP then you're not going to get the 'real' IP of the computer you are using.

On a side note EVERY IP changes. There are ways to get a local IP of a computer on a network. Check the php.net functions. I know some people created it.

 

If the IP does not change it is static, but that does not mean it WILL not change.

 

Let's say I am logging in from a school computer, if you ban that IP every person in that school is banned.

 

IP's only go so far. That and they can be spoofed. It sucks yes, but oh well. If I really wanted to, I can easily go in through a proxy and bam have access to you site with a new IP.

 

That is just how IP's work.

 

Why are you looking into this, for banning of users?

b/c when you're working on your own server (dev machine) that isn't actually an online server, it will show that as your IP.  That's your localhost IP on your computer.  If you upload your script to an actual web server, it will show your IP in the same manner as you see on here.

Here's the code I use which tries to get the "true" address, but it doesn't always work:

<?php
	if ($_SERVER["HTTP_X_FORWARDED_FOR"] != ""){
        		$IP = $_SERVER["HTTP_X_FORWARDED_FOR"];
        		$proxy = $_SERVER["REMOTE_ADDR"];
        		$host = @gethostbyaddr($_SERVER["HTTP_X_FORWARDED_FOR"]);
	}else{
        		$IP = $_SERVER["REMOTE_ADDR"];
        		$host = @gethostbyaddr($_SERVER["REMOTE_ADDR"]);
	}
?>

 

Ken

That's because I use the funtion gethostbyaddr() to try to get the full qualified domain name. If you just want the IP, change the code accordingly:

<?php
	if ($_SERVER["HTTP_X_FORWARDED_FOR"] != ""){
        		$IP = $_SERVER["HTTP_X_FORWARDED_FOR"];
        		$proxy = $_SERVER["REMOTE_ADDR"];
        		$host = $_SERVER["HTTP_X_FORWARDED_FOR"];
	}else{
        		$IP = $_SERVER["REMOTE_ADDR"];
        		$host = $IP;
	}
?>

 

Ken

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.