TinyPortal

Development => Feedback => Topic started by: GTS on April 10, 2006, 09:45:21 AM

Title: Not allowing guests to post links in ShoutBox
Post by: GTS on April 10, 2006, 09:45:21 AM
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 (http://www.adv-clan.com/gts-stuff/forum/).

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
Title: Re: Not allowing guests to post links in ShoutBox
Post by: 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.
Title: Re: Not allowing guests to post links in ShoutBox
Post by: GTS on July 13, 2006, 02:51:18 PM
Well // isnt a link.
For example: http//gts-stuff.com is not a valid url ^^
Title: Re: Not allowing guests to post links in ShoutBox
Post by: IchBin on July 13, 2006, 07:24:38 PM
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.
Title: Re: Not allowing guests to post links in ShoutBox
Post by: GTS on July 13, 2006, 07:59:12 PM
Mh, that reply is confusing me.

I don't see where my modification prevents HTML/PHP execution.
/me scratches head
Title: Re: Not allowing guests to post links in ShoutBox
Post by: alan s on July 13, 2006, 08:25:59 PM
i just posted a link there www.theteenzone.net in your shoutbox , its active and it works etc.........
Title: Re: Not allowing guests to post links in ShoutBox
Post by: GTS on July 13, 2006, 08:28:32 PM
Looks like i forgot the www. parsing.

I never had any bot that posted a link without http:// but well, i changed it ;)
Title: Re: Not allowing guests to post links in ShoutBox
Post by: IchBin on July 13, 2006, 11:29:06 PM
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>
Title: Re: Not allowing guests to post links in ShoutBox
Post by: GTS on July 14, 2006, 12:11:16 AM
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 ;)
Title: Re: Not allowing guests to post links in ShoutBox
Post by: IchBin on July 14, 2006, 03:41:21 AM
Im just pointing out that HTML is not longer available in the shoutbox.