frank18:
Thanks - but suppressing the error is not much good to me, I would like to know the reason for this error.
the reason is because the variable $_SERVER['REMOTE_ADDR'] can be empty, when it is empty the function strstr() throws the error, because it can't have an empty needle parameter
my 2nd suggestion should prevent the error because it doesn't run strstr() when $_SERVER['REMOTE_ADDR'] is empty
you could try additional ways to get the visitor's ip address, but nothing is 100% bullet proof, and in this case only administrator IP addresses are relevant, when the store is in maintenance mode, it is not necessary to resolve the IP address of all visitors all the time
zen cart does have a function to check several other environment variables for an IP address
admin/includes/functions/general.php
/**
* Get and sanitize the current IP address, detecting past proxies where possible
* @return IP address
*/
function zen_get_ip_address() {
if (isset($_SERVER)) {
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} elseif (isset($_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (isset($_SERVER['HTTP_X_FORWARDED'])) {
$ip = $_SERVER['HTTP_X_FORWARDED'];
} elseif (isset($_SERVER['HTTP_X_CLUSTER_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_X_CLUSTER_CLIENT_IP'];
} elseif (isset($_SERVER['HTTP_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_FORWARDED_FOR'];
} elseif (isset($_SERVER['HTTP_FORWARDED'])) {
$ip = $_SERVER['HTTP_FORWARDED'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
} else {
if (getenv('HTTP_X_FORWARDED_FOR')) {
$ip = getenv('HTTP_X_FORWARDED_FOR');
} elseif (getenv('HTTP_CLIENT_IP')) {
$ip = getenv('HTTP_CLIENT_IP');
} else {
$ip = getenv('REMOTE_ADDR');
}
}
return $ip;
}
to prevent the error you would still have to avoid running strstr() on an empty string