Author Topic: SERVER['REMOTE_HOST'] problem?  (Read 11825 times)

0 Members and 1 Guest are viewing this topic.

Offline Cienega32

  • Forecaster
  • *****
  • Posts: 2571
    • East Mesa Weather
SERVER['REMOTE_HOST'] problem?
« on: January 30, 2011, 05:48:52 PM »
(Using the SaratogaWx templates)

With some other problems that I've been experiencing with my hoster (1and1) that seem to be suddenly kicking out a ton of 500 errors, I included a small error handler that writes what may have been encountered along the way. One piece of info generated from Setting.php is this:

(line#) -  35","(Notice) Undefined index:  REMOTE_HOST"

Googling around a little found that changing
Code: [Select]
$SITE['REMOTE_HOST'] = $_SERVER['REMOTE_HOST'];
to this:
Code: [Select]
$SITE['REMOTE_HOST'] = gethostbyaddr($_SERVER['REMOTE_ADDR']);
satisfies the error handler. It's not a fatal error but the error response is present just the same. I'm trying to eliminate anything I can find that may gen any kind of error (in my defense).

Is this a workable option to maintain the intended results throughout the template and whatever else that may rely on it?


I also had one of these generated from the copyright date creation but I just moved that line to below the TZ function at the end of Settings.php to satisfy the error handler output:

Code: [Select]
date() [<a href='function.date'>function.date</a>]: It is not safe to rely on the system's timezone settings.
Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function.
In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier.
We selected 'America/New_York' for 'EST/-5.0/no DST' instead"


One more question - why does 'common.php' have no closing php tag at the end?

TIA

Pat ~ Davis VP2 6153-Weatherlink-Weather Display-StartWatch-VirtualVP-Win7 Pro-64bit
www.LasCruces-Weather.com   www.EastMesaWeather.com

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 7156
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: SERVER['REMOTE_HOST'] problem?
« Reply #1 on: January 30, 2011, 07:37:34 PM »
It's a workable solution.  The stock scripts don't use those values in $SITE for any specific purpose.

I'm reformatting the Settings.php for the new PHP/AJAX templates to have (at the end) this bit of code, which will set these optional entries, only if the server provides them
Code: [Select]
# Automatic Info we might need
############################################################################
if(isset($_SERVER['REMOTE_ADDR']))   {$SITE['REMOTE_ADDR'] = $_SERVER['REMOTE_ADDR'];}
if(isset($_SERVER['REMOTE_HOST']))   {$SITE['REMOTE_HOST'] = $_SERVER['REMOTE_HOST'];}
if(isset($_SERVER['DOCUMENT_ROOT'])) {$SITE['WEBROOT'] = $_SERVER['DOCUMENT_ROOT'];}
if(isset($_SERVER['REQUEST_URI']))   {$SITE['REQURI'] = $_SERVER['REQUEST_URI'];}
if(isset($_SERVER['SERVER_NAME']))   {$SITE['SERVERNAME'] = $_SERVER['SERVER_NAME'];}
$SITE['remote'] = "onclick=\"window.open(this.href,'_blank');return false;\"";
$SITE['PHPversion'] = phpversion();

Odd about the common.php missing the closing ?> .. I just checked the Base-USA distribution, and the common.php does have the closing ?> 

The Notice: errata you're seeing can be handily turned off (without a real issue) by putting in php.ini
error_reporting = E_ALL & ~E_NOTICE;

Best regards,
Ken
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Boltek-PCI/NexStorm, microSferics ToA, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge/hub
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline Cienega32

  • Forecaster
  • *****
  • Posts: 2571
    • East Mesa Weather
Re: SERVER['REMOTE_HOST'] problem?
« Reply #2 on: January 30, 2011, 10:11:03 PM »
Thanks for the info, Ken. I didn't see any obvious change in output using one method or the other but thought I should ask.

The errata was something I intentionally invoked in order to sift thru reasons for this onslaught of Error 500 1&1 has been serving me lately (Business package - shared server). Their suggestion is (no surprise) to upgrade to a dedicated server - at a higher cost. My complaint is I never had these Error 500s prior to mid-December. Suddenly, after a server farm relocation and a PHP upgrade to 5.2.17 on Jan 11, I have problems but only with any include() file that generates graphics.

Running the file(s) by itself will render properly but chokes on serving the graphic file - regardless of size - when called from index and stops at 645 bytes according to the FireFox (3.6.13) Inspector(Net). There have been times when simply running phpinfo.php will result in an Error 500.

Am I wrong in assuming that this is a problem on their end (more than likely) and can be easily fixed by them?

As far as the common.php lacking the closing tag, I d/loaded what you have available on 1-15 and found the same thing. Here is the content as unzipped (01-15-2011) from "WD-AJAX-PHP-USA":

Code: [Select]
<?php
############################################################################
# A Project of TNET Services, Inc. and Saratoga-Weather.org (WD-USA template set)
############################################################################
#
# Project: Sample Included Website Design
# Module: common.php
# Purpose: Provides common functions used throughout the website
Authors: Kevin W. Reed <kreed@tnet.com>
# TNET Services, Inc.
#
Copyright: (c) 1992-2007 Copyright TNET Services, Inc.
############################################################################
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
############################################################################
# This document uses Tab 4 Settings
############################################################################
require_once("Settings.php");
############################################################################

# Common Functions
############################################################################

function Mklink($url$title$desc$remote) {
    global 
$SITE;

    if (
$remote) {
        echo 
"<div class='link'>";
        echo 
"<a href='${url}' title='${title}' \n";
        echo 
"$SITE[remote] >";
        echo 
"$desc</a> <img src=\"/images/offsite.gif\" alt=\"*EXT*\" /></div>";

    } else {
        echo 
"<a href='${url}' title='${title}'>${desc}</a>";
    }
}

Pat ~ Davis VP2 6153-Weatherlink-Weather Display-StartWatch-VirtualVP-Win7 Pro-64bit
www.LasCruces-Weather.com   www.EastMesaWeather.com

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 7156
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: SERVER['REMOTE_HOST'] problem?
« Reply #3 on: January 30, 2011, 11:53:21 PM »
Ah... sorry, I've not been messing about with the WD-AJAX-PHP-USA set for quite some time in the common.php file.. it could well be missing the ?> at the end.  I thought you were talking about the new beta Base-USA template.  My bad.
I do intend to deprecate the older WD-AJAX-PHP-* templates for the new multi-weather-software supporting set :)

