Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 823475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T02:57:12+00:00 2026-05-15T02:57:12+00:00

I am trying to integrate some third party tracking code into one of my

  • 0

I am trying to integrate some third party tracking code into one of my sites, however it is throwing up some errors, and their support isn’t being much use, so i want to try and fix their code myself. Most I have fixed, however this function is giving me problems:

private function getXForwardedFor()
{
$s =& $this;

$xff_ips = array();

$headers = $s->getHTTPHeaders();

if ($headers['X-Forwarded-For']) {
$xff_ips[] = $headers['X-Forwarded-For'];
}

if ($_SERVER['REMOTE_ADDR']) {
$xff_ips[] = $_SERVER['REMOTE_ADDR'];
}

return implode(', ', $xff_ips); // will return blank if not on a web server
}

In my dev enviroment where I am showing all errors I am getting:

 Notice: Undefined index: X-Forwarded-For in /sites/webs/includes/OmnitureMeasurement.class.php  on line 1129

Line 1129 is:

if ($headers['X-Forwarded-For']) { 

If I print out $headers I get:

Array
(
[Host] => www.domain.com
[User-Agent] => Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3
[Accept] => text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
[Accept-Language] => en-gb,en;q=0.5
[Accept-Encoding] => gzip,deflate
[Accept-Charset] => ISO-8859-1,utf-8;q=0.7,*;q=0.7
[Keep-Alive] => 115
[Connection] => keep-alive
[Referer] => http://www10.toptable.com/
[Cookie] => PHPSESSID=nh9jd1ianmr4jon2rr7lo0g553; __utmb=134653559.30.10.1275901644; __utmc=134653559
[Cache-Control] => max-age=0
)

I can’t see X-Forwarded-For in there which I think is causing the problem. Is there something I should add to the function to take this into account?

I am using PHP 5.3 and Apache 2 on Fedora

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T02:57:12+00:00Added an answer on May 15, 2026 at 2:57 am

    This is not really a big deal, but good to fix nevertheless. It’s complaining about you trying to access an array key that doesn’t exist. (Even querying the array with that key using if is regarded accessing.)

    Change

    if ($headers['X-Forwarded-For']) 
      { $xff_ips[] = $headers['X-Forwarded-For']; }
    

    to

    if (array_key_exists('X-Forwarded-For', $headers))  
      { $xff_ips[] = $headers['X-Forwarded-For']; }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We've got some problems with an external company trying in integrate into a WCF
I'm trying to integrate some photo related functionality with my site and facebook. I
While trying to integrate Yahoo Media Player into my own website, I want to
I'm trying to integrate a public message board service into an existing web site.
I am trying to integrate the function into a map where you can enter
I'm using JSF/Facelets, and I'm trying to iterate over some Document objects (custom object)
I'm trying to integrate running Fitnesse tests from MSBuild im my nightly build on
We are trying to integrate tests in our daily builds using TestComplete, so far
I'm trying to integrate a NSURLConnection object with UIProgressView, so I can update the
I'm trying to integrate our Source Control(SourceAnywhere) with VS and are getting a lot

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.