Skip to Content
It is currently November 30th, 2021, 2:01 pm

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: October 11th, 2021, 3:42 pm 
Offline
SVS Member
SVS Member

Joined: December 6th, 2004, 9:00 am
Posts: 8295
Location: Cologne (Germany)
PHP 8 is almost 1 year old now, so I think it's time to think about an upgrade.
I won't help with adjusting the old templates from SAM 4.7.3 and older, but if you already upgraded to SAM 2018.3, updating the templates is an easy fix.

Basically the only thing remaining to be changed is the use of while(list($x,$y) = each($z)).
That was never a great style to use, but it was legal until PHP 7.2 and was still tolerated in PHP 7.3/7.4, but you did get a deprecation warning in those versions.
It looks like the code for SAM's PHP template was written by 2 different persons, one who knew PHP and one who had no clue what they were doing and just copied a tutorial from PHP3 or even older (that technique was outdated already when SAM was released 20 years ago and even more so when they released their rebranded templates 10 years ago)

The fix is replacing all occurences of the above pattern (variable names will vary slightly throughout the code) with foreach($z as $x => $y).
Usually these are accompanied with a reset($z) in front.

There's one in code/code.playlist.php, one in code/classes/class.song.php and several in library\Common\form.php and library\Common\xml.php:

Without replacing these, the templates will not be able to start a database connection and show an error message.
If you forget to fix the files in /code, the search function won't work, but it should be fine otherwise.

Attached is a zip file containing an updated samPHPweb folder with the PHP8 compatible templates. I removed the config folder, so if you didn't make any changes to the templates themselves, you should be able to unzip this file on top of your PHP files without having to change anything. (your database and other config will remain untouched)


Attachments:
File comment: samPHPweb updated for PHP8, Overwrite your own files, does not include the config directory!!!
sam-php-8.zip [281.58 KiB]
Downloaded 110 times

_________________
Benedikt Bauer - SVS (Spacial Volunteer Support)

Shop for readymade PAL scripts by countrywesterndj - Or get a custom script made by me (or others)

My Project:
Send "Now Playing" from SAM to Twitter and/or Facebook | Sourcecode
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 11 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group