WXforum.net

Web Weather => Weather Website PHP/AJAX scripting => Topic started by: mchallis on January 04, 2009, 12:37:09 AM

Title: Whos Online PHP Script for your template site
Post by: mchallis on January 04, 2009, 12:37:09 AM
Whos Online Script

This advanced PHP script is designed to be a webmaster tool for your PHP template web site.
Includes a carterlake php template page and includes instructions for other template sites.

It uses a MySQL database to track web site visitors online from the last 15 minutes.
You can see what pages they click on.
Visitors are considered inactive after 5 minutes. Removed after 15 minutes.
Nothing is permanently logged except for a few records.

It has a readme.txt file with step by step instructions, but if you are a beginner at PHP it might not be easy.

Download:     
http://www.642weather.com/weather/scripts/whos-online.zip

Live Example:   
http://www.642weather.com/weather/whos-online.php
My page is password protected, but there is a screenshot.jpg included in the download.

-----------------------------------------
Features
-----------------------------------------
Shows Search bots, Visitors, and You
Time online
Entry Time
Last Click Time
IP Addresses
IP Lookups
Last URL Visited
Referrer URL
Visitor count
Language variables, easy to translate

Options:
* password protect for admin only usage (protects your visitor's privacy)
* Show or hide Bots, Refresh rate, Profile display
* timezone configurable
* hide ip addresses if you want
* "location plugin" included: adds country, city, state, latitude & longitude, and a worldmap image of online visitors.
* many of the features can be turned on or off in include-whos-online-settings.php

Inspired by the osCommerce contribution "Who's Online Enhancement"
http://addons.oscommerce.com/info/824

"location plugin" Uses GeoLite data created by MaxMind, available from http://www.maxmind.com/
Title: Re: Whos Online PHP Script for your template site
Post by: andro700 on January 04, 2009, 01:35:20 AM
You know what Mike. No matter how I download that file it still show's the whos-online.php dated 12/31. Is there a way to send the files I need to update to the 2.0 version. What I will do is I will download the file and and screenshots to show you the dates of the files. Let me know what you think.

Chuck
Title: Re: Whos Online PHP Script for your template site
Post by: pinto on January 04, 2009, 08:45:21 AM
Hi Mike,

running fine here, no upgrading issues  :-D
Title: Re: Whos Online PHP Script for your template site
Post by: jwwd on January 04, 2009, 09:18:36 AM
Hi Mike

I have version 2.01 up and running - its working fint - and the pins seems to be placed in the right place.

Thank you very much for all your hard work on this great script.

Best regards,

Henrik
Title: Re: Whos Online PHP Script for your template site
Post by: BfdWx on January 04, 2009, 09:42:37 AM
Quote
and the pins seems to be placed in the right place.

It seems some are and some are not. Mine for instance shows me out in the middle of the Atlantic both on your site and mine and I can't swim for that long!! It is a great script though and after a lot of trouble getting the Geocity.dat file loaded it works nicely. Many thanks to "mth" of http://www.relayweather.com for his kind assistance.

Regards,

Jack
Title: Re: Whos Online PHP Script for your template site
Post by: mchallis on January 04, 2009, 11:17:33 AM
Problem:
Sometimes location pins are not in their proper locations or even in the ocean.

Here is an explanation that might make sense for the geolocation inaccuracy issue:
Sometimes geolocation is close to perfect, sometimes not. Usually only about 85% accuracy.
The lat & lon, city, state parameters the database produces is for the location the ISP has reported for your current IP address.
Many ISPs share one block, or several blocks, of IP addresses with all their users.
Each time you connect you may get a different IP address assignment with different location details.
So the accuracy can even vary according to your current IP assignment.
This can cause the reported city, state, lat & lon from the IP to vary from your actual location.

To check the database itself, compare with this online demo.
http://www.maxmind.com/app/locate_ip
Title: Re: Whos Online PHP Script for your template site
Post by: Arthurhh on October 11, 2009, 09:37:27 PM
I have this (latest version from 642) and when i enable it it induces the following error in my Ajax dashboard (V2 Alternative one)
High: 8.9 @  Deprecated: Function split() is deprecated in C:\wamp\www\tok\ajax-dashboard.php on line 1742 13:38

I get no errors and see no oddities with the dates and times unless I enable the who's Online by adding the required code after Time Zone and before theme switcher in serttings.php.

Any suggestions ?
Title: Re: Whos Online PHP Script for your template site
Post by: saratogaWX on June 14, 2013, 12:00:58 PM
Later versions of PHP sometimes have Strict: messages set in the error_reporting so Mike's whos-online script for include-whos-online-header.php Version: 2.25 - 01-Sep-2009 may have a message like
Quote
Strict Standards: Only variables should be passed by reference in /home/yoursite/public_html/include-whos-online-header.php on line 1061
appear, followed by a bunch of Warning: messages about Headers already emitted.

You can fix this by changing include-online-header.php with the following changes:

Change:
Code: [Select]
            if ($C['enable_host_lookups'] && $stored_user['hostlookup'] == '') {

To:
Code: [Select]
            if ($C['enable_host_lookups'] && isset($stored_user['hostlookup']) and  $stored_user['hostlookup'] == '') {

Change:
Code: [Select]
function get_http_user_agent() {
   // determine the visitors user agent (browser)
   if (getenv('HTTP_USER_AGENT')) {
        $agent = getenv('HTTP_USER_AGENT');
   } else if ($_SERVER['HTTP_USER_AGENT']) {
        $agent = $_SERVER['HTTP_USER_AGENT'];
   } else {
        $agent = 'unknown';
   }
   return $agent;
}

function get_http_referer() {
   // determine the visitors http referer (url they clicked on to get to your site)
   if (getenv('HTTP_REFERER')) {
        $referer = getenv('HTTP_REFERER');
   } else if ($_SERVER['HTTP_REFERER']) {
        $referer = $_SERVER['HTTP_REFERER'];
   } else {
        // sometimes it is just empty
        $referer = '';
   }
   return $referer;
}

To:
Code: [Select]
function get_http_user_agent() {
   // determine the visitors user agent (browser)
   if (getenv('HTTP_USER_AGENT')) {
        $agent = getenv('HTTP_USER_AGENT');
   } else if (isset($_SERVER['HTTP_USER_AGENT'])) {
        $agent = $_SERVER['HTTP_USER_AGENT'];
   } else {
        $agent = 'unknown';
   }
   return $agent;
}

function get_http_referer() {
   // determine the visitors http referer (url they clicked on to get to your site)
   if (getenv('HTTP_REFERER')) {
        $referer = getenv('HTTP_REFERER');
   } else if (isset($_SERVER['HTTP_REFERER'])) {
        $referer = $_SERVER['HTTP_REFERER'];
   } else {
        // sometimes it is just empty
        $referer = '';
   }
   return $referer;
}

Change:
Code: [Select]
$host = (($output[0] ? end ( explode (' ', $output[0])) : $ip)); // plan a continues

To:
Code: [Select]
$host = isset($output[0]) ? end ( explode (' ', $output[0])) : $ip; // plan a continues

and that should solve the Strict: and Warning: message issues.

Best regards,
Ken
Title: Re: Whos Online PHP Script for your template site
Post by: andro700 on June 15, 2013, 11:07:24 AM
Having issues with my whos-online page. Here is a link to my site.

http://www.chucksweather.com/ (http://www.chucksweather.com/whos-online.php)

Chuck
Title: Re: Whos Online PHP Script for your template site
Post by: saratogaWX on June 15, 2013, 12:31:09 PM
Hi Chuck,

I ran the wo-update.php utility to download a fresh copy of the GeoMind database and the page seems to work now.

Best regards,
Ken

BTW.. edited your post above to remove the link (so you won't be visited by annoying spiders on your whos-online.php page)
Title: Re: Whos Online PHP Script for your template site
Post by: andro700 on June 15, 2013, 12:47:14 PM
Thanks Ken for the quick response.

Chuck

Isn't there supposed to be a map on this page Ken?
Title: Re: Whos Online PHP Script for your template site
Post by: saratogaWX on June 15, 2013, 12:53:04 PM
Not on the whos-online.php page itself.  There's a separate page with the map AFAIK.
Title: Re: Whos Online PHP Script for your template site
Post by: stuart82 on July 01, 2013, 02:24:45 PM
I have just upload the who on line list to my server and seem to getting


Fatal error: Call to undefined function check_for_settings() in /home/arderswz/public_html/whos-online.php on line 48
Title: Re: Whos Online PHP Script for your template site
Post by: txweather.org on July 01, 2013, 08:18:10 PM
I have just upload the who on line list to my server and seem to getting


Fatal error: Call to undefined function check_for_settings() in /home/arderswz/public_html/whos-online.php on line 48


Read here: http://www.wxforum.net/index.php?topic=19430.0
Title: Re: Whos Online PHP Script for your template site
Post by: andro700 on July 01, 2013, 09:53:48 PM
Have a new error on my page.

http://www.chucksweather.com/whos-online.php

Chuck
Title: Re: Whos Online PHP Script for your template site
Post by: AWL on July 01, 2013, 10:00:26 PM
Have a new error on my page.

Thought this link might help...http://www.weather-watch.com/smf/index.php/topic,36763.msg343909.html#msg343909 (http://www.weather-watch.com/smf/index.php/topic,36763.msg343909.html#msg343909)
Doug
Title: Re: Whos Online PHP Script for your template site
Post by: gluepack on July 02, 2013, 06:48:35 AM
ooi, I saw reference to a future 3.0 on another site after I had installed 2.25. It was posted over 3 years ago. However, I can't find one on search, did it ever materialize?

Anyway, that was a nice easy install. Just have to figure out where I am going to put it on my site now.

ohoh, spoke too soon. The first part was ok but in attempting to run wo-update I get...

Warning: fopen() [function.fopen]: http:// wrapper is disabled in the server configuration by allow_url_fopen=0 in ....wo-update.php on line 390

Warning: fopen(http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz) [function.fopen]: failed to open stream: no suitable wrapper could be found in ....wo-update.php on line 390

download_file error: reading or opening file

oh... I googled it, I have to turn something on in my php.ini (lol, wherever that is)

oh...what the hell, I'll do it manually
Title: Re: Whos Online PHP Script for your template site
Post by: gluepack on July 02, 2013, 01:25:41 PM
OK, that's another great script added. I like it when I don't have to do a lot of work.

The only problem that I have now is why, when logged in, the table of who is online refuses to acknowledge the extent of the width of my page. Although everything is based on percentages (I'm trying now with fixed values, to no avail) it just will not fit within my page. I saw a reference to border-collapse:collapse being a problem, in that respect, but this is styled as border-collapse:separate.

Updated--
It is the Last URL cell that causes the problem. I have tried table-layout: fixed; on the table and word-wrap:break-word; on the cell but it (appears that it) will only break after a ? (oh, and possibly hyphens) so long urls cause a problem.
(I am trying with Chrome btw)
Title: Re: Whos Online PHP Script for your template site
Post by: AWL on July 02, 2013, 01:49:17 PM
The only problem that I have now is why, when logged in, the table of who is online refuses to acknowledge the extent of the width of my page. Although everything is based on percentages (I'm trying now with fixed values, to no avail) it just will not fit within my page. I saw a reference to border-collapse:collapse being a problem, in that respect, but this is styled as border-collapse:separate.

Maybe in 'include-whos-online-page.php' somewhere around line 183? ...table border...width="99%" . May not be what your looking for but I thought I would give it a shot.

Doug

*Disregard the above post....I'm sure you already tried that.
Title: Re: Whos Online PHP Script for your template site
Post by: gluepack on July 02, 2013, 02:00:07 PM
Thanks

I have updated the post since you read it perhaps.

I am using the tools in Chrome to modify the content dynamically and know where it should be modified but not what is required. I will try another browser to see if the word-wrap works but, at the moment, that is the only thing that I can think of that will resolve the problem and Chrome is refusing to break up the url other than at a - or a ?

It is interesting because the url is linkable and, if I wanted to know the full url, I could just hover and effectively there could be anything put in the cell so, perhaps I will look at it from that point of view and modify the source to put something that will break or that is just shorter anyway.

Yeah, that is what I will do. I can't say "typically" because I have little data to work on, lol, but typically what is causing the problem is that bots, for example are looking at my WU data which has a long parameter string so I think that I will look at curtailing the displayed info. immediately prior to the ?

DUH!! I should have looked at the settings, there is a  $C['lasturl_wordwrap_chars']   = 175; that could be changed, I guess.
Hahahahah, that worked, changing it to 50 :)

Now, I'm not too sure whether I want to see who is looking at my site and what they are looking at. About the first "person", as opposed to bot, from Houston, Texas, shows as having the "Last URL" as /index.php which doesn't exist on my website. Now does that mean they tried to access that file for some reason (perhaps assuming that it did exist) accidentally or were they up to no good?
Title: Re: Whos Online PHP Script for your template site
Post by: gluepack on July 03, 2013, 10:05:16 AM
OK, it's working fine but I would like some defaults established, especially when logging on

e.g. Refresh Rate: 0:30, Profile Display: All, Show Bots: checked

The problem, as I see it, is that the code is written to display the/a default and collect the response in one statement/parameter
so I can't, for example, replace the $_GET['refresh'] in the call to draw_pull_down_menu with a default value (despite that being the parameter position for "default") because then the variable never actually gets set to that and, also, it can't be changed. The same, basically, if I add "checked" to the Bots checkbox parameters.

Or, am I missing something and is it a simple thing to do?
Title: Re: Whos Online PHP Script for your template site
Post by: txweather.org on July 03, 2013, 10:11:31 AM
The stupid "Strict Standards: Only variables should be passed by reference in /home/yoursite/public_html/include-whos-online-header.php on line 1061" came back on my site. No clue why...
Title: Re: Whos Online PHP Script for your template site
Post by: saratogaWX on July 03, 2013, 10:26:04 PM
You do need to update your include-whos-online-header.php to solve the Strict Standards: issue(s)
PHP 5+ seems to default to having E_STRICT enabled for error_reporting, and that is why you get the message(s) which screw up the page formatting.

Save the attached .txt file as include-whos-online-header.php and upload to your site .. it has the errors causing the Strict messages fixed.

Best regards,
Ken
Title: Re: Whos Online PHP Script for your template site
Post by: txweather.org on July 03, 2013, 10:54:58 PM
You do need to update your include-whos-online-header.php to solve the Strict Standards: issue(s)
PHP 5+ seems to default to having E_STRICT enabled for error_reporting, and that is why you get the message(s) which screw up the page formatting.

Save the attached .txt file as include-whos-online-header.php and upload to your site .. it has the errors causing the Strict messages fixed.

Best regards,
Ken


Ken,

Thanks for your help. But your file is broken and the code is not complete. I am sure is a small mistake :)
Title: Re: Whos Online PHP Script for your template site
Post by: saratogaWX on July 03, 2013, 11:07:06 PM
Very strange, I just compared the .php with the .php.txt version I'd uploaded and they were identical, and the .php version is the one currently running on my site.

What were the error messages when you tried?

Best regards,
Ken
Title: Re: Whos Online PHP Script for your template site
Post by: txweather.org on July 03, 2013, 11:14:44 PM
Ken,

For example your code ends at:

Code: [Select]
function gethost_lin ($ip,$timeout_secs = 2) {

 // linux gethostbyaddr with timeout by mike challis

 $time_start = microtime(true); // set a timer

 @exec('host -W '.escapeshellarg($timeout_secs).' '.escapeshellarg($ip), $output); // plan a

 $time_end = microtime(true);  // check the timer

 if(($time_end - $time_start) > $timeout_secs) return 'n/a'; // bail because it timed out

 if (empty($output)) return gethostbyadd

Note how there is no closing statement for php and also I think there is a lot missing after "gethostbyadd" which should be "gethostbyaddr"
Also there is a lot of spaces between your if statement's.

I re-download it the page and I have the same issue. If I put that page on my server it brakes the the site.
Title: Re: Whos Online PHP Script for your template site
Post by: saratogaWX on July 03, 2013, 11:22:31 PM
Very strange... maybe the attachment was truncated.

Try the .zip of the .php attached.

Best regards,
Ken
Title: Re: Whos Online PHP Script for your template site
Post by: txweather.org on July 03, 2013, 11:28:12 PM
Very strange... maybe the attachment was truncated.

Try the .zip of the .php attached.

Best regards,
Ken


It sure was truncated. All the code is now in there.
Thanks!!! :D
Title: Re: Whos Online PHP Script for your template site
Post by: gluepack on July 04, 2013, 03:26:09 AM
Funny, because I downloaded mine on the 2nd and it was perfectly ok.
Title: Re: Whos Online PHP Script for your template site
Post by: Tailspin45 on July 05, 2013, 09:34:45 AM
Replaced include-whos-online-header.php with one Ken sent a few days ago and it seemed to solve the problem. But then it started again, sporadically. However if I reload the page, the message (below) goes away. Trashed browser cache but problem persists. I'm baffled (but that's easy).

Quote
Strict Standards: Only variables should be passed by reference in /home/tailspin/carlsbadwx.com/include-whos-online-header.php on line 1061

Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/tailspin/carlsbadwx.com/include-whos-online-header.php:1061) in /home/tailspin/carlsbadwx.com/Settings.php on line 331

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/tailspin/carlsbadwx.com/include-whos-online-header.php:1061) in/home/tailspin/carlsbadwx.com/Settings.php on line 331

Warning: Cannot modify header information - headers already sent by (output started at /home/tailspin/carlsbadwx.com/include-whos-online-header.php:1061) in /home/tailspin/carlsbadwx.com/top.php on line 43
Title: Re: Whos Online PHP Script for your template site
Post by: gluepack on July 05, 2013, 03:13:28 PM
Only a wild guess because my brain is hurting but you haven't added the 3 lines of code that goes into Settings.php twice have you? The reason I say it is that line 331 in my Settings.php is 3 lines after the line of code that I would associate with your error message.
Title: Re: Whos Online PHP Script for your template site
Post by: Tailspin45 on July 05, 2013, 04:12:19 PM
Good thought, but no. Checked every file on my site for the phrase 'include-whos-online-header' and it only appears once, in Settings.php.
Title: Re: Whos Online PHP Script for your template site
Post by: saratogaWX on July 05, 2013, 04:22:09 PM
If you're still seeing the Strict: message, then it is likely that the copy of include-whos-online-header.php on your website is really the older one, not the updated one .. I'd suggest downloading the .zip, unpacking it, and uploading it again :)

The other Warning: messages are artifacts of having the Strict: message appear and will go away when the Strict: message is gone.

Best regards,
Ken
Title: Re: Whos Online PHP Script for your template site
Post by: txweather.org on July 05, 2013, 04:41:24 PM
If you're still seeing the Strict: message, then it is likely that the copy of include-whos-online-header.php on your website is really the older one, not the updated one .. I'd suggest downloading the .zip, unpacking it, and uploading it again :)

