Changeset 290 for trunk/lib


Ignore:
Timestamp:
Nov 26, 2007 11:30:12 PM (16 years ago)
Author:
quinn
Message:

Fixed getRemoteAddr() to return only one value of a comma-delimited list.

Location:
trunk/lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/TemplateGlue.inc.php

    r254 r290  
    7373    $row = mysql_fetch_row($qid);
    7474    if (preg_match('/^enum|^set/i', $row[1]) && preg_match_all("/'([^']*)'/", $row[1], $enum)) {
     75        natsort($enum[1]);
    7576        return $enum[1];
    7677    } else {
  • trunk/lib/Utilities.inc.php

    r282 r290  
    849849{
    850850    $ip = getenv('HTTP_CLIENT_IP');
    851     if (empty($ip) || $ip == 'unknown' || $ip == 'localhost' || $ip == '127.0.0.1') {
     851    if (in_array($ip, array('', 'unknown', 'localhost', '127.0.0.1'))) {
    852852        $ip = getenv('HTTP_X_FORWARDED_FOR');
    853         if (empty($ip) || $ip == 'unknown' || $ip == 'localhost' || $ip == '127.0.0.1') {
     853        if (mb_strpos($ip, ',') !== false) {
     854            // If HTTP_X_FORWARDED_FOR returns a comma-delimited list of IPs then return the first one (assuming the first is the original).
     855            $ips = explode(',', $ip, 2);
     856            $ip = $ips[0];
     857        }
     858        if (in_array($ip, array('', 'unknown', 'localhost', '127.0.0.1'))) {
    854859            $ip = getenv('REMOTE_ADDR');
    855860        }
Note: See TracChangeset for help on using the changeset viewer.