SimplePortal
Development => Bugs => Topic started 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:
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)
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:
sp_stripos_array($row['avatar'], array('http://', 'https://')) ? ...
-
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.
-
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.
-
You planning on doing that then? Then I'd rather wait :P
-
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:
function sp_loadCalendarData($type, $low_date, $high_date = false)
add BEFORE above code:
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:
stristr($row['avatar'], 'http://')
replace with:
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:
stristr($row['avatar'], 'http://')
replace with:
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.
-
Thanks a ton Chen Zhen :)
I'll give it a go later :)