Welcome Guest, Not a member yet? Register   Sign In
Is this a bug , or just happens on my server?
#1

[eluser]Twisted1919[/eluser]
Hi , few moments ago i tried to save the session in database , but had some troubles with ip_address() function .
I am running lighttpd , and the ouput of the $_SERVER looks like :

Code:
Array
(
    [PATH] => /sbin:/bin:/usr/sbin:/usr/bin
    [SHELL] => /bin/bash
    [USER] => Twisted1919
    [PHP_FCGI_CHILDREN] => 4
    [PHP_FCGI_MAX_REQUESTS] => 10000
    [FCGI_ROLE] => RESPONDER
    [SERVER_SOFTWARE] => lighttpd/1.4.19
    [SERVER_NAME] => host.com
    [GATEWAY_INTERFACE] => CGI/1.1
    [SERVER_PORT] => 80
    [SERVER_ADDR] => ::ffff:86.34.yy.xx
    [REMOTE_PORT] => 60319
    [REMOTE_ADDR] => ::ffff:86.34.yy.xx
    [SCRIPT_NAME] => /index.php
    [PATH_INFO] => /admin
    [PATH_TRANSLATED] => /var/www/admin
    [SCRIPT_FILENAME] => /var/www/index.php
    [DOCUMENT_ROOT] => /var/www/
    [REQUEST_URI] => /admin
    [REDIRECT_URI] => /index.php/admin
    [QUERY_STRING] =>
    [REQUEST_METHOD] => GET
    [REDIRECT_STATUS] => 200
    [SERVER_PROTOCOL] => HTTP/1.1
    [HTTP_HOST] => host.com
    [HTTP_USER_AGENT] => Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2
    [HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    [HTTP_ACCEPT_LANGUAGE] => en-us,en;q=0.5
    [HTTP_ACCEPT_ENCODING] => gzip,deflate
    [HTTP_ACCEPT_CHARSET] => ISO-8859-1,utf-8;q=0.7,*;q=0.7
    [HTTP_KEEP_ALIVE] => 300
    [HTTP_CONNECTION] => keep-alive
    [HTTP_REFERER] => http://host.com/action/login_admin
    [HTTP_COOKIE] => Blah Blah , Not Important
    [ORIG_SCRIPT_FILENAME] => /var/www/index.php/admin
    [ORIG_PATH_TRANSLATED] => /var/www/admin
    [PHP_SELF] => /index.php/admin
    [REQUEST_TIME] => 1250060984
)
So the ip address looks like this ::ffff:86.34.8.46 which obiously is not a valid ipv4 address and the ip_address() from the input class return false on it so in my database all the ip addresses are like 0.0.0.0 .
For the moment i found a workaround to this by str_replace-ing the $_SERVER['REMOTE_ADDR'] from the ip_address() method but i would like to know if this is a bug of CI or just happens with lighttpd ?
Ah , of course , and the real solution to this Smile
P.S: CI from SVN at date .
Thx .
#2

[eluser]jedd[/eluser]
Ahh, the thrill of IPv6.

What does [url="http://ellislab.com/codeigniter/user-guide/libraries/input.html"]$this->input->ip_address()[/url] actually give you?

EDIT: {facepalm} Sorry - just re-read your message - it returns FALSE. Okay .. I've seen something like this before, in my pre-CI days, and there was another server variable that you could call on - I'll have a dig around and see if I can find it, but I seem to recall it was something that was being deprecated even back then, perhaps as long ago as PHP4.
#3

[eluser]Twisted1919[/eluser]
Now , with that little hack gives my real ip , but without gives : 0.0.0.0 .
Edit : well i don't know what is causing this . Maybe php 5.3.0 (that version i'm running)?




Theme © iAndrew 2016 - Forum software by © MyBB