The other Warning: messages are artifacts of having the Strict: message appear and will go away when the Strict: message is gone.

Best regards,
Ken

Ken,

I am not sure about that. I got 1061 again today even with your copy of the php.... Though it could of have been a cache thing...
Title: Re: Whos Online PHP Script for your template site
Post by: Tailspin45 on July 05, 2013, 04:44:12 PM
I did that, Ken. I trashed cache and installed the one you sent me by email a couple of days ago.

But thinking I may have screwed up, I also downloaded the zip you posted here earlier and installed that file, too.

My line 1061 (top) and yours (bottom) look like this:

Quote
$host = isset($output[0]) ? end ( explode (' ', $output[0])) : $ip; // plan a continues
$host = isset($output[0]) ? end ( explode (' ', $output[0])) : $ip; // plan a continues

The full path for my file, copied from BBEdit, is
Quote
ftp://username:@host//carlsbadwx.com/include-whos-online-header.php
so I'm not looking at the file on my system as I stupidly did once before.
Title: Re: Whos Online PHP Script for your template site
Post by: txweather.org on July 05, 2013, 08:37:13 PM
I can confirm that even with the fix the 1061 comes back to haunt u :(
Title: Re: Whos Online PHP Script for your template site
Post by: gluepack on July 07, 2013, 01:30:30 PM
As is my wont, I've played around with the script to tidy up a few things, mainly associated with wrapping (I've moved the Last URL to a separate line, for example).
If anyone is interested in looking at what I have done, you can access it (under Status) on my website http://www.jerbils.info/saratoga/wxindex.php (http://www.jerbils.info/saratoga/wxindex.php). For a limited time you can sign in as guest, password guest (lol, I hope that is ok).
I'm still tinkering with it as I have the map on the same page and want to pump that up a bit and I want to add some more detail to pad out the page, mainly because I am not expecting that many visitors (at the moment bots, many of them Chinese that seem to want to know what my weather is like in 2017, seem to outnumber visitors 4 to 1 and I am the 1, lol).
Title: Re: Whos Online PHP Script for your template site
Post by: AWL on July 07, 2013, 01:52:09 PM
If anyone is interested in looking at what I have done, you can access it (under Status) on my website

