1

(110 replies, posted in Supported extensions)

Question regarding csrf token (this sounds related to Francisco FR's problem)

Right now, when you leave the shoutbox open long enough, it'll eventually "crash" and stop working, due to a CSRF token mismatch. The reason this is happening is because a static CSRF token is being compared to one that gets generated on each poll and each new message (so basically, every 1.6 seconds). In simpler terms, each time it checks for new shouts or adds a new one, it'll check these two tokens, and eventually the static one will lag behind, and mismatch.

The comparison's in data.php on line 26:

$_GET['csrf_token'] != generate_form_token('./extensions/shoutbox_pun/data.php')

I understand that the reason for this is to help prevent cross-site attacks, and in this specific case, prevent bad people from posting shouts to your shoutbox without your permission. Does anyone have any idea on how to get around this? It looks like one solution is to regenerate the static token before it expires, but the token is generated via php code, and only gets called on page refresh. The alternative is to remove the check.

This problem also occurs with base PunBB functions, like modifying settings in the admin panel. The site gets around it by prompting you to confirm your action. I haven't looked at the code, but I imagine during this time, they regenerate the token, and then the action passes the check and goes through. But we can't do that with shouts, unless we force a page refresh every ~30 minutes.

Would be totally grateful for any help on this. Thanks!

2

(110 replies, posted in Supported extensions)

ams wrote:
helliax wrote:

I've managed to implement username links, but I'm trying to figure out the best way to go about tying it to an option, so it can be turned on and off through the forum settings.

Right now, the link is generated in the javascript. Specifically, the getHTMLFromMessage() function in shoutbox-pun.js. So in other words, I can't access the PHP config values directly. One way I figure I can do it, is to create a hidden <input /> that has the value, and grab that value from javascript. But that seems really hackish. Does anyone have any suggestions, or just other mods to check out, to see how they did it?

I forked andrew's project so I can work on it without messing up his project, so you can look at the code I have now: https://github.com/helliax/shoutbox_pun. Preferably, all my major changes will get turned into options, so we end up with one mod instead of two with just minor differences.

Why not add the option in the XML output in data.php? getShouts could have an additional <options> bit.

Please feel free to submit a pull request once the changes are done

This is sort of so obvious now I don't know why I didn't think of it immediately at the time. Thanks!

3

(110 replies, posted in Supported extensions)

I've managed to implement username links, but I'm trying to figure out the best way to go about tying it to an option, so it can be turned on and off through the forum settings.

Right now, the link is generated in the javascript. Specifically, the getHTMLFromMessage() function in shoutbox-pun.js. So in other words, I can't access the PHP config values directly. One way I figure I can do it, is to create a hidden <input /> that has the value, and grab that value from javascript. But that seems really hackish. Does anyone have any suggestions, or just other mods to check out, to see how they did it?

I forked andrew's project so I can work on it without messing up his project, so you can look at the code I have now: https://github.com/helliax/shoutbox_pun. Preferably, all my major changes will get turned into options, so we end up with one mod instead of two with just minor differences.

Quick note/warning about this extension: the chat box makes http requests every 10s to keep the chat updated, which may alarm your hosting service. A number of users were recently IP banned by our hosting service because they thought the chat box's requests were security threats.