TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
Stats
  • Total Posts: 195,828
  • Total Topics: 21,286
  • Online today: 59
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 61
  • Total: 61

Not allowing guests to post links in ShoutBox

Started by GTS, April 10, 2006, 09:45:21 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

GTS

I made a little modification to my TPModules.php, that does not allow guests to post url's in the Shoutbox.
Using this little mod got rid of these spam bots, since they always post some url's.

I thought this might be usefull, since i didn't want to completely turn off Guest Shouts.

I'm using TP 0.86 (updated) with SMF 1.0.7
You can see the script in action on my page.

Here's what i did, find the following code (should be near the end of the file):

               if($context['user']['is_logged'])
                   $shout_name='<a href="'.$scripturl.'?action=profile;u='.$context['user']['id'].'">'.$_POST['tp-shout-name'].'</a>';


and replace it with:
               if($context['user']['is_logged']) {
                   $shout_name='<a href="'.$scripturl.'?action=profile;u='.$context['user']['id'].'">'.$_POST['tp-shout-name'].'</a>';
               }
               else { // if not logged in // if user is a guest
                  $pos = strpos ($shout, "://"); // look for ://
                  if ($pos !== false) {  // if it finds it in message, die with a little message
                     die('Sorry, guests are not allowed not use links in ShoutBox.');
                  }               
                  $pos = strpos ($shout, "www.");
                  if ($pos !== false) { 
                     die('Sorry, guests are not allowed not post links.');
                  } 
               }


I thought someone would like it.
I personally would like it, if this was added permanently, with a turn on/off switch :)

Edit: Oops, pasted a line too much ;)
Edit2: Changed "if ($pos > 0)" to "if ($pos !== false)"
Edit3: Added www. ...

Regards,
GTS

Polymath

I just posted as a guest at GTSdll.  I posted //

wasn't it supposed to say 'Sorry, guests are not allowed not use links in ShoutBox.'

if it finds it in a message. just wondering cos I added the changes to mine.

GTS

Well // isnt a link.
For example: http//gts-stuff.com is not a valid url ^^

IchBin

Quote from: Polymath on July 04, 2006, 03:14:32 AM
I just posted as a guest at GTSdll.  I posted //

wasn't it supposed to say 'Sorry, guests are not allowed not use links in ShoutBox.'

if it finds it in a message. just wondering cos I added the changes to mine.
Technically it doesn't "restrict" you from posting links, it just makes it so that HTML/PHP code does not get parsed.

GTS

Mh, that reply is confusing me.

I don't see where my modification prevents HTML/PHP execution.
* GTS scratches head

alan s

i just posted a link there www.theteenzone.net in your shoutbox , its active and it works etc.........

GTS

#6
Looks like i forgot the www. parsing.

I never had any bot that posted a link without http:// but well, i changed it ;)

IchBin

Links get parsed as BBC code automatically. YOu try and put something like this in the shoutbox and it won't work.
<div align="right">Test Text here</div>

GTS

#8
Well i know pretty much that html parsing is disabled in the shoutbox. My mod doesnt change this behaviour at all.
I still don't get your point about your earlier post.

As for the bbcode: i'd rather modify the behaviour of the shoutbox than the bbcode behaviour on links since bbcode is used forum-wide ;)

IchBin

Im just pointing out that HTML is not longer available in the shoutbox.

This website is proudly hosted on Crocweb Cloud Website Hosting.