Re 1and1 .. I, too, have been a long time customer (since 2006) and they have tried several times to suggest that I should have a dedicated server.  Balderdash!  These weather websites are not onerous to the servers (as show by many folks on the e-rice.net servers using the templates).  The issue is with their server.. they may have crammed too many websites on a server, with some of the websites being ill-behaved.  I'd suggest you ask them politely to have your website moved (rehomed) to a less populated server.
Using http://www.my-ip-neighbors.com/ I have 52 neighbors (and 5 of those are my domains).
Your site has 134 sites homed on your server.

If you have SSH access (1and1 does offer it), try logging on and running 'top' -- it will show the server load and what's happening on your webserver.  If the load factors (top-right set of 3 numbers) are above 5, it shows your server is quite 'crowded' .. Mine shows
Quote
top - 23:51:01 up 513 days, 17:57,  0 users,  load average: 1.28, 1.26, 1.29
Tasks:   7 total,   2 running,   5 sleeping,   0 stopped,   0 zombie
Cpu(s): 15.6%us,  4.3%sy,  2.7%ni, 72.8%id,  4.1%wa,  0.1%hi,  0.4%si,  0.0%st
Mem:   4147452k total,  3965020k used,   182432k free,   405020k buffers
Swap:   265064k total,   117828k used,   147236k free,  2799564k cached
which is quite good :)

