cloudy cloudy

Author Topic: whos-online with php 7.2.2? (resolved!)  (Read 1501 times)

0 Members and 1 Guest are viewing this topic.

Offline atsio

  • Weather at Thessaloniki - Northern Greece.
  • Posts: 418
  • Macedonia is GREECE! Study history!
  • Thessaloniki - Greece
  • OS/Browser:
  • Win NT 10.0
  • Chrome 64.0.3282.168
    • Weather conditions at Thessaloniki Historical Center-Central Macedonia-Greece
whos-online with php 7.2.2? (resolved!)
« on: March 03, 2018, 12:35:44 PM »
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
« Last Edit: March 03, 2018, 04:31:05 PM by atsio »

Offline atsio

  • Weather at Thessaloniki - Northern Greece.
  • Posts: 418
  • Macedonia is GREECE! Study history!
  • Thessaloniki - Greece
  • OS/Browser:
  • Win NT 10.0
  • Chrome 64.0.3282.168
    • Weather conditions at Thessaloniki Historical Center-Central Macedonia-Greece
Re: whos-online with php 7.2.2?
« Reply #1 on: March 03, 2018, 04:30:28 PM »
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
« Last Edit: March 03, 2018, 04:33:38 PM by atsio »

Offline tman1991

  • Posts: 703
  • Tucson, AZ (US)
  • OS/Browser:
  • Win NT 10.0
  • Firefox 58.0
    • Countryside Manor
Re: whos-online with php 7.2.2? (resolved!)
« Reply #2 on: March 03, 2018, 09:01:50 PM »
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.

Offline tman1991

  • Posts: 703
  • Tucson, AZ (US)
  • OS/Browser:
  • Win NT 10.0
  • Firefox 58.0
    • Countryside Manor
Re: whos-online with php 7.2.2? (resolved!)
« Reply #3 on: March 03, 2018, 09:38:12 PM »
so I found this on wxforum.net in a thread referenced by Ken.

https://www.weather-watch.com/smf/index.php/topic,62375.msg498945.html#msg498945

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.

Offline atsio

  • Weather at Thessaloniki - Northern Greece.
  • Posts: 418
  • Macedonia is GREECE! Study history!
  • Thessaloniki - Greece
  • OS/Browser:
  • Win NT 10.0
  • Chrome 64.0.3282.168
    • Weather conditions at Thessaloniki Historical Center-Central Macedonia-Greece
Re: whos-online with php 7.2.2? (resolved!)
« Reply #4 on: March 04, 2018, 05:07:57 PM »
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

Offline i_fiorentino

  • Alessandro Bardi
  • Posts: 1,699
  • 150 mls Candeglia (Pt), Tuscany, Italy
  • OS/Browser:
  • Win NT 10.0
  • Chrome 65.0.3325.162
    • Meteopistoia.it
Re: whos-online with php 7.2.2? (resolved!)
« Reply #5 on: March 18, 2018, 09:51:16 AM »
No problem here in Italy with PHP 7.x  :wink:

Offline i_fiorentino

  • Alessandro Bardi
  • Posts: 1,699
  • 150 mls Candeglia (Pt), Tuscany, Italy
  • OS/Browser:
  • Win NT 10.0
  • Chrome 71.0.3578.98
    • Meteopistoia.it
Re: whos-online with php 7.2.2? (resolved!)
« Reply #6 on: January 05, 2019, 01:41:11 PM »
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

Offline ed2kayak

  • CoCoRaHS PA-CD-6, Weather Underground KPAMECHA7, CWOP DW5425
  • Posts: 458
  • Mechanicsburg PA
  • OS/Browser:
  • Win NT 10.0
  • Chrome 71.0.3578.98
    • Cumberland Valley Weather
Re: whos-online with php 7.2.2? (resolved!)
« Reply #7 on: January 27, 2019, 03:40:37 AM »
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
Ed
CoCoRaHS PA-CD-6,  Weather Underground KPAMECHA7, CWOP DW5425

Offline niko

  • syzygy
  • Global Moderator
  • Posts: 27,986
  • Crystal Ball broken! Please post the URL.
  • Northern California, U.S.A.
  • OS/Browser:
  • Win 7/Srvr 2008R2
  • Chrome 71.0.3578.98
Re: whos-online with php 7.2.2? (resolved!)
« Reply #8 on: January 27, 2019, 02:26:45 PM »
@ed2kayak: split() is deprecated as of php 5.3. Ken posted a link to a later version of the script in this thread.

Offline ed2kayak

  • CoCoRaHS PA-CD-6, Weather Underground KPAMECHA7, CWOP DW5425
  • Posts: 458
  • Mechanicsburg PA
  • OS/Browser:
  • Win NT 10.0
  • Chrome 71.0.3578.98
    • Cumberland Valley Weather
Re: whos-online with php 7.2.2? (resolved!)
« Reply #9 on: January 27, 2019, 03:54:05 PM »
Thanks Niko,

One of apparently many updates I've missed the last few years, from not paying close attention. #-o
Ed
CoCoRaHS PA-CD-6,  Weather Underground KPAMECHA7, CWOP DW5425

Offline tman1991

  • Posts: 703
  • Tucson, AZ (US)
  • OS/Browser:
  • Win NT 10.0
  • Firefox 66.0
    • Countryside Manor
Re: whos-online with php 7.2.2? (resolved!)
« Reply #10 on: April 08, 2019, 07:39:16 PM »
anyone have an update using new geodata?'

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

Offline jmcmurry

  • Jim McMurry
  • Posts: 2,833
  • Mauston, WI, USA
  • OS/Browser:
  • Win 7/Srvr 2008R2
  • Firefox 66.0
    • Juneau County Weather
Re: whos-online with php 7.2.2? (resolved!)
« Reply #11 on: April 09, 2019, 11:44:32 PM »
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:"

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 niko

  • syzygy
  • Global Moderator
  • Posts: 27,986
  • Crystal Ball broken! Please post the URL.
  • Northern California, U.S.A.
  • OS/Browser:
  • Win 7/Srvr 2008R2
  • Chrome 73.0.3683.86
Re: whos-online with php 7.2.2? (resolved!)
« Reply #12 on: April 10, 2019, 12:04:30 AM »
Nice one Jim  :D

 

cumulus