Author Topic: Whos Online PHP Script for your template site  (Read 33846 times)

0 Members and 1 Guest are viewing this topic.

Offline ed2kayak

  • Ed
  • Forecaster
  • *****
  • Posts: 613
  • Davis Vantage Pro2 w/12 hr FARS, solar/uv
    • Cumberland Valley Weather
Re: Whos Online PHP Script for your template site
« Reply #100 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

Ed
CoCoRaHS PA-CD-6,  Weather Underground KPAMECHA7, CWOP DW5425

Offline ConligWX

  • Forecaster
  • *****
  • Posts: 836
  • #conligwx
    • conligwx.org
Re: Whos Online PHP Script for your template site
« Reply #101 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.
« Last Edit: August 16, 2018, 04:34:56 AM by Toxic »
Regards Simon
Davis Vantage Pro2 Plus (6162UK) • Daytime FARS • WeatherLink Live • AirLink • PurpleAir PA-II-SD • CumulusMX •


Offline wvdkuil

  • Wim van der kuil
  • Forecaster
  • *****
  • Posts: 1986
    • My PWS at Leuven Belgium Europe
Re: Whos Online PHP Script for your template site
« Reply #102 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
« Last Edit: August 16, 2018, 05:01:52 AM by wvdkuil »

Offline ConligWX

  • Forecaster
  • *****
  • Posts: 836
  • #conligwx
    • conligwx.org
Re: Whos Online PHP Script for your template site
« Reply #103 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.
Regards Simon
Davis Vantage Pro2 Plus (6162UK) • Daytime FARS • WeatherLink Live • AirLink • PurpleAir PA-II-SD • CumulusMX •


Offline ed2kayak

  • Ed
  • Forecaster
  • *****
  • Posts: 613
  • Davis Vantage Pro2 w/12 hr FARS, solar/uv
    • Cumberland Valley Weather
Re: Whos Online PHP Script for your template site
« Reply #104 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
Ed
CoCoRaHS PA-CD-6,  Weather Underground KPAMECHA7, CWOP DW5425

Offline Forever

  • Senior Contributor
  • ****
  • Posts: 209
Re: Whos Online PHP Script for your template site
« Reply #105 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?

Offline Maumelle Weather

  • Forecaster
  • *****
  • Posts: 1824
    • Maumelle Weather
Re: Whos Online PHP Script for your template site
« Reply #106 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.
« Last Edit: January 27, 2019, 11:13:30 AM by sacreyweather »
GR2AE, GR3, Cumulus

Offline ed2kayak

  • Ed
  • Forecaster
  • *****
  • Posts: 613
  • Davis Vantage Pro2 w/12 hr FARS, solar/uv
    • Cumberland Valley Weather
Re: Whos Online PHP Script for your template site
« Reply #107 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.
Ed
CoCoRaHS PA-CD-6,  Weather Underground KPAMECHA7, CWOP DW5425

Offline lddaly

  • Forecaster
  • *****
  • Posts: 490
Re: Whos Online PHP Script for your template site
« Reply #108 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.
« Last Edit: January 27, 2019, 01:15:43 PM by lddaly »

Offline ed2kayak

  • Ed
  • Forecaster
  • *****
  • Posts: 613
  • Davis Vantage Pro2 w/12 hr FARS, solar/uv
    • Cumberland Valley Weather
Re: Whos Online PHP Script for your template site
« Reply #109 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
Ed
CoCoRaHS PA-CD-6,  Weather Underground KPAMECHA7, CWOP DW5425

Offline ConligWX

  • Forecaster
  • *****
  • Posts: 836
  • #conligwx
    • conligwx.org
Re: Whos Online PHP Script for your template site
« Reply #110 on: January 27, 2019, 05:53:55 PM »
does anyone have an upto date GeoLiteCity.dat file I can download?
Regards Simon
Davis Vantage Pro2 Plus (6162UK) • Daytime FARS • WeatherLink Live • AirLink • PurpleAir PA-II-SD • CumulusMX •


Offline jmcmurry

  • Jim McMurry
  • Forecaster
  • *****
  • Posts: 528
  • Davis Vantage Pro 2 Plus Wireless.
    • Juneau County Weather
Re: Whos Online PHP Script for your template site
« Reply #111 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

Forum Search and Google Can be Your Best Friends

Offline lddaly

  • Forecaster
  • *****
  • Posts: 490
Re: Whos Online PHP Script for your template site
« Reply #112 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.

Offline ConligWX

  • Forecaster
  • *****
  • Posts: 836
  • #conligwx
    • conligwx.org
Re: Whos Online PHP Script for your template site
« Reply #113 on: January 28, 2019, 04:36:51 AM »
I just touched the filedate on mine so whos-online script thinks its a new file.
Regards Simon
Davis Vantage Pro2 Plus (6162UK) • Daytime FARS • WeatherLink Live • AirLink • PurpleAir PA-II-SD • CumulusMX •


Offline Otis

  • (aka Paul)
  • Forecaster
  • *****
  • Posts: 724
    • Lake Huron Weather
Re: Whos Online PHP Script for your template site
« Reply #114 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

CW3699

Offline gwwilk

  • Southeast Lincoln Weather
  • Forecaster
  • *****
  • Posts: 2578
    • SouthEast Lincoln, NE Weather
Re: Whos Online PHP Script for your template site
« Reply #115 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.
Regards, Jerry Wilkins
gwwilk@gmail.com

Offline AWL

  • Forecaster
  • *****
  • Posts: 727
    • Ardmore Weather Live
Re: Whos Online PHP Script for your template site
« Reply #116 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

Offline ConligWX

  • Forecaster
  • *****
  • Posts: 836
  • #conligwx
    • conligwx.org
Re: Whos Online PHP Script for your template site
« Reply #117 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

Regards Simon
Davis Vantage Pro2 Plus (6162UK) • Daytime FARS • WeatherLink Live • AirLink • PurpleAir PA-II-SD • CumulusMX •


Offline gwwilk

  • Southeast Lincoln Weather
  • Forecaster
  • *****
  • Posts: 2578
    • SouthEast Lincoln, NE Weather
Re: Whos Online PHP Script for your template site
« Reply #118 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.
Regards, Jerry Wilkins
gwwilk@gmail.com

Offline jmcmurry

  • Jim McMurry
  • Forecaster
  • *****
  • Posts: 528
  • Davis Vantage Pro 2 Plus Wireless.
    • Juneau County Weather
Re: Whos Online PHP Script for your template site
« Reply #119 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;
}

Forum Search and Google Can be Your Best Friends

Offline gwwilk

  • Southeast Lincoln Weather
  • Forecaster
  • *****
  • Posts: 2578
    • SouthEast Lincoln, NE Weather
Re: Whos Online PHP Script for your template site
« Reply #120 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 :!:
Regards, Jerry Wilkins
gwwilk@gmail.com

Offline the beteljuice

  • the beteljuice
  • Forecaster
  • *****
  • Posts: 316
    • test site
Re: Whos Online PHP Script for your template site
« Reply #121 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.
« Last Edit: January 28, 2019, 09:10:09 PM by beteljuice »
Imagine what you will KNOW tomorrow !

 

anything