Please read the posts in the Announcements section about the current status of Cumulus development now that I have retired

Please read this post before posting

Latest Cumulus release v1.9.4 (build 1099) - Nov 28 2014
Latest Cumulus MX release - v3.0.0 build 3043 Jan 20 2017. See this post for download

PHP Deprecated error RESOLVED

Other discussion about creating web sites for Cumulus that doesn't have a specific subforum

Moderators: daj, TNETWeather

User avatar
PaulMy
Posts: 1679
Joined: Sun Sep 28, 2008 11:54 pm
Weather Station: Davis Vantage Pro 2 w/Envoy USB
Operating System: Windows-8
Location: Komoka, ON Canada
Contact:

PHP Deprecated error RESOLVED

Postby PaulMy » Thu Apr 12, 2018 4:14 pm

I have come to realize that I have a lot of errors in my website folders and beginning to work on fixing those. Some of these are likely caused by my adapting some posted scripts here and modifying incorrectly. Some of the errors appear to be due to deprecated code. One particular is from my once a minute cron job to import realtime.txt in my MySQL DB and this continued to add to the error_log.txt file which is getting quite large.

[12-Apr-2018 15:49:25 UTC] PHP Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/psoykkrhjuz3/public_html/weather/ImportCumulusFile.php on line 234


Line 234 is

Code: Select all

  // Connect to the datbase
    $con = mysql_connect($dbhost, $dbuser, $dbpassword);


I have attempted to change this line to mysqli_connect() but that crashes the script. ImportCumulusFile.php has several lines of such mysql_ but only the first one shows in the error_log.

What changews should I make to eliminate these errorsÉ

Thanks,
Paul
Last edited by PaulMy on Fri Apr 13, 2018 2:56 pm, edited 1 time in total.

User avatar
mcrossley
Posts: 5147
Joined: Thu Jan 07, 2010 9:44 pm
Weather Station: Davis VP2
Operating System: Stretch Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: PHP Deprecated error

Postby mcrossley » Thu Apr 12, 2018 4:17 pm

Paul, you just need a newer version of the file, I changed it to mysqli some time ago.

User avatar
PaulMy
Posts: 1679
Joined: Sun Sep 28, 2008 11:54 pm
Weather Station: Davis Vantage Pro 2 w/Envoy USB
Operating System: Windows-8
Location: Komoka, ON Canada
Contact:

Re: PHP Deprecated error

Postby PaulMy » Thu Apr 12, 2018 4:52 pm

Thanks Mark, forgot to check the basics...
However, I have edited the v.3.1 with my DB info and the cron job fails and DB not updated. Cron job details are:

Code: Select all

Fetched URL
http://www.komokaweather.com/weather/ImportCumulusFile.php?type=realtime&key=xxxxx&table=realtime&file=realtime.txt
Status
500 Internal Server Error


I have used the same DB info and key as the previous version. Will look deeper but if any suggestion that is welcome.

Paul

User avatar
mcrossley
Posts: 5147
Joined: Thu Jan 07, 2010 9:44 pm
Weather Station: Davis VP2
Operating System: Stretch Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: PHP Deprecated error

Postby mcrossley » Thu Apr 12, 2018 5:28 pm

Oh dear, can you get the error log from the server and see what the actual error was - HTTP error 500 is a generic "something went wrong" that doesn't tell you anything.

User avatar
PaulMy
Posts: 1679
Joined: Sun Sep 28, 2008 11:54 pm
Weather Station: Davis Vantage Pro 2 w/Envoy USB
Operating System: Windows-8
Location: Komoka, ON Canada
Contact:

Re: PHP Deprecated error

Postby PaulMy » Thu Apr 12, 2018 6:17 pm

Thanks Mark,
When I run the new version 3.1 from URL http://www.komokaweather.com/weather/Im ... me.txt(not through cron-job) I get
Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at webmaster@komokaweather.com to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.


and nothing shows on webserver error_log.txt

