Disallow posting of URLs or BB code by member group.

Started by destalk, March 19, 2005, 02:48:50 AM

Previous topic - Next topic

destalk

RE: Disallow posting of URLs or BB code by member group.

i haven't found a way to apply this in the normal way (and I haven't the PHP skills to produce a mod), so I'm making it a feature request.

As an anti-spam measure, it would be nice to be able to limit these functions by member group. For example, a new member would be required to have posted a certain amount of messages, before their URLs became links (or perhaps disallowing BB code in general would be easier to implement). A similar feature could be applied so that new members would not be allowed to have URLs or BB code in their signatures, to stop people simply signing up and posting junk to get their links shown.

OK. It's not foolproof, but at least it might make it more bother than it's worth for the casual spammer to post 10-25 quality 'on-topic' messages, before being allowed to post a link to their spam site.  Ideally, it would then allow the mods to spot them before they get to this stage.

Any thoughts?

[Unknown]

#1
Making it retroactive would be a pain.  Making it so that any URLs they posted before they had x posts simply didn't become links would be easy, but not as nice.  I wonder what compromise would work between those two... if any.

This really isn't complicated, though.  Of that tutorial I gave you a link to, how much did you understand?  I know you didn't know how to link it to parsing, but if you want to add the permission...

Find, Sources/Subs-Post.php:

// Only mess with stuff outside [html][[/html]/code] tags.
for ($i = 0, $n = count($parts); $i < $n; $i++)
{
// 1 (odd) means a code section, not post text.
if ($i % 2 == 1)
$parts[$i] = '[html][[/html]code]' . $parts[$i] . '[html][[/html]/code]';
// Mess with the tags outside [html][[/html]code].
else
fixTags($parts[$i]);
}


Replace:

// Only mess with stuff outside [html][[/html]/code] tags.
for ($i = 0, $n = count($parts); $i < $n; $i++)
{
// 1 (odd) means a code section, not post text.
if ($i % 2 == 1)
$parts[$i] = '[html][[/html]code]' . $parts[$i] . '[html][[/html]/code]';
// Mess with the tags outside [html][[/html]code].
else
{
fixTags($parts[$i]);

if (!allowedTo('post_urls'))
$message = preg_replace(array('~\[i?url\]~i', '~\[/i?url\]~i', '~\[i?url=.+?\]~i'), '', $message);
}
}