After the PHP upgrade, did you put 'allow_url_fopen = on;' in your php.ini .. that may be causing the graphics problem if the program uses file_get_contents('http://.....') for a graphic file.

Best regards,
Ken
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Boltek-PCI/NexStorm, microSferics ToA, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge/hub
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline Cienega32

  • Forecaster
  • *****
  • Posts: 2571
    • East Mesa Weather
Re: SERVER['REMOTE_HOST'] problem?
« Reply #4 on: January 31, 2011, 01:41:44 AM »
That's some good stuff! Good tools to have - thanks!

My 'top':



Wouldn't the file_get_contents('http://.....') problem generated a 'Fail to open stream' type warning (IIRC)?

The graphics is my thermometer.php, cloud-base.php and my wxcams.php page. The wxcams is mainly html in the wxsample template page with hrefs to 3 jpegs on my other site. Example:

Code: [Select]
<a href="http://www.eastmesaweather.com/cams/secam.jpg"><img src="http://www.eastmesaweather.com/cams/resize400.php?in=secam.jpg" border="0" alt="SE Cam view" width="320" height="240" /></a>

Sometimes 1 will show - sometimes 2 but never all three. If I right-click/Reload image where it should be, it will render. If I left click to follow the link to the full size image and then "Go back 1 page", the image will be there. The "resize400.php" does a little image() type  handling to resize and create the smaller image on the page.

Thinking it may have been somehow related to me referencing another http, I removed it from the dashboard (which uses it for thumbnail as the conditions icon during the day) but the the other two (thermometer) still failed. They would load after an auto refresh but not on a browser refresh. And they all work fine when run on their own.

Now that I think about it - all three expect input parameters. Could that be noteworthy?

-------------------

Yes, I have hinted at and then pretty much requested that I be relocated - at least for sake of argument. Their reply was to send me what looks like a FAQ copy&paste on how to parse PHP 5 and/or PHP3 on their default PHP4...  ](*,)

Our emails have been going back & forth for a few days now. I'm sure you won't be surprised that the phone tech's first suggestion was to clear my browser cache. My response was "Which machine and which browser? I've checked 5 machines with 3 different browser from two different households using two different ISPs..." - Oh. Hold on.... ... ... you should have a dedicated server or you should optimize your code - too many things in the side-bar menu.  :roll:

Then 2 or 3 emails about how they can only allocate 30M and the error 500 are from all the programs I'm running on my site which, other than the Wx template is NONE. They're driving me nuts and trying my patience but I keep holding on. 4 different "tech" names and most responses almost sound automated based on keywords.

Needless to say, they can't grasp the concept of "thousands of people around the world running these scripts" without a problem pretty much eliminates the scripts as being suspect. That and the fact that even phpinfo.php has generated a few Error 500s as well...

Pat ~ Davis VP2 6153-Weatherlink-Weather Display-StartWatch-VirtualVP-Win7 Pro-64bit
www.LasCruces-Weather.com   www.EastMesaWeather.com

Offline Cienega32

  • Forecaster
  • *****
  • Posts: 2571
    • East Mesa Weather
Re: SERVER['REMOTE_HOST'] problem?
« Reply #5 on: January 31, 2011, 06:45:52 PM »
This morning I tried the file_url_open=on (it was off) with no different results.

I'm quickly running out of patience with their tech support as well. I have one individual that repeatedly sends me the same, word for word response about how they can only allocate 30M and blah blah. I did have that wanted 'ps aux' from SSH so I gave them that and the 'top'. That prompted yet another "... only 30M" from the other individual.  ](*,)

I politely requested a home change being it seems to be impossible to resolve so I'll see what happens. That IP_neighbor link will come in handy.



Pat ~ Davis VP2 6153-Weatherlink-Weather Display-StartWatch-VirtualVP-Win7 Pro-64bit
www.LasCruces-Weather.com   www.EastMesaWeather.com

 

anything