Remove Links from Activity Field
My forum has got lot of spammers who keep on posting drugs related link on activity page of other users.
What should I do so that any thing that ends with .com doenst get converted to links.
Shouldnt activity field be only text based?
There was an error rendering this rich post.
Best Answers
-
peregrine MVP
I don't have your version of vanilla, but in 2.0.18.4
/applications/dashboard/views/activity/helper_functions.
search for this line <div class="Excerpt"><?php echo $Excerpt; ?></div> and place this above it if (!preg_match("/\.com/", $Excerpt)) { $Excerpt = ""; }
heres a little test program
<?php $Excerpt = "joe.com"; if (!preg_match("/\.com/", $Excerpt)) { $Excerpt = ""; } ?> <div class="Excerpt"><?php echo $Excerpt; ?></div> <?php $Excerpt = "just text"; if (!preg_match("/com/", $Excerpt)) { $Excerpt = ""; } ?> <div class="Excerpt"><?php echo $Excerpt; ?></div>
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
2 -
peregrine MVP
if ((preg_match("http", $Excerpt)) || (preg_match("www", $Excerpt))) {
to remove the automatic formatting you would have to do a preg_replace
without testing something like this
(preg_replace("/\<a|a\>/","". $Excerpt))
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
1
Answers
I don't have your version of vanilla, but in 2.0.18.4
/applications/dashboard/views/activity/helper_functions.
heres a little test program
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
or you just could remove the ability to post on the wall completely.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
Excellent @peregrine. You are my Saviour.
But I think, you have to remove that not in preg_match.
And peregrine, dot coms, still show up in status. Any way to remove it.
I have implemented your first idea but I am interested in knowing how to remove ability to post on walls?
There was an error rendering this rich post.
I did the exact opposite that of what you wanted. Yes remove the not.
You could remove view activity for members in the dashboard
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
@peregrine this method proves ineffective for links not ending with dot com. example - http://www.google.co.in/
is there any way to remove automatic formatting of links?
There was an error rendering this rich post.
if ((preg_match("http", $Excerpt)) || (preg_match("www", $Excerpt))) {
to remove the automatic formatting you would have to do a preg_replace
without testing something like this
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
Genius
There was an error rendering this rich post.
sub-mensa
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
BTW for other users, the correct one is
if ((preg_match("/http/", $Excerpt)) || (preg_match("/www/", $Excerpt)))
There was an error rendering this rich post.
glad you "liked" it
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
@peregrine
here is another problem i stumbled into. While going through self profile > activity I cannot see the links for which I have started because we have changed them by blanking $Excerpt.
Now, i have weired "You commented on a discussion.
Sorry, you cannot post links here."
Currently I have in activity helper function -
<div class="Excerpt">
<?php if ((preg_match("/http/", $Excerpt)) || (preg_match("/www/", $Excerpt)))
{$Excerpt = "<span style=\"color:red;\">Sorry, you cannot post links here.</span>"; echo ``$Excerpt;}
else echo $Excerpt; ?>
</div>
I have even tried by adding another if statement that matches if the link is from forum itselft but now the problem is the links are relative and does not contain forum url.
There was an error rendering this rich post.
so it won't ork with that....
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
As said, since the link is relative starting from / therefore yoursite.com doesnt work
There was an error rendering this rich post.
give me an example of one that won't match
if it is starting from / why does it have an http in it?
(what is in the excerpt variable).
I've got 5 minutes and then if I don't hear from you, I'll check back later
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
Where it didnt work -
http://forum.gtricks.com/profile/activity
What it shows -
You commented on a discussion.
Sorry, no links for you
and
You started a discussion.
Sorry, no links for you.
Where "Sorry, no links for you" is my custom excerpt whenever preg_match finds "http"
It works in some places where the link is "/discussion/634/make-your-own-hitler-reacts-video"
but does not in places where the link is http://forum.gtricks.com/discussion/628/google-kills-igoogle-google-video-and-many-other
There was an error rendering this rich post.
what you need to do is
var_dump($Excerpt);
before and after the preg_replaces so I can see what the string does, so I can help you.
note the difference where it "works" and where it doesn't" post examples of the before and after var_dumps of $Excerpt (using the C code format button when you post your results).
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.