I have migrated a 10 year old home-made forum written in php4 to a new Shared Hosting server running php5. I have found 3 errors, and I will be eternally grateful if you experts could help me solve them. They are the following:
1) Notice: Undefined index: HTTP_CLIENT_IP in /usr/local/pem/vhosts/144229/webspace/httpdocs/banner.php on line 268
2) Notice: Undefined index: HTTP_X_FORWARDED_FOR in /usr/local/pem/vhosts/144229/webspace/httpdocs/banner.php on line 269
The section there is the following:
// Patched function to detect REAL IP address ifit's valid
function getip(){
global $HTTP_SERVER_VARS;
if(validip($HTTP_SERVER_VARS['HTTP_CLIENT_IP'])) return $HTTP_SERVER_VARS['HTTP_CLIENT_IP'];
elseif($HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR']!=""){
$forwarded=str_replace(",","",$HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR']);
$forwarded_array=split(" ",$forwarded);
foreach($forwarded_array as $value) if(validip($value)) return $value;
}
return $HTTP_SERVER_VARS['REMOTE_ADDR'];
}
The third error is: Fatal error: Call to undefined function sqlerr() in /usr/local/pem/vhosts/144229/webspace/httpdocs/banner.php on line 301
That section reads as follows:
function userlogin(){
global $HTTP_SERVER_VARS,$SITE_ONLINE;
unset($GLOBALS["CURUSER"]);
$ip=getip();
$nip=ip2long($ip);
$res=mysql_query("SELECT * FROM bans WHERE $nip >= first AND $nip <= last") or sqlerr(__FILE__,__LINE__);
if(mysql_num_rows($res) > 0){
header("HTTP/1.0 403 Forbidden");
print("<html><body><h1>403 Forbidden</h1>Unauthorized IP address.</body></html>\n");
die;
}
I'm utterly incompetent in php, but I inherited this issue from my Sysop, who's fighting cancer, and I have nobody else to turn to.
Thoughts and ideas on how to solve these errors? Thank you all !!!