Welcome Guest, Not a member yet? Register   Sign In
All users with the same ip address, why?
#1

Hi guys, I do not know why, I can not understand it at all since I did not make such strange changes to my script ... but ... I find that every visitor, so every one of my users has the same IP address.

This causes me malfunction to my site, because voting systems and counting visits depend on IP addresses.

(I tried to install a copy of my script into a subfolder, but everything works, but users have different ip addresses.)

I ask you maybe you can understand the cause,
I do not think I have touched anything on config.php or anything else.
Reply
#2

How are you getting the user's IP address? Is the IP 127.0.0.1 or 192.168.0.1 or similar?
Reply
#3

Yes, 127.0.0.1
Reply
#4

I'm guessing you're running this app on your local machine then and connecting to it yourself? Because that's your local IP (localhost).

How are you getting the IP? You should use either $_SERVER['REMOTE_ADDR'] or CI's function $this->input->ip_address().

Docs for CI's function:
https://www.codeigniter.com/user_guide/l...ip_address
Reply
#5

I have installed all the base codeignites folders on my web space, later I worked on it to develop my script. I had already tried on other providers and everything was fine.

I take ip addresses with the original function of codeigniter: echo $this->input->ip_address();
Reply
#6

See if this works, but do not use this on a real web site for security reasons.

PHP Code:
/**
 * Function to get the client ip address
 *
 * Useage: $ip = getIpAddress();
 *
 * Use for testing only not on a real site!
 */
function getIpAddress()
{
 
   $ipaddress '';

 
   if ($_SERVER['HTTP_CLIENT_IP'])
 
   {
 
       $ipaddress $_SERVER['HTTP_CLIENT_IP'];
 
   }
 
   elseif ($_SERVER['HTTP_X_FORWARDED_FOR'])
 
   {
 
       $ipaddress $_SERVER['HTTP_X_FORWARDED_FOR'];
 
   }
 
   elseif ($_SERVER['HTTP_X_FORWARDED'])
 
   {
 
       $ipaddress $_SERVER['HTTP_X_FORWARDED'];
 
   }
 
   elseif ($_SERVER['HTTP_FORWARDED_FOR'])
 
   {
 
       $ipaddress $_SERVER['HTTP_FORWARDED_FOR'];
 
   }
 
   elseif ($_SERVER['HTTP_FORWARDED'])
 
   {
 
       $ipaddress $_SERVER['HTTP_FORWARDED'];
 
   }
 
   elseif ($_SERVER['REMOTE_ADDR'])
 
   {
 
       $ipaddress $_SERVER['REMOTE_ADDR'];
 
   }
 
   else
    
{
 
       $ipaddress 'UNKNOWN';
 
   }

 
   return $ipaddress;

What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#7

(This post was last modified: 09-05-2017, 03:35 AM by Marcolino92.)

Show my correct ip address, yes!

PS: Is the SSL certificate case by chance?
Reply
#8

(09-05-2017, 03:21 AM)InsiteFX Wrote: See if this works, but do not use this on a real web site for security reasons.

PHP Code:
/**
 * Function to get the client ip address
 *
 * Useage: $ip = getIpAddress();
 *
 * Use for testing only not on a real site!
 */
function getIpAddress()
{
 
   $ipaddress '';

 
   if ($_SERVER['HTTP_CLIENT_IP'])
 
   {
 
       $ipaddress $_SERVER['HTTP_CLIENT_IP'];
 
   }
 
   elseif ($_SERVER['HTTP_X_FORWARDED_FOR'])
 
   {
 
       $ipaddress $_SERVER['HTTP_X_FORWARDED_FOR'];
 
   }
 
   elseif ($_SERVER['HTTP_X_FORWARDED'])
 
   {
 
       $ipaddress $_SERVER['HTTP_X_FORWARDED'];
 
   }
 
   elseif ($_SERVER['HTTP_FORWARDED_FOR'])
 
   {
 
       $ipaddress $_SERVER['HTTP_FORWARDED_FOR'];
 
   }
 
   elseif ($_SERVER['HTTP_FORWARDED'])
 
   {
 
       $ipaddress $_SERVER['HTTP_FORWARDED'];
 
   }
 
   elseif ($_SERVER['REMOTE_ADDR'])
 
   {
 
       $ipaddress $_SERVER['REMOTE_ADDR'];
 
   }
 
   else
    
{
 
       $ipaddress 'UNKNOWN';
 
   }

 
   return $ipaddress;


Please stop giving this snippet to everybody who has an "IP address problem".

It doesn't matter that you say it is only for test purposes. People will use your "test purposes function" in production, because nobody gave them another solution.
Reply
#9

@Narf, Sorry was just trying to see if he had another problem, well noted.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB