<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
    <channel>
        <title>Anti-spam: Restrict new users from posting hyperlinks / images</title>
        <description> (Apologies if this has been requested before, I have been away from these forums for over a year)

Has anybody written a module to restrict new users from posting hyperlinks?
This would make the job of a spammer harder.

Ideally, the module would be configurable and flexible enough to support things like the following:
 Maximum number of hyperlinks per post for unregistered users  Maximum number of hyperlinks per post for registered users younger than x days  Maximum number of hyperlinks per post for registered users  Maximum number of images per post for unregistered users  Maximum number of images per post for registered users younger than x days  Maximum number of images per post for registered users  No restrictions for users older than y days 

I haven&amp;#039;t written a Phorum module for a few years, but would be willing to write this one if somebody gave me some pointers.

Thank you,

/\dam</description>
        <link>https://www.phorum.org/support/read.php?20,152210,152210#msg-152210</link>
        <lastBuildDate>Tue, 21 Jul 2026 02:19:22 -0500</lastBuildDate>
        <generator>Phorum 6.0.4</generator>
        <item>
            <guid>https://www.phorum.org/support/read.php?20,152210,154858#msg-154858</guid>
            <title>Re: Anti-spam: Restrict new users from posting hyperlinks / images</title>
            <link>https://www.phorum.org/support/read.php?20,152210,154858#msg-154858</link>
            <description><![CDATA[ Hello Sheik,<br />
<br />
I&#039;m actually looking for such a add-on to block those annoying Spammers.<br />
<br />
Will you&#039;re version works with Phorum version 5.1.16a ?<br />
<br />
It would interesting if you could have a feature to deactivate this function after a certain <i>x</i> of post. The reason for this is because some newly register user can take month before posting. I know spammers that register account months in advance before starting spamming. Probably to circumvent those add-on like yours.<br />
<br />
Thanks,<br />
<br />
Yves]]></description>
            <dc:creator>Yves Julien</dc:creator>
            <category>Phorum Hack/Mod Requests</category>
            <pubDate>Sun, 12 Jan 2014 14:11:14 -0600</pubDate>
        </item>
        <item>
            <guid>https://www.phorum.org/support/read.php?20,152210,152732#msg-152732</guid>
            <title>Re: Anti-spam: Restrict new users from posting hyperlinks / images</title>
            <link>https://www.phorum.org/support/read.php?20,152210,152732#msg-152732</link>
            <description><![CDATA[ Sorry, invalid thread]]></description>
            <dc:creator>tecmade</dc:creator>
            <category>Phorum Hack/Mod Requests</category>
            <pubDate>Sun, 09 Dec 2012 05:08:42 -0600</pubDate>
        </item>
        <item>
            <guid>https://www.phorum.org/support/read.php?20,152210,152290#msg-152290</guid>
            <title>Re: Anti-spam: Restrict new users from posting hyperlinks / images</title>
            <link>https://www.phorum.org/support/read.php?20,152210,152290#msg-152290</link>
            <description><![CDATA[ I have now added support for the Premium Subscribers Module, so you can disable restrictions for premium subscribers to your forum.<br />
<br />
The module seems to be working well on my forum, so is now available for public download at [<a href="http://www.phorum.org/phorum5/read.php?62,152289,152289#msg-152289" target="_blank" >www.phorum.org</a>]<br />
<br />
/\dam]]></description>
            <dc:creator>sheik</dc:creator>
            <category>Phorum Hack/Mod Requests</category>
            <pubDate>Wed, 17 Oct 2012 05:56:45 -0500</pubDate>
        </item>
        <item>
            <guid>https://www.phorum.org/support/read.php?20,152210,152254#msg-152254</guid>
            <title>Re: Anti-spam: Restrict new users from posting hyperlinks / images</title>
            <link>https://www.phorum.org/support/read.php?20,152210,152254#msg-152254</link>
            <description><![CDATA[ Initial admin screen, note I have added a &quot;maximum message length&quot; for different users. If this has already been implemented elsewhere I will remove it.<br />
<br />
<img src="http://www.celerity.co.uk/phorum_code/content_restrictions/admin_screen_beta1.png" class="bbcode" border="0" /><br />
<br />
I am going to run this in the wild for a few days and if there are no problems I will release it.<br />
<br />
/\dam]]></description>
            <dc:creator>sheik</dc:creator>
            <category>Phorum Hack/Mod Requests</category>
            <pubDate>Mon, 15 Oct 2012 11:28:32 -0500</pubDate>
        </item>
        <item>
            <guid>https://www.phorum.org/support/read.php?20,152210,152252#msg-152252</guid>
            <title>Re: Anti-spam: Restrict new users from posting hyperlinks / images</title>
            <link>https://www.phorum.org/support/read.php?20,152210,152252#msg-152252</link>
            <description><![CDATA[ The above algorithm in code:<br />
<pre class="bbcode">
// first count and remove all bbcode [ url ] tags and everything between them
$parsed_message = preg_replace(&#039;@[url(.*?)[/url\]@&#039;, &#039;&#039;, $message[&quot;body&quot;],-1,$num_bbcodelinks);
		
// now count and remove all remaining http*://*. strings to catch http and https links
$parsed_message = preg_replace(&#039;/http(.*?)\:\/\/(.*?)\./i&#039;, &#039;&#039;, $parsed_message, -1, $num_hyperlinks);
		
// now count and remove all remaining www.* strings
$parsed_message = preg_replace(&#039;/www(.*?)\./i&#039;, &#039;&#039;, $parsed_message, -1, $num_wwwlinks);
		
// count all mailto.* strings
preg_match_all(&#039;@[email(.*?)[/email\]@&#039;, $parsed_message, $matches);
$num_mailtolinks = count($matches[0]);
		
$total_num_links = $num_hyperlinks + $num_bbcodelinks + $num_wwwlinks + $num_mailtolinks;</pre>
<br />
Initial tests seem to work OK.<br />
<br />
/\dam]]></description>
            <dc:creator>sheik</dc:creator>
            <category>Phorum Hack/Mod Requests</category>
            <pubDate>Mon, 15 Oct 2012 09:15:17 -0500</pubDate>
        </item>
        <item>
            <guid>https://www.phorum.org/support/read.php?20,152210,152251#msg-152251</guid>
            <title>Re: Anti-spam: Restrict new users from posting hyperlinks / images</title>
            <link>https://www.phorum.org/support/read.php?20,152210,152251#msg-152251</link>
            <description><![CDATA[ OK, one possible algorithm would involve doing multiple calls to preg_replace.<br />
eg:<br />
- match all instances of pairs of bbcode url open and close tags. Delete all of these strings and make a note of how many matches there were.<br />
- use the output from the above bulk replace to search for strings that start with &quot;http ://&quot; - again count and delete them<br />
- use the output from the above bulk replace to search for strings that start with &quot;www.*.&quot; - count them<br />
- add up the three totals from the above, and it *should* give an accurate link count for my previous example.<br />
<br />
I think this would work but I&#039;d need to code and test it.<br />
It would use up slightly more memory and CPU than my previous (incorrect) algorithm as the message body would be copied in memory and more intensive regexes would be performed on it.<br />
<br />
Thoughts?<br />
<br />
/\dam]]></description>
            <dc:creator>sheik</dc:creator>
            <category>Phorum Hack/Mod Requests</category>
            <pubDate>Mon, 15 Oct 2012 06:01:49 -0500</pubDate>
        </item>
        <item>
            <guid>https://www.phorum.org/support/read.php?20,152210,152248#msg-152248</guid>
            <title>Re: Anti-spam: Restrict new users from posting hyperlinks / images</title>
            <link>https://www.phorum.org/support/read.php?20,152210,152248#msg-152248</link>
            <description><![CDATA[ Thanks Thomas, I have a proof-of-concept module working that restricts unregistered users only.<br />
<br />
I am detecting unregistered users by: <br />
<pre class="bbcode">$tsregistered = $PHORUM[&quot;user&quot;][&quot;date_added&quot;];
if (!$tsregistered){ // user is UNREGISTERED</pre>
Is there a better way?<br />
<br />
Additionally, I could use some advice on how to target hyperlinks.<br />
As far as I know, there are three ways to post web links in Phorum and spammers certainly use all of these on my forums:<br />
<br />
1: Enter a straightforward http:// address - Phorum auto-parses this to make it clickable<br />
2: Use the bbcode tag (note, you do not need to prefix with http:// for this to work, bbcode will make *anything* clickable and let the browser worry about what to do with it)<br />
3: Just type a www.foo.com address - it won&#039;t be made clickable but users will see it.<br />
<br />
I am counting instances of (1) using:<br />
<pre class="bbcode">preg_match_all(&#039;@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@&#039;, $message[&quot;body&quot;], $matches);</pre>
(I swiped this off the web, preliminary testing suggests it seems to work)<br />
<br />
instances of (2) using:<br />
<pre class="bbcode">preg_match_all(&#039;/\[url/&#039;, $message[&quot;body&quot;], $matches);</pre>
(I&#039;m just counting opening bbcode url tags, I don&#039;t care about closing ones)<br />
<br />
and instances of (3) using:<br />
<pre class="bbcode">preg_match_all(&#039;/\\www\.(.*?)\./i&#039;, $message[&quot;body&quot;], $matches);</pre>
(this should look for any consecutive string starting with &quot;www.&quot; (case-insensitive) and containing at least one other &quot;.&quot;)<br />
<br />
Now, the problem with the above is that my *total* count of links will often be higher than it should be.<br />
For example, <a href="http://www.this.test.link" target="_blank"  rel="nofollow">http://www.this.test.link</a> is technically only one link but my regexs above will count it as 2 http links, 1 bbcode link and 2 www links, giving a total of 5 hyperlinks instead of one.<br />
<br />
After this gets solved &quot;mailto&quot; links would need to be detected too.<br />
<br />
It is late here, so I&#039;m going to sleep on the problem - feedback would be appreciated.<br />
<br />
/\dam]]></description>
            <dc:creator>sheik</dc:creator>
            <category>Phorum Hack/Mod Requests</category>
            <pubDate>Sun, 14 Oct 2012 23:57:36 -0500</pubDate>
        </item>
        <item>
            <guid>https://www.phorum.org/support/read.php?20,152210,152230#msg-152230</guid>
            <title>Re: Anti-spam: Restrict new users from posting hyperlinks / images</title>
            <link>https://www.phorum.org/support/read.php?20,152210,152230#msg-152230</link>
            <description><![CDATA[ have a look at the posting hooks, for example the check_post hook [<a href="http://www.phorum.org/docs/html/developer/ch03s14s09.html" target="_blank" >www.phorum.org</a>] .<br />
But you will have to do your own parsing for links there.]]></description>
            <dc:creator>Thomas Seifert</dc:creator>
            <category>Phorum Hack/Mod Requests</category>
            <pubDate>Sun, 14 Oct 2012 04:07:25 -0500</pubDate>
        </item>
        <item>
            <guid>https://www.phorum.org/support/read.php?20,152210,152227#msg-152227</guid>
            <title>Re: Anti-spam: Restrict new users from posting hyperlinks / images</title>
            <link>https://www.phorum.org/support/read.php?20,152210,152227#msg-152227</link>
            <description><![CDATA[ Yes, but then you have to redo your changes if you want to benefit from updates to the original codebase.<br />
I agree your suggestion is quicker and easier - I just think it&#039;s cleaner to keep it as a separate mod.<br />
<br />
  /\dam]]></description>
            <dc:creator>sheik</dc:creator>
            <category>Phorum Hack/Mod Requests</category>
            <pubDate>Sat, 13 Oct 2012 18:36:42 -0500</pubDate>
        </item>
        <item>
            <guid>https://www.phorum.org/support/read.php?20,152210,152225#msg-152225</guid>
            <title>Re: Anti-spam: Restrict new users from posting hyperlinks / images</title>
            <link>https://www.phorum.org/support/read.php?20,152210,152225#msg-152225</link>
            <description><![CDATA[ Well, since BBCode is a module, you can create a new mod and activate that rather than the &quot;standard&quot; BBCode module.]]></description>
            <dc:creator>DavidVonB</dc:creator>
            <category>Phorum Hack/Mod Requests</category>
            <pubDate>Sat, 13 Oct 2012 18:11:05 -0500</pubDate>
        </item>
        <item>
            <guid>https://www.phorum.org/support/read.php?20,152210,152222#msg-152222</guid>
            <title>Re: Anti-spam: Restrict new users from posting hyperlinks / images</title>
            <link>https://www.phorum.org/support/read.php?20,152210,152222#msg-152222</link>
            <description><![CDATA[ I&#039;d rather keep it a clean module rather than hacking core routines.<br />
My inclination would be to use a hook before bbcode gets involved, to strip out anything starting with &quot;http ://&quot;, &quot;ftp ://&quot; etc based on the user&#039;s registration date and the module&#039;s own, internal logic.<br />
Ideally I&#039;d then use another hook to display a message to the user explaining what has happened to their post and why.<br />
<br />
This should actually be a fairly straightforward module to write. I&#039;d just appreciate some guidance on the hooks to use, and also how to pull back the current user&#039;s registration date.<br />
<br />
Some admins might also like to base the rules upon how many posts a user has made, so that would be good to know how to extract too.<br />
<br />
Cheers,<br />
<br />
  /\dam]]></description>
            <dc:creator>sheik</dc:creator>
            <category>Phorum Hack/Mod Requests</category>
            <pubDate>Sat, 13 Oct 2012 13:27:37 -0500</pubDate>
        </item>
        <item>
            <guid>https://www.phorum.org/support/read.php?20,152210,152218#msg-152218</guid>
            <title>Re: Anti-spam: Restrict new users from posting hyperlinks / images</title>
            <link>https://www.phorum.org/support/read.php?20,152210,152218#msg-152218</link>
            <description><![CDATA[ I did something like that a number of years ago (for the links). You need to modify the bbcode module<br />
function bbcode_url_handler($content, $args) (in the api.php program in the mod subdirectory)<br />
<br />
You just need to add some conditional code toward the end of the function and modify what gets returned.]]></description>
            <dc:creator>DavidVonB</dc:creator>
            <category>Phorum Hack/Mod Requests</category>
            <pubDate>Sat, 13 Oct 2012 04:58:55 -0500</pubDate>
        </item>
        <item>
            <guid>https://www.phorum.org/support/read.php?20,152210,152210#msg-152210</guid>
            <title>Anti-spam: Restrict new users from posting hyperlinks / images</title>
            <link>https://www.phorum.org/support/read.php?20,152210,152210#msg-152210</link>
            <description><![CDATA[ (Apologies if this has been requested before, I have been away from these forums for over a year)<br />
<br />
Has anybody written a module to restrict new users from posting hyperlinks?<br />
This would make the job of a spammer harder.<br />
<br />
Ideally, the module would be configurable and flexible enough to support things like the following:<br />
<ul><li> Maximum number of hyperlinks per post for unregistered users </li><li> Maximum number of hyperlinks per post for registered users younger than x days </li><li> Maximum number of hyperlinks per post for registered users </li><li> Maximum number of images per post for unregistered users </li><li> Maximum number of images per post for registered users younger than x days </li><li> Maximum number of images per post for registered users </li><li> No restrictions for users older than y days </li></ul>
<br />
I haven&#039;t written a Phorum module for a few years, but would be willing to write this one if somebody gave me some pointers.<br />
<br />
Thank you,<br />
<br />
/\dam]]></description>
            <dc:creator>sheik</dc:creator>
            <category>Phorum Hack/Mod Requests</category>
            <pubDate>Fri, 12 Oct 2012 09:28:47 -0500</pubDate>
        </item>
    </channel>
</rss>
