SimplePortal

Support => English Support => Topic started by: ataru on January 26, 2015, 03:51:47 AM

Title: Shoutbox can't refresh
Post by: ataru on January 26, 2015, 03:51:47 AM
I own a forum, http://www.biancocelesti.org, just upgraded from 2.0RC3 to 2.0.9.

I also upgraded SP from 2.3.2 to 2.3.6.

now my shoutboxes can't refresh. shouts are stored in db, can be seen refreshing the whole page (F5), but can't refresh only shoutbox.

Trying to debug js code, i encounter an error:
Code: [Select]
Uncaught TypeError: Cannot read property 'nodeValue' of undefined - portal.js?236:127
onShoutReceived - portal.js?236:127
oMyDoc.onreadystatechange - script.js?rc3:88


this is the portal.js part of the error:
Code: [Select]
for (var i = 0; i < shouts.length; i++)
{
shout = XMLDoc.getElementsByTagName("smf")[0].getElementsByTagName("shout")[i];
id = shout.getElementsByTagName("id")[0].childNodes[0].nodeValue;
---> author = shout.getElementsByTagName("author")[0].childNodes[0].nodeValue;<---
time = shout.getElementsByTagName("time")[0].childNodes[0].nodeValue;
timeclean = shout.getElementsByTagName("timeclean")[0].childNodes[0].nodeValue;
delete_link = shout.getElementsByTagName("delete")[0].childNodes[0].nodeValue;
content = shout.getElementsByTagName("content")[0].childNodes[0].nodeValue;
is_me = shout.getElementsByTagName("is_me")[0].childNodes[0].nodeValue;

new_body += '<li class="smalltext">' + (is_me == 0 ? '<strong>' + author + ':</strong> ' : '') + content + '<br />' + (delete_link != 0 ? ('<span class="shoutbox_delete">' + delete_link + '</span>') : '') + '<span class="smalltext shoutbox_time">' + time + '</span></li>';
}

and this is the script.js part:
Code: [Select]
if (bAsync)
{
oMyDoc.onreadystatechange = function () {
if (oMyDoc.readyState != 4)
return;

if (oMyDoc.responseXML != null && oMyDoc.status == 200)
{
if (funcCallback.call)
{
---> funcCallback.call(oCaller, oMyDoc.responseXML);<---
}
// A primitive substitute for the call method to support IE 5.0.
else
{
oCaller.tmpMethod = funcCallback;
oCaller.tmpMethod(oMyDoc.responseXML);
delete oCaller.tmpMethod;
}
}
};
}
oMyDoc.open('GET', sUrl, bAsync);
oMyDoc.send(null);


no errors in error.log, only client side.
can anyone help me?
Title: Re: Shoutbox can't refresh
Post by: ataru on January 26, 2015, 09:11:53 AM
i tried to see the xml generated by myurl/index.php?action=portal;sa=shoutbox;shoutbox_id=1;xml and i see:
Code: [Select]
<smf>
<shoutbox>1</shoutbox>
<updated>1</updated>
<error>0</error>
<warning>0</warning>
<reverse>0</reverse>
<shout>
<id>167015</id>
<author/>
<time/>
<timeclean/>
<delete>
<a href="myurl/index.php?action=portal;sa=shoutbox;shoutbox_id=1;delete=167015;ed3d3dff0=b6e1b2b659ad6f39f96b2b0c33928ef4" onclick="sp_delete_shout(1, 167015, 'ed3d3dff0', 'b6e1b2b659ad6f39f96b2b0c33928ef4'); return false;"><img src="myurl/Themes/mytheme/images/sp/delete_small.png" alt="Elimina" title="Elimina" /></a>
</delete>
<content/>
<is_me>0</is_me>
</shout>
<shout>
<id>166299</id>
<author/>
<time/>
<timeclean/>
<delete>
<a href="myurl/index.php?action=portal;sa=shoutbox;shoutbox_id=1;delete=166299;ed3d3dff0=b6e1b2b659ad6f39f96b2b0c33928ef4" onclick="sp_delete_shout(1, 166299, 'ed3d3dff0', 'b6e1b2b659ad6f39f96b2b0c33928ef4'); return false;"><img src="myurl/Themes/mytheme/images/sp/delete_small.png" alt="Elimina" title="Elimina" /></a>
</delete>
<content/>
<is_me>0</is_me>
</shout>

