- fix protection against session hijacking for IPv4; ti be done later for ipv6

git-svn-id: http://piwigo.org/svn/trunk@12119 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
rvelices
2011-09-08 18:47:30 +00:00
parent 1d3fc9005f
commit bfd6bc92dd
+9 -6
View File
@@ -94,13 +94,16 @@ function pwg_session_close()
function get_remote_addr_session_hash()
{
$separator = (FALSE === strpos($_SERVER['REMOTE_ADDR'],'.'))
? ':'
: '.'
;
return substr(md5($_SERVER['REMOTE_ADDR']), 0, 4);
if (strpos($_SERVER['REMOTE_ADDR'],':')===false)
{//ipv4
return vsprintf(
"%02X%02X",
explode('.',$_SERVER['REMOTE_ADDR'])
);
}
return ''; //ipv6 not yet
}
/**
* this function returns
* a string corresponding to the value of the variable save in the session