Good job  =D>, in fact you entire site looks very well put together.

Doug
Title: Re: Whos Online PHP Script for your template site
Post by: txweather.org on July 07, 2013, 02:06:49 PM
If anyone is interested in looking at what I have done, you can access it (under Status) on my website

Good job  =D>, in fact you entire site looks very well put together.

Doug

A good job indeed!
Title: Re: Whos Online PHP Script for your template site
Post by: txweather.org on July 07, 2013, 02:32:47 PM
As is my wont, I've played around with the script to tidy up a few things, mainly associated with wrapping (I've moved the Last URL to a separate line, for example).
If anyone is interested in looking at what I have done, you can access it (under Status) on my website http://www.jerbils.info/saratoga/wxindex.php (http://www.jerbils.info/saratoga/wxindex.php). For a limited time you can sign in as guest, password guest (lol, I hope that is ok).
I'm still tinkering with it as I have the map on the same page and want to pump that up a bit and I want to add some more detail to pad out the page, mainly because I am not expecting that many visitors (at the moment bots, many of them Chinese that seem to want to know what my weather is like in 2017, seem to outnumber visitors 4 to 1 and I am the 1, lol).

We must have different versions of php. If I get rid of line 1061 all my issues go away.
Title: Re: Whos Online PHP Script for your template site
Post by: gluepack on July 07, 2013, 02:54:01 PM
Not quite.....

Strict Standards: Only variables should be passed by reference in /var/www/include-whos-online-header.php on line 1062


Mine is 5.3.24 btw
Title: Re: Whos Online PHP Script for your template site
Post by: txweather.org on July 07, 2013, 02:55:11 PM
Not quite.....

Strict Standards: Only variables should be passed by reference in /var/www/include-whos-online-header.php on line 1062