it seems like it couldn't get nothing but id from xml
Title: Re: Shoutbox can't refresh
Post by: ataru on February 02, 2015, 10:09:32 AM
nobody can help me? where can i finf xml parsing function for shoutbox?
Title: Re: Shoutbox can't refresh
Post by: ataru on February 02, 2015, 10:36:43 AM
ok another step forward:

in Portalshoutbox.template.php i found xml generator:

Code: [Select]
function template_shoutbox_xml()
Code: [Select]
<shout>
<id>', $shout['id'], '</id>
<author>', htmlspecialchars($shout['author']['link']), '</author>
<time>', htmlspecialchars($shout['time']), '</time>
<timeclean>', htmlspecialchars(strip_tags($shout['time'])), '</timeclean>
<delete>', !empty($shout['delete_link_js']) ? htmlspecialchars($shout['delete_link_js']) : 0, '</delete>
<content>', htmlspecialchars($shout['text']), '</content>
<is_me>', $shout['is_me'] ? 1 : 0, '</is_me>
</shout>';

htmlspecialchars sometimes returns empty values, i think it's something related to utf stuff and php 5.4.

it seems that in php 5.4 htmlspecialchars uses utf-8 as default encoding

how can i workaround?
Title: Re: Shoutbox can't refresh
Post by: ataru on February 02, 2015, 11:08:12 AM
ok. solved adding $smcFunc and using $smcFunc['htmlspecialchars'] instead of php htmlspecialchars


Code: [Select]
function template_shoutbox_xml()
{
global $context, $txt, $smcFunc;

echo '<', '?xml version="1.0" encoding="', $context['character_set'], '"?', '>
<smf>
<shoutbox>', $context['SPortal']['shoutbox']['id'], '</shoutbox>';

if ($context['SPortal']['updated'])
{
echo '
<updated>1</updated>
<error>', empty($context['SPortal']['shouts']) ? $txt['sp_shoutbox_no_shout'] : 0, '</error>
<warning>', !empty($context['SPortal']['shoutbox']['warning']) ? $smcFunc['htmlspecialchars']($context['SPortal']['shoutbox']['warning']) : 0, '</warning>
<reverse>', !empty($context['SPortal']['shoutbox']['reverse']) ? 1 : 0, '</reverse>';

foreach ($context['SPortal']['shouts'] as $shout)
echo '
<shout>
<id>', $shout['id'], '</id>
<author>', $smcFunc['htmlspecialchars']($shout['author']['link']), '</author>
<time>', $smcFunc['htmlspecialchars']($shout['time']), '</time>
<timeclean>', $smcFunc['htmlspecialchars'](strip_tags($shout['time'])), '</timeclean>
<delete>', !empty($shout['delete_link_js']) ? $smcFunc['htmlspecialchars']($shout['delete_link_js']) : 0, '</delete>
<content>', $smcFunc['htmlspecialchars']($shout['text']), '</content>
<is_me>', $shout['is_me'] ? 1 : 0, '</is_me>
</shout>';


/* old code
<shout>
<id>', $shout['id'], '</id>
<author>', htmlspecialchars($shout['author']['link']), '</author>
<time>', htmlspecialchars($shout['time']), '</time>
<timeclean>', htmlspecialchars(strip_tags($shout['time'])), '</timeclean>
<delete>', !empty($shout['delete_link_js']) ? htmlspecialchars($shout['delete_link_js']) : 0, '</delete>
<content>', htmlspecialchars($shout['text']), '</content>
<is_me>', $shout['is_me'] ? 1 : 0, '</is_me>
</shout>';*/



}
else
echo '
<updated>0</updated>';

echo '
</smf>';

Title: Re: Shoutbox can't refresh
Post by: ccbtimewiz on February 04, 2015, 09:19:26 PM
Sorry for the somewhat late response.

Yes, the function passed through $smcFunc is a UTF8 safe version of htmlspecialchars(). This check should happen before the template though, so it's actually just a small oversight in SP right now.

Perhaps make a report in the bug report board and it'll be addressed.
Title: Re: Shoutbox can't refresh
Post by: [SiNaN] on August 01, 2015, 07:48:26 AM
I'm sorry that I couldn't respond to this earlier. Again, thank you for your report and suggested fix!
Title: Re: Shoutbox can't refresh
Post by: timp11 on November 28, 2015, 09:44:08 PM
Mine doesnt refresh.. and i have tried everything.
SimplePortal 2.3.8 © 2008-2024, SimplePortal