• Resolved Per Alm

    (@per-alm)


    I GOT:
    Undefined index: HTTP_REFERER
    …./wp-content/plugins/wp-statistics/includes/classes/statistics.class.php Row: 118
    Undefined offset: 1
    …./wp-content/plugins/wp-statistics/includes/classes/hits.class.php Row: 124
    Undefined offset: 1
    …./wp-content/plugins/wp-statistics/includes/classes/hits.class.php Row: 125

    PROPOSED SOLUTIONS:

    statistics.class.php Row 111:

    if( isset($_SERVER[‘HTTP_REFERER’]) ) { //NEW LINE
    if( $default_referr ) {
    if( !esc_sql(strip_tags($_SERVER[‘HTTP_REFERER’])) ) {
    return get_bloginfo(‘url’);
    } else {
    return esc_sql(strip_tags($_SERVER[‘HTTP_REFERER’]));
    }
    } else {
    return esc_sql(strip_tags($_SERVER[‘HTTP_REFERER’]));
    }
    } //NEW LINE

    hits.class.php Row 124:

    if( isset($ip_arr[1]) ) { //NEW LINE
    $x = ip2long($ip_arr[1]);
    $mask = long2ip($x) == $ip_arr[1] ? $x : 0xffffffff << (32 – $ip_arr[1]);
    $ip_long = ip2long($ip);

    // echo “>”.$ip_arr[1].”> “.decbin($mask).”\n”;
    return ($ip_long & $mask) == ($network_long & $mask);
    } //NEW LINE

    https://www.ads-software.com/plugins/wp-statistics/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Greg Ross

    (@gregross)

    The first function is a little bit inelegent, this is probably better:

    $referr = '';
    
    if( isset($_SERVER['HTTP_REFERER']) ) { $referr = $_SERVER['HTTP_REFERER']; }
    if( $default_referr ) { $referr = $default_referr; }
    
    $referr = esc_sql(strip_tags($referr) );
    
    if( !$referr ) { $referr = get_bloginfo('url'); }
    
    return $referr;

    The second one should instead just assume a 0 mask:

    $ip_arr = explode('/', $network);
    
    if( !isset( $ip_arr[1] ) ) { $ip_arr[1] = 0; }
    
    $network_long = ip2long($ip_arr[0]);

    Plugin Contributor Greg Ross

    (@gregross)

    Closing topic.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Udefined index and offset’ is closed to new replies.