whos-online with php 7.2.2? (resolved!)

Ken,

Today I decided to upgrade to PHP 7.x.x. In all 7x versions I get this error message when I try to load my webpage:

Fatal error: Uncaught Error: Call to undefined function mysqli_connect() in /home/thanos/public_html/whos-online/include-whos-online-header.php:124 Stack trace: #0 /home/thanos/public_html/Settings.php(357): update_whos_online() #1 /home/thanos/public_html/index.php(30): require_once(‘/home/thanos/pu…’) #2 {main} thrown in /home/thanos/public_html/whos-online/include-whos-online-header.php on line 124

I know that the errors come from the script “who’s on line” and probably is not compatible with PHP 7.x.x or current MySQL version. I wonder if there’s a workaround for this issue.
I rolled back to PHP version 5.6.33 where it is working fine.

Locally in my pc it runs fine with the latest XAMPP package, having PHP version 7.2.2 running!

Thanks,

Thanos

Issue resolved!

I just installed all the PHP extensions needed for PHP versions 7.x like “php-mysqli” and all problems that appeared are gone! #-o

The new EasyApache 4 in CPanel is more flexible than EasyApache 3 but more complex too, to configure your server! :wink:

Thanks,

Thanos

I was just going to post on this. As I am upgrading to php 7…

It all breaks on these functions.

$wo_dbh = mysql_connect($C['dbhost'], $C['dbuser'], $C['dbpass']);
if (!$wo_dbh) die('Could not connect: ' . mysql_error($wo_dbh));
mysql_select_db($C['dbname'],$wo_dbh) or die(mysql_error($wo_dbh));

if there is someone who knows how to fix this that would be great, but those functions dont work in php 7. I tried to use the new functions, but really dont know what I’m doing that much and never got it to work.

Any fixes would be great.

so I found this on wxforum.net in a thread referenced by Ken.

http://discourse.weather-watch.com/p/481901

these are from “forever” not mine…

This now works under php 7.1. My host still has some issues with 7.2 so I cant try that version yet.


Whos-Online.zip (32.7 KB)

I applied that fix at that time when Ken kindly released it to the community! At that time, I upgraded to PHP 5.6.

Yesterday, I upgraded PHP to version 7.2 and all the problems that appeared, were due to missing PHP extensions, needed to run all the scripts.

Unfortunately, when a new major PHP version gets installed (by CPanel in my case), only the basic PHP extensions are installed too! So, many scripts have problems with functions mostly, operated by extensions!

Now, everything looks to be working fine in PHP 7.2.2! Of course I’m constantly checking and applying all the new updates that Ken releases for Saratoga template. :wink:

Thanos

No problem here in Italy with PHP 7.x :wink:

Hi guys,
i’ve seen my whos online scripthas gone.
I’m using PHP 7.0.x

What about your version?

Link here: http://www.meteopistoia.it/whos-online.php

Thank you so much for any help.
Regards,

Alessandro

http://cvweather.org/whos-online.php
Now getting this error

curl_last_mod error: fetching timestamp failed for URL, 404 not found?

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

@ed2kayak: split() is deprecated as of php 5.3. Ken posted a link to a later version of the script in this thread.

Thanks Niko,

One of apparently many updates I’ve missed the last few years, from not paying close attention. #-o

anyone have an update using new geodata?’

https://support.maxmind.com/geolite-legacy-discontinuation-notice/
this script uses the old data

I haven’t heard of anyone figuring out how to use the new data, but I posted the following to a discussion on WXForum.

"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:"

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;
}

Nice one Jim :smiley:

hi to you all
I see this is a old topic but I am try to fix the script again
I have edit the files but now I have this error
Fatal error: error traversing GeoLite City database file - perhaps it is corrupt? Try reinstalling it. in /home/domains/weerstation-woerden.nl/public_html/whos-online/include-whos-online-geoip.php on line 454
have someone a complet working script

greetings Gert