SimplePortal

Development => Bugs => Topic started by: Chen Zhen on May 15, 2018, 01:09:12 PM

Title: blocks showing user avatars
Post by: Chen Zhen on May 15, 2018, 01:09:12 PM

re. any blocks showing user avatars

Most forums as of late use TLS/SSL ( https ) therefore some changes need to be made to how avatars are possibly rendered in blocks.
The current coding contains this for checking avatar url's:
Code: [Select]
stristr($row['avatar'], 'http://') ? ...

Imo the way it is being used (true or false) should be stripos instead of stristr & it should be checking both http & https.

ie.
create a new function to be used in the block php file (perhaps put in subs file)
Code: [Select]
function sp_stripos_array($string, $array)
{
$array = !is_array($array) ? array($array) : $array;
foreach ($array as $find)
if (stripos($string, $find) !== false)
return true;

return false;
}

.. and now replace existing code to be used like this:
Code: [Select]
sp_stripos_array($row['avatar'], array('http://', 'https://')) ? ...
Title: Re: blocks showing user avatars
Post by: hulapyk on November 15, 2018, 06:46:41 AM
Is this what's causing url avatars to show as an error in the various blocks?
If so, should I replace all stristr($row['avatar'], 'http://') ? with your code?

Or is it another issue?

Thanks in advance.
Title: Re: blocks showing user avatars
Post by: Chen Zhen on November 15, 2018, 09:05:24 AM
First you will need to add the new function to ie. /Sources/Subs-Portal.php & then you can replace the instances that were referenced.
I should make a tool to do this.
Title: Re: blocks showing user avatars
Post by: hulapyk on November 15, 2018, 09:22:30 AM
You planning on doing that then? Then I'd rather wait  :P
Title: Re: blocks showing user avatars
Post by: Chen Zhen on November 15, 2018, 01:19:27 PM
No, there is something wack about the SMF modification installer.
Their regexp option is not working and a search & replace of multiple instances of the same search is not working properly either.
You will have to do your own edits.

Use an editor such as notepad++ (notepad plus plus ... not MS notepad)
located here: https://notepad-plus-plus.org/



Open ../Sources/Subs-Portal.php with notepad++
hit CTRL-F

find what:
Code: [Select]
function sp_loadCalendarData($type, $low_date, $high_date = false)

add BEFORE above code:
Code: [Select]
function sp_stripos_array($string, $array)
{
$array = !is_array($array) ? array($array) : $array;
foreach ($array as $find)
if (stripos($string, $find) !== false)
return true;

return false;
}

save changes and close file



Open ../Sources/PortalBlocks.php with notepad++
hit CTRL-F
Click on "replace"

find what:
Code: [Select]
stristr($row['avatar'], 'http://')

replace with:
Code: [Select]
sp_stripos_array($row['avatar'], array('http://', 'https://'))

Use "replace all"
save changes and close file



Open ../Sources/PortalArticles.php with notepad++
hit CTRL-F
Click on "replace"

find what:
Code: [Select]
stristr($row['avatar'], 'http://')

replace with:
Code: [Select]
sp_stripos_array($row['avatar'], array('http://', 'https://'))

Use "replace all"
save changes and close file



The first edit is not a replacement, just add above the code I said to search for.
Make sure to use "replace all" for the 2nd & third edits because there are multiple replacements for those.
Title: Re: blocks showing user avatars
Post by: hulapyk on November 15, 2018, 01:47:11 PM
Thanks a ton Chen Zhen :)
I'll give it a go later :)
SimplePortal 2.3.8 © 2008-2024, SimplePortal