GOSH! :(
That is so annoying...
Title: Re: Whos Online PHP Script for your template site
Post by: gluepack on July 07, 2013, 03:10:31 PM
oh btw... look at my 1061 in include-whos-online-header.php compared to yours....

$host = (($output[0] ? end ( explode (' ', $output[0])) : $ip)); // plan a continues

$host = isset($output[0]) ? end ( explode (' ', $output[0])) : $ip; // plan a continues

...are you sure you have the right file?

My line 13 says...
Version: 2.25 - 01-Sep-2009 see changelog.txt for changes
Title: Re: Whos Online PHP Script for your template site
Post by: txweather.org on July 07, 2013, 03:23:41 PM
I have the file uploaded by Ken.

Code: [Select]
$host = isset($output[0]) ? end ( explode (' ', $output[0])) : $ip; // plan a continues
Is the correct change made by Ken and is what I have.

Code: [Select]
$host = (($output[0] ? end ( explode (' ', $output[0])) : $ip)); // plan a continues
Is the old line.

My version is:
Code: [Select]
Version: 2.25 - 01-Sep-2009 see changelog.txt for changes
Title: Re: Whos Online PHP Script for your template site
Post by: txweather.org on July 07, 2013, 03:37:35 PM
one more time... I just dl the zip file and unzip it on my dir.

Lets see if anything changes.
Title: Re: Whos Online PHP Script for your template site
Post by: Tailspin45 on July 07, 2013, 06:29:00 PM
Mine says 2.25 and 2009 too, but I know Ken has tweaked it since then to include this version of line 1061

Quote
$host = isset($output[0]) ? end ( explode (' ', $output[0])) : $ip; // plan a continues

Title: Re: Whos Online PHP Script for your template site
Post by: txweather.org on July 07, 2013, 06:31:13 PM
Mine says 2.25 and 2009 too, but I know Ken has tweaked it since then to include this version of line 1061

Quote
$host = isset($output[0]) ? end ( explode (' ', $output[0])) : $ip; // plan a continues



That is correct. and mine still complaints about that line. Though is states 1062 because I add it a line to my php file to silent errors... Still I am unable to get rid of that message...
Title: Re: Whos Online PHP Script for your template site
Post by: gluepack on July 08, 2013, 06:50:23 AM
Can I remove the

 echo '<meta http-equiv="refresh" ....
statement and just refresh the

<?php include($C['files_path'].'include-whos-online-page.php'); ?>
statement somehow, if refresh is set,

so that the whole page doesn't refresh?
Title: Re: Whos Online PHP Script for your template site
Post by: txweather.org on July 08, 2013, 08:37:19 AM
Can I remove the

 echo '<meta http-equiv="refresh" ....
statement and just refresh the

<?php include($C['files_path'].'include-whos-online-page.php'); ?>
statement somehow, if refresh is set,

so that the whole page doesn't refresh?

gluepack,

You didn't point out which line your file has.
Yours "works" and you claim you got the same copy.... But the line you posted is not the same as the Ken source.
Can you confirm please.

Thanks!
Title: Re: Whos Online PHP Script for your template site
Post by: gluepack on July 08, 2013, 09:16:01 AM
Sorry, the post that you have quoted is nothing to do with your error messages. It is a request for a mod to change the method of refreshing.

If you look at an earlier post, you will see what I have for line 1061..

Mine: $host = (($output[0] ? end ( explode (' ', $output[0])) : $ip)); // plan a continues

Yours: $host = isset($output[0]) ? end ( explode (' ', $output[0])) : $ip; // plan a continues

I downloaded my version, from the regular download place, and that was on the 2nd.
Title: Re: Whos Online PHP Script for your template site
Post by: txweather.org on July 08, 2013, 09:19:21 AM
Sorry, the post that you have quoted is nothing to do with your error messages. It is a request for a mod to change the method of refreshing.

If you look at an earlier post, you will see what I have for line 1061..

Mine: $host = (($output[0] ? end ( explode (' ', $output[0])) : $ip)); // plan a continues

Yours: $host = isset($output[0]) ? end ( explode (' ', $output[0])) : $ip; // plan a continues

I downloaded my version, from the regular download place, and that was only a couple of days ago. Look at my posts.

Sorry I quoted the wrong post :) . Ok so that confirms that that is not Kens modified version of the header file. That's the original. I am going to try that line.
Thanks for the reply.
Title: Re: Whos Online PHP Script for your template site
Post by: Tailspin45 on July 08, 2013, 01:39:00 PM
Tried the line you mentioned, xcom, and thought it fixed the problem. Trashed the cache, went through a bunch of pages with no problem. But went back an hour later and home page displayed the usual error. ](*,)
Title: Re: Whos Online PHP Script for your template site
Post by: txweather.org on July 08, 2013, 01:40:53 PM
Tried the line you mentioned, xcom, and thought it fixed the problem. Trashed the cache, went through a bunch pf pages with no problem. But went back an hour later and home page displayed the usual error. ](*,)

Same issue here. I just can see how gluepack fixed it without thew page.... He add it code to his page so something there fixed it...

Title: Re: Whos Online PHP Script for your template site
Post by: mkutche on July 08, 2013, 03:46:23 PM
can someone help me make a mysql table im having trouble.

Mike
Title: Re: Whos Online PHP Script for your template site
Post by: Tailspin45 on July 08, 2013, 03:57:21 PM
Why don't you start a new thread, so it doesn't get lost in this one which is on an entirely different topic?
Title: Re: Whos Online PHP Script for your template site
Post by: txweather.org on July 08, 2013, 10:51:28 PM
gluepack can you share your include-whos-online-header.php file please.

Thanks.
Title: Re: Whos Online PHP Script for your template site
Post by: gluepack on July 09, 2013, 08:00:20 AM
The header php?

The only difference is that I have added align="center" to line 741

The original file is time-stamped 01/09/2009 15:52

Can't the author help?

Anyway, I'm still interested in.....
Quote
Can I remove the

 echo '<meta http-equiv="refresh" ....
statement and just refresh the

<?php include($C['files_path'].'include-whos-online-page.php'); ?>

statement somehow, if refresh is set,
so that the whole page doesn't refresh?
Each time you change a parameter the whole page refreshes.
and
Quote
I would like some defaults established, especially when logging on

e.g. Refresh Rate: 0:30, Profile Display: All, Show Bots: checked

The problem, as I see it, is that the code is written to display the/a default and collect the response in one statement/parameter
so I can't, for example, replace the $_GET['refresh'] in the call to draw_pull_down_menu with a default value (despite that being the parameter position for "default") because then the variable never actually gets set to that and, also, it can't be changed. The same, basically, if I add "checked" to the Bots checkbox parameters.

Can the author help?

Oh, the other thing that I am interested in is, as I alluded to in a previous post, how the Last URL can be /index.php when it doesn't exist on my site. I thought that it might have derived from a bad "refer"ral on my part but looking at the Referer in each case, apart from there being no commonality, except my signature, invariably the only link is from my banner which is correct.
Title: Re: Whos Online PHP Script for your template site
Post by: saratogaWX on July 09, 2013, 11:35:25 AM
On looking at the docs for PHP, I found
Quote
Description

mixed end ( array &$array )

end() advances array's internal pointer to the last element, and returns its value.


Parameters


array
The array. This array is passed by reference because it is modified by the function.
This means you must pass it a real variable and not a function returning an array because only actual variables may be passed by reference.



Return Values

Returns the value of the last element or FALSE for empty array.

Which seems to indicate that a construct like

 $host = (($output[0] ? end ( explode (' ', $output[0])) : $ip)); // plan a continues

or

 $host = isset($output[0]) ? end ( explode (' ', $output[0])) : $ip; // plan a continues

will both cast a Strict: error because the end() function is not being passed a 'real variable', but instead is passed the return array from the explode() function.

I suggest trying the @ operator to suppress the message.  So something like


 $host = isset($output[0]) ? @end ( explode (' ', $output[0])) : $ip; // plan a continues

and see if that squashes the Strict: (and the resultant Warning: about the headers already output) messages.

Or, rewrite the code as

 if(isset($output[0])) {
   $tIP = explode (' ', $output[0]);
   $host = end($tIP);
  } else {
  $host = $ip; }

which would work the same and satisfy the end() requirement for an real variable array to be passed to it.


Best regards,
Ken

Title: Re: Whos Online PHP Script for your template site
Post by: Tailspin45 on July 09, 2013, 12:22:55 PM
Who-hoo! Thanks Ken.

Will give it a shot and report back after a suitable period since the error seemed to go away but reappear after a while.

UPDATE: Zipped through all my pages and didn't hit the error speed bump. Trashed cache, still no problems.

Have we successfully put a stake through it's heart?
Title: Re: Whos Online PHP Script for your template site
Post by: txweather.org on July 09, 2013, 02:15:24 PM
Ken,

Thanks!!!! :D
I just did

Code: [Select]
$host = isset($output[0]) ? @end ( explode (' ', $output[0])) : $ip; // plan a continues
Now waiting if it comes back to hunt me.... So far all ok :)
Title: Re: Whos Online PHP Script for your template site
Post by: gluepack on July 09, 2013, 05:27:01 PM
Well that answers one of my questions,idly wandering through the settings file.....
'thermometer.php' => '/index.php'
'settings.php'    => '/index.php'


