tags:

views:

50

answers:

2

This is my codes and I got an error:

  require_once(IPT_DIR."config.php");
    if ($trackip == 1) {
            $ipaddr = $_SERVER["REMOTE_ADDR"] ;
     $hostnm = gethostbyaddr("$ipaddr");

     $exclude_me=false;
     array_walk($exclude_ips, 'exclude_ip');
     if(!$exclude_me) array_walk($exclude_hosts, 'exclude_host');
     if (!$exclude_me) {
      # concatenate SCRIPT_NAME and QUERY_STRING since REQUEST_URI not used in Windows hosted sites.
      # $pg = getenv(REQUEST_URI);
      # $pg = getenv(SCRIPT_NAME);
      $pg = $_SERVER["SCRIPT_NAME"];
      # if ((getenv(QUERY_STRING)) != "") { $pg = $pg . "?" . getenv(QUERY_STRING) ; }
      if (($_SERVER["QUERY_STRING"]) != "") { $pg = $pg . "?" . $_SERVER["QUERY_STRING"] ; }

    }

And the config.php file:

$trackip = 1;

$exclude_ips = array(); # quoted IP comma separated list, wildcards ok
# example: $exclude_ips = array('127.0.0.1', '68.69.+');

$exclude_hosts = array(); # quoted Hostname comma separated list, wildcards ok
# example: $exclude_hosts = array('swbcs007.sbc.com', '.+avantgo.com');

And when I run this script I get this error:

Warning: array_walk() [function.array-walk]: The argument should be an array in tracking.php on line 80

Warning: array_walk() [function.array-walk]: The argument should be an array in tracking.php on line 81

Do you know why it’s happening?

A: 

$exclude_ips and $exclude_hosts are either not defined, or not arrays. Possible causes:

  • You are editing/including the wrong config file (or, less likely, the config file is not included at all, but that should raise an error I believe)
  • You are overwriting the arrays from the config file somewhere else before using them in array_walk
fireeyedboy
so what is ur suggestion , and what should i do exactly , i should note that when i remove require config.php line , everything goes fine , but im sure that would be disabling the functionality
Mac Taylor
A: 

You can try the following - in config.php and tracking.php just before using $exclude_ips and $exclude_hosts add

global $exclude_hosts;
global $exclude_ips;
a1ex07