OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



gethostbyaddr(): Address is not in a.b.c.d form -request.inc

Are you responsible for making OJS work -- installing, upgrading, migrating or troubleshooting? Do you think you've found a bug? Post in this forum.

Moderators: jmacgreg, btbell, michael, bdgregg, barbarah, asmecher

Forum rules
What to do if you have a technical problem with OJS:

1. Search the forum. You can do this from the Advanced Search Page or from our Google Custom Search, which will search the entire PKP site. If you are encountering an error, we especially recommend searching the forum for said error.

2. Check the FAQ to see if your question or error has already been resolved.

3. Post a question, but please, only after trying the above two solutions. If it's a workflow or usability question you should probably post to the OJS Editorial Support and Discussion subforum; if you have a development question, try the OJS Development subforum.

gethostbyaddr(): Address is not in a.b.c.d form -request.inc

Postby enri » Sat Sep 08, 2007 4:53 am

A user report to us with error message (attached at the end of this message) showing that he cannot download our PDF file.

I believe the problem comes from the PHP function $_SERVER['HTTP_X_FORWARDED_FOR']
It is very much likely that in the client side (that we have no control of), they have a proxy that do not return ip address to our server, and created an error message.

I do not want to break the code or turn off the log function for compatibility reason

Is there any good method to solved this error, like hardcode the ip address when the getRemoteAddr() cannot obtain the ip address?

Note: We are not running with required subscription

Thanks a lot. :roll:


Error message:
==============================================================
Warning: gethostbyaddr(): Address is not in a.b.c.d form in
D:\www\ojs2\classes\core\Request.inc.php on line 252

Warning: Cannot modify header information - headers already sent by
(output started at D:\www\ojs2\classes\core\Request.inc.php:252) in
D:\www\ojs2\classes\file\FileManager.inc.php on line 187

Warning: Cannot modify header information - headers already sent by
(output started at D:\www\ojs2\classes\core\Request.inc.php:252) in
D:\www\ojs2\classes\file\FileManager.inc.php on line 188

Warning: Cannot modify header information - headers already sent by
(output started at D:\www\ojs2\classes\core\Request.inc.php:252) in
D:\www\ojs2\classes\file\FileManager.inc.php on line 189

Warning: Cannot modify header information - headers already sent by
(output started at D:\www\ojs2\classes\core\Request.inc.php:252) in
D:\www\ojs2\classes\file\FileManager.inc.php on line 190

Warning: Cannot modify header information - headers already sent by
(output started at D:\www\ojs2\classes\core\Request.inc.php:252) in
D:\www\ojs2\classes\file\FileManager.inc.php on line 191

===============================================

line 252 of request.inc
==========================
function getRemoteDomain() {
static $remoteDomain;
if (!isset($remoteDomain)) {
$remoteDomain = getHostByAddr(Request::getRemoteAddr());
HookRegistry::call('Request::getRemoteDomain', array(&$remoteDomain));
}
return $remoteDomain;
}
enri
 
Posts: 12
Joined: Fri Jan 20, 2006 11:00 am

Re: gethostbyaddr(): Address is not in a.b.c.d form -request.inc

Postby asmecher » Sat Sep 08, 2007 9:27 am

Hi enri,

Change that line from:
Code: Select all
$remoteDomain = getHostByAddr(Request::getRemoteAddr());
...to...
Code: Select all
$remoteDomain = @getHostByAddr(Request::getRemoteAddr());
if (!isset($remoteDomain)) $remoteDomain = '';
This will suppress the error message when the domain can't be detected. In general, however, I'd suggest directing error messages to a log file, not the remote browser.

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 8316
Joined: Wed Aug 10, 2005 12:56 pm


Return to OJS Technical Support

Who is online

Users browsing this forum: Google [Bot], ojsearch and 7 guests