Also, I wondered why it looked weird. Whatever you specify for the wordwrap count for Last URL (at least) doesn't necessarily manifest itself in the resulting output. I don't know if that is because of the use of the htmlspecialchars function or not but, as well, sometimes it shows &amp; and other times it shows & and sometimes it puts a spurious ; in the text. The href for the link is fine it is what is displayed is a problem. I have wordrap set to 100 for example and it does it around 77.
Title: Re: Whos Online PHP Script for your template site
Post by: gluepack on August 07, 2013, 02:11:00 PM
The Geolite database that gets updated each month is supposed to be available from the first Tuesday of the month but the current one appears to be dated 3rd July still (which was a Wednesday, so I guess it may be available later today).

Also, are there any changes to the whosonline scripts, apart from the hard-coded name, that have to be made, if you want to switch over to V6?
Title: Re: Whos Online PHP Script for your template site
Post by: andro700 on August 11, 2013, 01:45:06 PM
Having issues with my update page. Here is what it is showing when I update. Any idea's?

Checking for updates for the Maxmind GeoLiteCity database...
Connecting to this URL: http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz


Please allow plenty of time for the approximately 19meg file to download (the time needed depends on your server download speed)...
A timeout can happen if the connection is really slow causing this to take more than 3 minutes...

Warning: set_time_limit() has been disabled for security reasons in /virtual/users/e14497-14796/web/wo-update.php on line 385
Download begins(counting megs)...(1)(2)(3)(4)(5)(6)(7)(8)(9)(10)(11)
Warning: set_time_limit() has been disabled for security reasons in /virtual/users/e14497-14796/web/wo-update.php on line 417
...download complete.
Download success, uncompressing file...

Warning: fopen(GeoLiteCity.dat) [function.fopen]: failed to open stream: Permission denied in /virtual/users/e14497-14796/web/wo-update.php on line 201
unzip error: opening GeoLiteCity.dat file

Chuck
Title: Re: Whos Online PHP Script for your template site
Post by: Maumelle Weather on August 11, 2013, 01:59:50 PM
Chuck,

Looks like everything is working, except your blog.
Title: Re: Whos Online PHP Script for your template site
Post by: scottct1 on February 19, 2014, 01:45:48 PM
I am not sure what happened this was working great but now when I look at whos online all the people connected are showing the same IP address and that address is the IP of my server, not the IP they are connecting from.

I am not sure why this is happening, I even uninstalled and reinstalled it with the same issue.

Any ideas??
Title: Re: Whos Online PHP Script for your template site
Post by: n7xrd on February 22, 2014, 08:22:20 AM
New Install and I am getting this message
Fatal error: Call to undefined function check_for_settings() in       can't seem to find the issue
Title: Re: Whos Online PHP Script for your template site
Post by: jgillett on February 23, 2014, 10:26:32 PM
Decided to give this another try tonight and can't even get past the DB. Get the following SQL error when trying to run Mike's provided code...

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TYPE=MyISAM DEFAULT CHARSET=utf8' at line 23

Thoughts appreciated.
Title: Re: Whos Online PHP Script for your template site
Post by: W3DRM on February 24, 2014, 11:15:55 AM
You might want to contact Mike Challis directly from his website. He hasn't been active on this forum since August 12, 2012 so I doubt he will be aware you folks are having problems.

Mike's scripts are available here:
Title: Re: Whos Online PHP Script for your template site
Post by: Maumelle Weather on February 24, 2014, 12:05:18 PM
Hi John,

I've seen this error before, but I don't exactly remember what the fix was. I'll have to look when I get home.

John
Title: Re: Whos Online PHP Script for your template site
Post by: jgillett on February 24, 2014, 12:21:58 PM
Hi John,

Been pouring through everything I can find online but no luck so far. Have a feeling it's actually annoyed with the line directly above that one, but not sure.

Also missing wo-us-map.png which he calls out in the readme-install file.

Just downloaded again directly from his site and have the same problems.

Thanks!
Title: Re: Whos Online PHP Script for your template site
Post by: Maumelle Weather on February 24, 2014, 12:58:54 PM
Hi John,

I think I found it. Change

from:

TYPE=MyISAM DEFAULT CHARSET=utf8

to

ENGINE=MyISAM DEFAULT CHARSET=utf8

I think this resolves that.

John
Title: Re: Whos Online PHP Script for your template site
Post by: jgillett on February 24, 2014, 02:52:16 PM
Hi John,

Perfect! Changed all 3 instances (1 for each table). Worked exactly as advertised. THANK YOU!

If I may, would you happen to have wo-us-map.png hanging around?

'preciate...  :grin:
Title: Re: Whos Online PHP Script for your template site
Post by: Maumelle Weather on February 24, 2014, 02:59:56 PM
I think these are the ones.
Title: Re: Whos Online PHP Script for your template site
Post by: jgillett on February 24, 2014, 04:28:46 PM
Those two I have in /readme-files/optional-region-maps/ (odd place). But in the readme-install he specifically calls out wo-us-map.png.

Regardless, the basics are now working in the footer, along with http://tiggrweather.net/whos-online.php (not yet in the nav bar).
On occasion get the strict errors mentioned here but am using Ken's mod. Have to fix that and then to the options - oh boy.

Thanks again, John. Wouldn't have gotten this far without your SQL fix.
Title: Re: Whos Online PHP Script for your template site
Post by: jgillett on February 25, 2014, 06:00:57 PM
Finally got this thing working last night. Everything appears OK and no validation errors.

However, at the same time this came online the Cloud Level graphic went away and hasn't been back since. Anybody know of any problems in this area?

Thanks.
Title: Re: Whos Online PHP Script for your template site
Post by: jgillett on March 05, 2014, 08:47:30 PM
Got the cloud level fixed, but...

A few days ago was the first run of the cron to update the GeoLite DB. Failed. Long message but the gist is...

Warning: fopen(): http:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /home/tigercon/public_html/tiggrweather.net/wo-update.php on line 390

allow_url_fopen is On in the php.ini file.

Thoughts appreciated.
Title: Re: Whos Online PHP Script for your template site
Post by: saratogaWX on March 05, 2014, 10:23:32 PM
It is possible that in the server's master config, they've disallowed changing that.  Run a page with phpinfo(); in it to see the full configuration.  Check the settings under the Core listing.  If the master setting is off, then you'll likely need to contact tech support to get it changed (or allow the local php.ini to change it).

Best regards,
Ken
Title: Re: Whos Online PHP Script for your template site
Post by: jgillett on March 06, 2014, 12:08:27 AM
Thanks for your reply, Ken.

Both Local and Master values are On.
Title: Re: Whos Online PHP Script for your template site
Post by: saratogaWX on March 06, 2014, 01:34:14 AM
Time to call tech support at the hoster.. with both on, that message shouldn't have happened.

Best regards,
Ken
Title: Re: Whos Online PHP Script for your template site
Post by: jgillett on March 06, 2014, 02:28:55 AM
Will do.

One thing bothers me, though. Other scripts that rely on that setting seem to be running OK. Should they not be failing as well?

Thanks, Ken.
Title: Re: Whos Online PHP Script for your template site
Post by: jgillett on March 10, 2014, 07:17:32 PM
Time to call tech support at the hoster.. with both on, that message shouldn't have happened.
They say that in both my copy and the server master all settings for allow_url_fopen are on. Therefore (according to them), the script is at fault.

Just passing on what they said.
Title: Re: Whos Online PHP Script for your template site
Post by: i_fiorentino on October 01, 2014, 02:09:14 AM
Hi guys,
actually i've this error on my site:
Fatal error: Cannot redeclare geoip_country_code_by_name() in /home/byoryrxn/public_html/whos-online/include-whos-online-geoip.php on line 379
File attached.

Any ideas?
Thanks in advance,


Alessandro
Title: Re: Whos Online PHP Script for your template site
Post by: i_fiorentino on October 20, 2014, 10:51:05 AM
Hi guys,
actually i've this error on my site:
Fatal error: Cannot redeclare geoip_country_code_by_name() in /home/byoryrxn/public_html/whos-online/include-whos-online-geoip.php on line 379
File attached.

Any ideas?
Thanks in advance,


Alessandro

Up!
It seems there are some guys with the same problem.....and nobody has found a solution  :-( :-(
Title: Re: Whos Online PHP Script for your template site
Post by: Gert Woerden on October 25, 2014, 08:04:58 AM
this script will not work with PHP5.5  !!!!!
( The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead )
I hope there will by a update soon
greetings
Title: Re: Whos Online PHP Script for your template site
Post by: i_fiorentino on October 25, 2014, 08:32:12 AM
this script will not work with PHP5.5  !!!!!
( The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead )
I hope there will by a update soon
greetings

Ohhhhhhhhhhh, finally someone who has found the problem  =D&gt; =D&gt; =D&gt;
What do you think to send an email to Mike for fixing this issue?
Best regards,


Alessandro
Title: Re: Whos Online PHP Script for your template site
Post by: ALITTLEweird1 on October 25, 2014, 11:17:29 AM
Are you sure you have php 5.5?
Title: Re: Whos Online PHP Script for your template site
Post by: i_fiorentino on October 25, 2014, 11:27:54 AM
Are you sure you have php 5.5?

I've Php 5.4 but i think the problem is in these two versions (5.4/5.5).
Title: Re: Whos Online PHP Script for your template site
Post by: ALITTLEweird1 on October 25, 2014, 11:41:08 AM
I have 5.4 and it works fine. You should start over with the script if your trying to move it over from another host.
Title: Re: Whos Online PHP Script for your template site
Post by: Gert Woerden on October 25, 2014, 11:58:44 AM
yes I have
I also have some errors into my template Saratoga but that I have fix
only the problem with this script  I can not fix
so I hope someone know what to do
 for info I was run V2 from this script and after the update from my server  to PHP 5.5  I saw the error
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in
so I have delete that script and download the new one Whos Online V3  but also this one have the some problem
so I hope for you that your server will not update the PHP to 5.5  if do  you will have the some problems like my
Greetings   Gert

/////////////////////////
Does PHP work?

Yes, it does. PHP Version 5.5.17

To run the WXGRAPHIC script, you need GD enabled in PHP.
Current GD status:
•GD support: yes
•GD Version: bundled (2.1.0 compatible)
•FreeType Support:  yes
•FreeType Linkage: with freetype
•T1Lib Support:  no
•GIF Read Support:  yes
•GIF Create Support:  yes
•JPEG Support:  yes
•PNG Support:  yes
•WBMP Support:  yes
•XPM Support:  yes
•XBM Support:  yes
•JIS-mapped Japanese Font Support:  no

If you don't see "Yes, it does." in large font above, then PHP is not enabled.
/////////////////////////

Are you sure you have php 5.5?

I've Php 5.4 but i think the problem is in these two versions (5.4/5.5).
Title: Re: Whos Online PHP Script for your template site
Post by: JupiterJoe on June 22, 2015, 08:25:55 PM
Sorry to bring up such an old thread, but I couldn't find any results using the search. Has anyone figured this out? I just started getting the PHP errors related to the mysqli and pdo for the who's online script. I'm not sure how to change the script to make it work again without throwing errors up on every page.

yes I have
I also have some errors into my template Saratoga but that I have fix
only the problem with this script  I can not fix
so I hope someone know what to do
 for info I was run V2 from this script and after the update from my server  to PHP 5.5  I saw the error
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in
so I have delete that script and download the new one Whos Online V3  but also this one have the some problem
so I hope for you that your server will not update the PHP to 5.5  if do  you will have the some problems like my

Are you sure you have php 5.5?

I've Php 5.4 but i think the problem is in these two versions (5.4/5.5).
Title: Re: Whos Online PHP Script for your template site
Post by: Stegrie on July 02, 2015, 10:35:08 AM
My Error Problem  is:
"Cannot redeclare geoip-country-code-by-name () in/var/vhosts/wetterstation-johanngeorgenstadt.de/http docs/include-
whos-online-geoip.php on line 379"
Have PHP 5.3.1
Myself can open my Homepage, many other Users will see this Error Message why?
Stefan
Title: Re: Whos Online PHP Script for your template site
Post by: saratogaWX on July 02, 2015, 12:10:38 PM
That message is the result of trying to include() more than once the 'include-whos-online-geoip.php' in the page.  PHP does not allow redefinition of a function once it is defined. 
Title: Re: Whos Online PHP Script for your template site
Post by: Stegrie on July 02, 2015, 12:20:31 PM
And what can i do for this Problem?
Title: Re: Whos Online PHP Script for your template site
Post by: saratogaWX on July 02, 2015, 12:27:50 PM
In your Settings.php, you have
Code: [Select]
# Set timezone in PHP5/PHP4 manner
  if (!function_exists('date_default_timezone_set')) {
     putenv("TZ=" . $SITE['tz']);
     // include the who's online functions
 require ('include-whos-online-header.php');
  $whos_online_records = update_whos_online();
//     print "<!-- using putenv(\"TZ=". $SITE['tz']. "\") -->\n";
    } else {
     date_default_timezone_set($SITE['tz']);
//     print "<!-- using date_default_timezone_set(\"". $SITE['tz']. "\") -->\n";
   }

$SITE['tzname']    = date("T",time());

// include the who's online functions
require ('include-whos-online-header.php');
  $whos_online_records = update_whos_online();
if($SITE['allowThemeSwitch']) {

Change that to
Code: [Select]
# Set timezone in PHP5/PHP4 manner
  if (!function_exists('date_default_timezone_set')) {
     putenv("TZ=" . $SITE['tz']);
//     print "<!-- using putenv(\"TZ=". $SITE['tz']. "\") -->\n";
    } else {
     date_default_timezone_set($SITE['tz']);
//     print "<!-- using date_default_timezone_set(\"". $SITE['tz']. "\") -->\n";
   }

$SITE['tzname']    = date("T",time());

// include the who's online functions
require ('include-whos-online-header.php');
  $whos_online_records = update_whos_online();
if($SITE['allowThemeSwitch']) {
and that should fix the issue.

Title: Re: Whos Online PHP Script for your template site
Post by: Stegrie on July 02, 2015, 12:43:00 PM
Thank you Ken. You're incredible (as always)
Greeting from Germany 
Stefan
Title: Re: Whos Online PHP Script for your template site
Post by: Forever on August 09, 2015, 05:03:54 PM
Hi all :)

I moved my site to a new PC and I'm getting an error when trying to update the GeoLiteCity data. This was working fine on my old PC but was an older version of the script. I'm using the newest version now because the older version was not working with my PHP 5.6.12. This new version of PHP has been giving me lots of problems with deprecated code in a lot of the scripts my side uses. I'm not sure if this is related or I set something up wrong.

I'm getting the following error:
Code: [Select]
PHP Warning: fopen(GeoLiteCity.dat.gz): failed to open stream: Permission denied in C:\inetpub\weathercat\whos-online\wo-update.php on line 353
PHP Fatal error: Call to undefined function error_exit() in C:\inetpub\weathercat\whos-online\wo-update.php on line 353

This is line 353:
Code: [Select]
  $wh = fopen($file_target, 'wb') or error_exit('download_file error: cannot write to file, check server permission settings');
I think I have the path set correctly in the settings and the permission on the geo folder are set correctly.
Can anyone help me get this fixed?
Title: Re: Whos Online PHP Script for your template site
Post by: saratogaWX on August 09, 2015, 05:11:21 PM
I think you're running IIS on a Windows platform (based on the Permission denied in C:\inetpub\weathercat\whos-online\wo-update.php in the error message).  You likely have to give permissions to IIS to open AND write the GeoLiteCity.dat.gz file (that's what the 'w' in the fopen() second argument means, the 'b' means for binary data).

I've found that IIS can be problematic running simple PHP scripts -- if you have the option, I strongly recommend you switch to a Linux/Apache host, or if you're running the server yourself on a home system, installing XAMPP (www.apachefriends.org) and use it instead of IIS .. it will save a lot of headaches in the future.  If you install XAMPP, then make sure to use the Services panel to disable "World Wide Web Publishing Service" (nee "IIS") before starting XAMPP as Apache will want to use port 80/443, which would be occupied by IIS if enabled.
Title: Re: Whos Online PHP Script for your template site
Post by: Forever on August 09, 2015, 05:37:41 PM
Yes it's a windows server running IIS that I have at my house. I know it's harder getting scripts to work but it's what I know and use.

I had this working on my old windows server so I know it can be done, I just need to find out how to give the correct permissions but don't remember what I did last time.
Title: Re: Whos Online PHP Script for your template site
Post by: Forever on August 09, 2015, 07:50:30 PM
I fixed it, I needed to set the server path in more than one spot.  #-o
Title: Re: Whos Online PHP Script for your template site
Post by: ConligWX on August 15, 2018, 12:51:35 PM
This is an old thread but just wondering if others are now getting issues with this script and php 7.2.8?

Started seeing issues with the following error:

Notice: Undefined index: bots in /share/htdocs/weather/whos-online/include-whos-been-online.php on line 190 which is:

Code: [Select]
  echo TEXT_SHOW_BOTS . ': <input type="checkbox" name="bots" value="show" onclick="this.form.submit()"' . ($_GET['bots'] == 'show' ? ' checked="checked"': '') . ' />';
  echo '

if I check the tick box the error goes away.,

unfortunately the script is no long supported which was written by Mike Challis.

Any help would be most appreciated
Title: Re: Whos Online PHP Script for your template site
Post by: ed2kayak on August 15, 2018, 01:05:29 PM
Hello Toxic

Currently on php 7.2.6, not seeing your error currently.

But my map no longer displays  :-(.

http://cvweather.org/whos-online-maps.php

Title: Re: Whos Online PHP Script for your template site
Post by: ConligWX on August 16, 2018, 04:13:12 AM
I think there was a fix for this somewhere out on the net. I know there was about 4-5 files released with fixes a few years back. lemme check....

 [ You are not allowed to view attachments ]  make a backup of your files first and see if this fixes it.

The other issue is this script will need a re-write most as the geolite dat file has stopped and a new version will take its place.

Quote
You have the latest available Maxmind GeoLiteCity database
Note: Maxmind usually updates GeoLiteCity once monthly on the 1st, but sometimes they update on the 2nd or 3rd or even later dates!
Maxmind last updated it 03-27-2018 (142 days ago) this is the newest file available.
You updated to the current GeoLiteCity database on 08-16-2018 (0 days ago), no new updates are available today.


https://dev.maxmind.com/geoip/legacy/geolite/

Quote
Updated versions of the GeoLite Legacy databases are now only available to redistribution license customers, although anyone can continue to download the March 2018 GeoLite Legacy builds. Starting January 2, 2019, the last build will be removed from our website. GeoLite Legacy database users will need to switch to the GeoLite2 or commercial GeoIP databases and update their integrations by January 2, 2019.
Title: Re: Whos Online PHP Script for your template site
Post by: wvdkuil on August 16, 2018, 04:53:59 AM
Hello Toxic

Currently on php 7.2.6, not seeing your error currently.

But my map no longer displays  :-(.

http://cvweather.org/whos-online-maps.php
The map is a background:url
http://cvweather.org/whos-online/wo-worldmap.php?time=1&units=days&map=3&pin=1&pins=off&text=on&textcolor=000000&textshadow=FFFFFF&textalign=cb&ul_lat=0&ul_lon=0&lr_lat=360&lr_lon=180&offset_x=0&offset_y=0&type=jpg
As you (or your hoster) is running your site with error messages turned on, there is a message just before the image.
Code: [Select]
Deprecated: The each() function is deprecated.
This message will be suppressed on further calls in /home/cvweather/www/www/whos-online/wo-worldmap.php on line 333

Warning: Cannot modify header information - headers already sent by (output started at /home/cvweather/www/www/whos-online/wo-worldmap.php:333) in /home/cvweather/www/www/whos-online/wo-worldmap.php on line 234
Solution: Switch af error reporting for your site.
At least switch it off in  whos-online/wo-worldmap.php
Check that script for all lines with either of the two below
Code: [Select]
ini_set('display_errors', 'On');
ini_set('display_errors', '1');
and replace the ini_set with
Code: [Select]
ini_set('display_errors', '0'); That is a literal zero. If you can not find such  a line, replace the first
Code: [Select]
<?php  with
Code: [Select]
<?php  ini_set('display_errors''0');If all fails zip the wo-worldmap.php  script and post it here.
Wim
Title: Re: Whos Online PHP Script for your template site
Post by: ConligWX on August 16, 2018, 05:21:10 AM
Thx Wim

I have added

Code: [Select]
<?php  ini_set('display_errors''0');
to my include-whos-been-online.php since the error seems to be cosmetic and not actually a real error.
Title: Re: Whos Online PHP Script for your template site
Post by: ed2kayak on August 17, 2018, 09:53:00 AM
Thanks for comments.

I have to review my installation, may have multiple issues. Hope to have time in the next few days. Will report back.

Ed
Title: Re: Whos Online PHP Script for your template site
Post by: Forever on January 27, 2019, 10:59:05 AM
My who's online script still works but the data has been stale for a while and now gives an 404 error when trying to update due to changes at Maxmind.com.
Has any tried to fix this?

Code: [Select]
Checking for updates for the Maxmind GeoLiteCity database...
Connecting to this URL: http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
curl_last_mod error: fetching timestamp failed for URL, 404 not found?
Title: Re: Whos Online PHP Script for your template site
Post by: Maumelle Weather on January 27, 2019, 11:05:21 AM
My who's online script still works but the data has been stale for a while and now gives an 404 error when trying to update due to changes at Maxmind.com.
Has any tried to fix this?

Code: [Select]
Checking for updates for the Maxmind GeoLiteCity database...
Connecting to this URL: http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
curl_last_mod error: fetching timestamp failed for URL, 404 not found?

Maxmind no longer has the free GeoLiteCity database.

Edit:  Correction, there is a free DB at Maxmind, but it would take some new coding for our usage. Also, this script is no longer supported by its creator.
Title: Re: Whos Online PHP Script for your template site
Post by: ed2kayak on January 27, 2019, 11:54:55 AM
New error now.

Fatal error: Uncaught Error: Call to undefined function split() in /home/cvweather/www/www/whos-online/include-whos-online-page.php:808 Stack trace: #0 /home/cvweather/www/www/whos-online/include-whos-online-page.php(789): http_last_mod('http://geolite....', 1) #1 /home/cvweather/www/www/whos-online/include-whos-online-page.php(707): curl_last_mod('http://geolite....') #2 /home/cvweather/www/www/whos-online/include-whos-online-page.php(89): check_geoip_date(1527251906) #3 /home/cvweather/www/www/whos-online.php(86): include('/home/cvweather...') #4 {main} thrown in /home/cvweather/www/www/whos-online/include-whos-online-page.php on line 808

 [ You are not allowed to view attachments ]

I also posted on  (https://www.weather-watch.com/smf/index.php/topic,66365.msg542870/topicseen.html#msg542870) not trying to add confusion. Wasn't sure which threads were most current.

Also GeoLiteCity database is different as sacreyweather and Forever noted previously.
Title: Re: Whos Online PHP Script for your template site
Post by: lddaly on January 27, 2019, 01:09:31 PM
If you want to get rid of the error, you can change the file name being checked to the new version. This does not fix the issue of the database not updating, but at least you can access the whos-online page until the script can be updated or removed from your site.

In the include-whos-online-page.php file:
Code: [Select]
// get last updated time of the maxmind geo database remote file
// echo "checking the maxmind timestamp now...<br />";
$remote_file_time = curl_last_mod('https://geolite.maxmind.com/download/geoip/database/GeoLite2-City.tar.gz');
// $remote_file_time = curl_last_mod('http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz');

You will also need to change the split command to explode if you are running PHP7.
Title: Re: Whos Online PHP Script for your template site
Post by: ed2kayak on January 27, 2019, 01:51:22 PM
Thanks Iddaly that fixed it at least temporarily.
Didn't have to change the split command. I am running PHP7
Title: Re: Whos Online PHP Script for your template site
Post by: ConligWX on January 27, 2019, 05:53:55 PM
does anyone have an upto date GeoLiteCity.dat file I can download?
Title: Re: Whos Online PHP Script for your template site
Post by: jmcmurry on January 27, 2019, 07:42:38 PM
This thread contains what folks came up with for this problem http://www.wxforum.net/index.php?topic=34808.msg354751#msg354751

- Jim
Title: Re: Whos Online PHP Script for your template site
Post by: lddaly on January 27, 2019, 09:08:50 PM
This thread contains what folks came up with for this problem http://www.wxforum.net/index.php?topic=34808.msg354751#msg354751

- Jim

Thanks Jim. Since the GeoLite Legacy databases were discontinued on January 2, 2019, the script would need to be updated to support the new GeoLite2-City.mmdb format.

Has Ken (or someone else) taken over Mike Challis's legacy PHP Scripts that he is no longer supporting? I guess that is the question a few of us need answered. If not, we will just remove them from our site.

Regards.
Title: Re: Whos Online PHP Script for your template site
Post by: ConligWX on January 28, 2019, 04:36:51 AM
I just touched the filedate on mine so whos-online script thinks its a new file.
Title: Re: Whos Online PHP Script for your template site
Post by: Otis on January 28, 2019, 07:06:14 AM
This thread contains what folks came up with for this problem http://www.wxforum.net/index.php?topic=34808.msg354751#msg354751

- Jim

Thanks Jim. Since the GeoLite Legacy databases were discontinued on January 2, 2019, the script would need to be updated to support the new GeoLite2-City.mmdb format.

Has Ken (or someone else) taken over Mike Challis's legacy PHP Scripts that he is no longer supporting? I guess that is the question a few of us need answered. If not, we will just remove them from our site.

Regards.

I don't use the subject script but here is a link to the Legacy Scripts that Ken is supporting.
https://saratoga-weather.org/scripts-legacy.php (https://saratoga-weather.org/scripts-legacy.php)
Title: Re: Whos Online PHP Script for your template site
Post by: gwwilk on January 28, 2019, 11:08:03 AM
I just touched the filedate on mine so whos-online script thinks its a new file.
Worked for me, too.  I suspect that this is the best we can do for now.
Title: Re: Whos Online PHP Script for your template site
Post by: AWL on January 28, 2019, 11:22:43 AM
I just touched the filedate on mine so whos-online script thinks its a new file.
Worked for me, too.  I suspect that this is the best we can do for now.

Could you please explain "touched" to someone of limited knowledge?

Thanks, Doug
Title: Re: Whos Online PHP Script for your template site
Post by: ConligWX on January 28, 2019, 12:18:11 PM
When you touch a file, the file date changes nothing else, contents remain the same.

Sent from my ONEPLUS A6003 using Tapatalk

Title: Re: Whos Online PHP Script for your template site
Post by: gwwilk on January 28, 2019, 01:27:25 PM
I just touched the filedate on mine so whos-online script thinks its a new file.
Worked for me, too.  I suspect that this is the best we can do for now.

Could you please explain "touched" to someone of limited knowledge?

Thanks, Doug
Touch is a Linux command that only updates the file time.  I accessed my website's file system via my ftp login and 'SmarTTY' to get to a command line.  From there I used a 'cd' (change directory) command to get to the root, 'cd /'.  Then I used Ken True's 'check-fetch-times.php' to find the true Linux directory of my site following which I pasted this directory into a 'cd ' command in the TTY window.  After doing an 'ls' (list directory) command to be certain I was where I wanted to be, I merely issued a 'cd /whose-online' to access this directory where I did another 'ls' and then  'touch GeoLiteCity.dat' to update the file time.

This can be a VERY dangerous process which if you screw it up can hose your web site.  PROCEED WITH EXTREME CAUTION!  If you've never played around with Linux, this probably wouldn't be the way to start.
Title: Re: Whos Online PHP Script for your template site
Post by: jmcmurry on January 28, 2019, 02:09:30 PM
This may be a better alternative.  I tried using several online lookup sites and settled on https://ipapi.co/ as the best.  Their free plan is limited to 30,000 lookups/month which is more than adequate for my little hobby web site.  So, save a copy of your files and then try this if you wish.  - Jim

In include-whos-online-page.php I commented out the lines that contained "TEXT_LAST_UPDATED" so I wouldn't get the update messages.

Then in include-whos-online-header.php I renamed the function get_location_info to old_get_location_info and added the following right above it:

Code: [Select]
function get_location_info($user_ip) {
global $C; 

$ch = curl_init('https://ipapi.co/'.$user_ip.'/json/');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Macintosh; Intel Mac OS X x.y; rv:42.0) Trident/5.0 Firefox/42.0');
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);                 // connection timeout
curl_setopt($ch, CURLOPT_TIMEOUT, 5);                        // data timeout
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);              // return the data transfer
curl_setopt($ch, CURLOPT_NOBODY, false);                     // set nobody
$json = curl_exec($ch);
curl_close($ch);
$record = json_decode($json, true);
if (strpos($json,"error") == 0 && $record[country_name] != "") {
$record[city] = str_replace("City of ", "", $record[city]);
$location_info = array();    // Create Result Array
$location_info['provider']     = '';
$location_info['city_name']    = $record[city];
$location_info['state_name']   = $record[region];
$location_info['state_code']   = strtoupper($record[region_code]);
$location_info['country_name'] = ($record[country_name] != '') ? $record[country_name] : '--';
$location_info['country_code'] = ($record[country] != '') ? strtoupper($record[country]) : '--';
$location_info['latitude']     = ($record[latitude]  != '') ? $record[latitude]  : '0';
$location_info['longitude']    = ($record[longitude] != '') ? $record[longitude] : '0';
} else {
$location_info = old_get_location_info($user_ip);         // use the outdated database
}
return $location_info;
}
Title: Re: Whos Online PHP Script for your template site
Post by: gwwilk on January 28, 2019, 02:21:36 PM
This may be a better alternative.  I tried using several online lookup sites and settled on https://ipapi.co/ as the best.  Their free plan is limited to 30,000 lookups/month which is more than adequate for my little hobby web site.  So, save a copy of your files and then try this if you wish.  - Jim

In include-whos-online-page.php I commented out the lines that contained "TEXT_LAST_UPDATED" so I wouldn't get the update messages.

Then in include-whos-online-header.php I renamed the function get_location_info to old_get_location_info and added the following right above it:

Code: [Select]
function get_location_info($user_ip) {
global $C; 

$ch = curl_init('https://ipapi.co/'.$user_ip.'/json/');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Macintosh; Intel Mac OS X x.y; rv:42.0) Trident/5.0 Firefox/42.0');
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);                 // connection timeout
curl_setopt($ch, CURLOPT_TIMEOUT, 5);                        // data timeout
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);              // return the data transfer
curl_setopt($ch, CURLOPT_NOBODY, false);                     // set nobody
$json = curl_exec($ch);
curl_close($ch);
$record = json_decode($json, true);
if (strpos($json,"error") == 0 && $record[country_name] != "") {
$record[city] = str_replace("City of ", "", $record[city]);
$location_info = array();    // Create Result Array
$location_info['provider']     = '';
$location_info['city_name']    = $record[city];
$location_info['state_name']   = $record[region];
$location_info['state_code']   = strtoupper($record[region_code]);
$location_info['country_name'] = ($record[country_name] != '') ? $record[country_name] : '--';
$location_info['country_code'] = ($record[country] != '') ? strtoupper($record[country]) : '--';
$location_info['latitude']     = ($record[latitude]  != '') ? $record[latitude]  : '0';
$location_info['longitude']    = ($record[longitude] != '') ? $record[longitude] : '0';
} else {
$location_info = old_get_location_info($user_ip);         // use the outdated database
}
return $location_info;
}
This code is working on my site. Thanks, Jim :!:
Title: Re: Whos Online PHP Script for your template site
Post by: the beteljuice on January 28, 2019, 09:06:19 PM
the betejuice was just playing with IP look-up.

Try http://ip-api.com - free, 150 req / min = 9000 / hr !!!! (your option is 1000 / day)

No need for curl
I used:
Code: [Select]
     $data = file_get_contents("http://ip-api.com/json/".$_SERVER['REMOTE_ADDR']);
   $data = json_decode($data, true);
... and of course you would have to change some of the $record['?????']
http://beteljuice.co.uk/DEMOS/who.php

I tried HTML5 geolocate and found it was inaccurate even though it said it was within a 400 yards.
Although that is from a 'real' PC and not a GPS enabled device.