I have compared the version 2.3 I have been using (and changed back to now so my cron jobs can run) to the new v3.1 and all the DB settings seem identical (I don't use the dbconfig.php with this script)
The other differences between v3.1 and v2.3 are too complex for me to understand and are mainly below the --------- Nothing to edit below here -------------- area.

Paul

User avatar
mcrossley
Posts: 5147
Joined: Thu Jan 07, 2010 9:44 pm
Weather Station: Davis VP2
Operating System: Stretch Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: PHP Deprecated error

Postby mcrossley » Thu Apr 12, 2018 7:53 pm

Version 2.7 made the change to mysqli, so maybe give that file whirl as it is closest to the version you have now?

User avatar
mcrossley
Posts: 5147
Joined: Thu Jan 07, 2010 9:44 pm
Weather Station: Davis VP2
Operating System: Stretch Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: PHP Deprecated error

Postby mcrossley » Thu Apr 12, 2018 7:56 pm

Actually, I just read the readme properly myself, there are two database changes you would have to make going from 2.3 -> 3.1 Though neither affect the realtime table :(

There is just one going from 2.3 -> 2.7

Code: Select all

ALTER TABLE `dayfile` CHANGE `HighSolarRad` `HighSolarRad` DECIMAL(5,1) NULL DEFAULT NULL


As always make a copy of the table before altering it so you can quickly switch back again.

User avatar
PaulMy
Posts: 1679
Joined: Sun Sep 28, 2008 11:54 pm
Weather Station: Davis Vantage Pro 2 w/Envoy USB
Operating System: Windows-8
Location: Komoka, ON Canada
Contact:

Re: PHP Deprecated error -SOLVED

Postby PaulMy » Fri Apr 13, 2018 12:33 am

Thanks Mark,
Finally resolved using v2.7 and no errors being logged. However I had to change one line:
My previous v2.3 had line 181 as: die('Error: Failed security key check:' . $param_key . ' ' . $key);
The v2.7 download had line 199 : die('Error: Failed security key check:' . $param_key);
I changed line 199 in v2.7 to : die('Error: Failed security key check:' . $param_key . ' ' . $key);

Paul

sfws
Posts: 409
Joined: Fri Jul 27, 2012 11:29 am
Weather Station: Customised Fine Offset
Operating System: off-line Vista and W10 PCs
Location: UK

Re: PHP Deprecated error

Postby sfws » Fri Apr 13, 2018 5:22 am

PaulMy wrote:The v2.7 download had line 199 : die('Error: Failed security key check:' . $param_key);
I changed line 199 in v2.7 to : die('Error: Failed security key check:' . $param_key . ' ' . $key);

While I don't use Mark's script, and so I am not absolutely sure what the two variables are you that you mention, I can hazard a good guess from the message I have coloured up.

I am pretty sure Mark removed the second variable deliberately, what is the point of having a hidden key controlling write access if a failure to use it tells the hacker the key they should have used!

Post Script Edit: actually I have just looked at Mark's versions list
// ver 2.6 - 02/04/14, Mark Crossley * Fixed PHP vulnerability that could reveal the passcode
and see I am right.


I know you don't understand much PHP, Paul, but even you might guess that what is included in die messages has no effect on subsequent processing as the die instruction exits the code parsing.

User avatar
mcrossley
Posts: 5147
Joined: Thu Jan 07, 2010 9:44 pm
Weather Station: Davis VP2
Operating System: Stretch Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: PHP Deprecated error

Postby mcrossley » Fri Apr 13, 2018 1:18 pm

Odd Paul, as sfws said, that line will not affect the rest of the script, and you should really use the version from 2.7 for security.

Anyway, glad you got v2.7 going in the end, it should fix your original "Deprecated" error.

User avatar
PaulMy
Posts: 1679
Joined: Sun Sep 28, 2008 11:54 pm
Weather Station: Davis Vantage Pro 2 w/Envoy USB
Operating System: Windows-8
Location: Komoka, ON Canada
Contact:

Re: PHP Deprecated error RESOLVED

Postby PaulMy » Fri Apr 13, 2018 2:56 pm

Maybe a red herring yesterday, but when I first ran v2.7 it popped up some message for that line. I then compared to the previous working version and found the difference and changed the line and then it worked - nothing else done at the time. And yes :oops: I did not catch and understand the significance of that code difference.

So this morning went back to the original v2.7 without my edit, and it still works. I presume now as intended.

One deprecated issue resolved!

Thanks all for your assistance,
Paul


Return to “Web site - General”

Who is online

Users browsing this forum: No registered users and 8 guests