This won't stop autolinking, but it's a start.  If you can get this far, I can show you how to do autolinking too (although it'd be a billion times easier in 1.1.)

-[Unknown]

destalk

#2
Thanks very much for all of this.

Quote from: [Unknown] on March 23, 2005, 11:18:55 PM
  Of that tutorial I gave you a link to, how much did you understand? 
-[Unknown]

:-X Next to nothing, I'm afraid.

I really understand zero about PHP.(I don't even code HTML - I use Dreamweaver and then clean it up a bit by hand), copy and pasting is as far as it goes. I'm looking at your last post and I think that you are saying that I need to replace the first lot of code with the second lot of code? I think I might just be able to do that :-\

QuoteMaking it so that any URLs they posted before they had x posts simply didn't become links would be easy...

That's pretty much all I would be after. I'm not really clear what you mean by 'making it retroactive'. When you say 'autolinking'. Do you mean that - with the above method - if they just post http://www.spammersdomain.com it will still come out as a url? I.E. The method you describe above will only affect posters who use [url=http://www............ etc? 


Also, what is the result of doing all that copy and pasting. You say it will 'add the permission'. Do you mean it will add a checkbox in the preferences?

Sorry for being so dense.

bjp

[Unknown]
What you propose is intéresting, but not very clear for a beginner. Car you explain what we have to find and change exactly.
Thank you.

[Unknown]

How about this, then:

Find, Sources/Subs-Post.php:

// Only mess with stuff outside [html][[/html]/code] tags.
for ($i = 0, $n = count($parts); $i < $n; $i++)
{
// 1 (odd) means a code section, not post text.
if ($i % 2 == 1)
$parts[$i] = '[html][[/html]code]' . $parts[$i] . '[html][[/html]/code]';
// Mess with the tags outside [html][[/html]code].
else
fixTags($parts[$i]);
}


Replace:

// Only mess with stuff outside [html][[/html]/code] tags.
for ($i = 0, $n = count($parts); $i < $n; $i++)
{
// 1 (odd) means a code section, not post text.
if ($i % 2 == 1)
$parts[$i] = '[html][[/html]code]' . $parts[$i] . '[html][[/html]/code]';
// Mess with the tags outside [html][[/html]code].
else
{
fixTags($parts[$i]);

if ($GLOBALS['user_info']['posts'] < 10)
{
$message = preg_replace(array('~\[i?url\]~i', '~\[/i?url\]~i', '~\[i?url=.+?\]~i'), '', $message);
$message = strtr($message, array('.' => '&#46;', ':' => '&#58;', '@' => '&#64;'));
}
}
}


How does that work?

-[Unknown]

destalk

Quote from: [Unknown] on March 27, 2005, 03:01:35 AM
How about this, then:

How does that work?

-[Unknown]


Hmmmm. Seems to do nothing. I set it up on a fresh board and registered as a new user. I was able to post urls without a problem.

[Unknown]

#6
Gah!  I made a horrible typo.

Find, Sources/Subs-Post.php:
	// Only mess with stuff outside [html][[/html]/code] tags.
for ($i = 0, $n = count($parts); $i < $n; $i++)
{
// 1 (odd) means a code section, not post text.
if ($i % 2 == 1)
$parts[$i] = '[html][[/html]code]' . $parts[$i] . '[html][[/html]/code]';
// Mess with the tags outside [html][[/html]code].
else
fixTags($parts[$i]);
}

Replace:
	// Only mess with stuff outside [html][[/html]/code] tags.
for ($i = 0, $n = count($parts); $i < $n; $i++)
{
// 1 (odd) means a code section, not post text.
if ($i % 2 == 1)
$parts[$i] = '[html][[/html]code]' . $parts[$i] . '[html][[/html]/code]';
// Mess with the tags outside [html][[/html]code].
else
{
fixTags($parts[$i]);

if ($GLOBALS['user_info']['posts'] < 10)
{
$parts[$i] = preg_replace(array('~\[i?url\]~i', '~\[/i?url\]~i', '~\[i?url=.+?\]~i'), '', $parts[$i]);
$parts[$i] = strtr($parts[$i], array('.' => '&#46;', ':' => '&#58;', '@' => '&#64;'));
}
}
}

This one?

-[Unknown]

destalk

Waheeeeyyy! Thanks [Unknown], that works like a dream.  :D

And I assume that all I need to do is change this; if ($GLOBALS['user_info']['posts'] < 10)

to this: if ($GLOBALS['user_info']['posts'] < 5) to make it 5 posts, (or whatever)?

Many many thanks.

[Unknown]


destalk

The only thing I'm not sure about is whether this works for signatures. I'll test that later.

Another way of dealing with spam in signatures is the way that Invision Board does. Whereby signatures can be hidden from guests. This prevents people signing up simply to get their homepage crawled by search engines. Perhaps that's a bit harsh though. If someone contributes to a talk forum, I have no objection to them putting their url in their signature. But, again, a posting limit would be one way of controlling that the url in the signature is a relevant one.

Just some thoughts...

I'm looking forward to SMF 1.1 ;)

destalk

Quick question.

For updating to 1.0.3, will this altered file cause problems? Thanks.

[Unknown]


destalk

BTW. Is there any - easy - way to get this to just disable urls and not all UBB code?

destalk

Quote from: [Unknown] on March 28, 2005, 05:19:47 PM
Gah!  I made a horrible typo.

Find, Sources/Subs-Post.php:

// Only mess with stuff outside [/code] tags.
for ($i = 0, $n = count($parts); $i < $n; $i++)
{
// 1 (odd) means a code section, not post text.
if ($i % 2 == 1)
$parts[$i] = '[code]' . $parts[$i] . '[/code]';
// Mess with the tags outside [code].
else
fixTags($parts[$i]);
}


Replace:

// Only mess with stuff outside [/code] tags.
for ($i = 0, $n = count($parts); $i < $n; $i++)
{
// 1 (odd) means a code section, not post text.
if ($i % 2 == 1)
$parts[$i] = '[code]' . $parts[$i] . '[/code]';
// Mess with the tags outside [code].
else
{
fixTags($parts[$i]);

if ($GLOBALS['user_info']['posts'] < 10)
{
$parts[$i] = preg_replace(array('~\[i?url\]~i', '~\[/i?url\]~i', '~\[i?url=.+?\]~i'), '', $parts[$i]);
$parts[$i] = strtr($parts[$i], array('.' => '&#46;', ':' => '&#58;', '@' => '&#64;'));
}
}
}


This one?

-[Unknown]

This looks a bit different under 1.1 beta 3. Is there any update to that code?

Thanks

[Unknown]

Just add the same thing after:

fixTags($parts[$i]);

-[Unknown]

destalk

#15
Hmmm. I get this error when I start a new topic.

Parse error: parse error, unexpected '}' in /home/user/public_html/Sources/Subs-Post.php on line 255

This is what I did with the  code, where did I go wrong? >:(

<?php

// Only mess with stuff outside [code] tags.
for ($i 0$n count($parts); $i $n$i++)
{
// It goes 0 = outside, 1 = begin tag, 2 = inside, 3 = close tag, repeat.
if ($i == 0)
{
fixTags($parts[$i]);


if ($GLOBALS['user_info']['posts'] < 4)
{
$parts[$i] = preg_replace(array('~\[i?url\]~i''~\[/i?url\]~i''~\[i?url=.+?\]~i'), ''$parts[$i]);
$parts[$i] = strtr($parts[$i], array('.' => '&#46;'':' => '&#58;''@' => '&#64;'));
}
}
}

// Replace /me.+?\n with [me=name]dsf[/me]\n.
if (strpos($user_info['name'], '[') !== false || strpos($user_info['name'], ']') !== false || strpos($user_info['name'], '\'') !== false || strpos($user_info['name'], '"') !== false)
$parts[$i] = preg_replace('~(\A|\n)/me(?: |&nbsp;)(.*?)(\n|\z)~i''$1[me=&quot;' $user_info['name'] . '&quot;]$2[/me]$3'$parts[$i]);
else
$parts[$i] = preg_replace('~(\A|\n)/me(?: |&nbsp;)(.*?)(\n|\z)~i''$1[me=' $user_info['name'] . ']$2[/me]$3'$parts[$i]);

if (!$previewing)

?>


Thanks[/code]

[Unknown]

Just find:

fixTags($parts[$i]);

And add after it:

if ($GLOBALS['user_info']['posts'] < 4)
{
$parts[$i] = preg_replace(array('~\&#91;i?url\]~i', '~\&#91;/i?url\]~i', '~\&#91;i?url=.+?\]~i'), '', $parts[$i]);
$parts[$i] = strtr($parts[$i], array('.' => '&#46;', ':' => '&#58;', '@' => '&#64;'));
}


-[Unknown]

destalk

Thanks [Unknown]

It seems to work with http://www.domain.com but not with [url=http://www.domain.com]links[/url] which still appears as a link.

[Unknown]

Hmm... strange.  Try:

if ($GLOBALS['user_info']['posts'] < 4)
{
$parts[$i] = preg_replace(array('~\[i?url\]~i', '~\[/i?url\]~i', '~\[i?url=.+?\]~i'), '', $parts[$i]);
$parts[$i] = strtr($parts[$i], array('.' => '&#46;', ':' => '&#58;', '@' => '&#64;'));
}


-[Unknown]

destalk


Advertisement: