Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

Remove Links from Activity Field

aeryaery Gtricks Forum in 2.2 :) ✭✭✭
edited May 2012 in Vanilla 2.0 - 2.8

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

  • Options
    peregrineperegrine MVP
    edited May 2012 Answer ✓

    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.

  • Options
    peregrineperegrine MVP
    edited May 2012 Answer ✓

    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.

Answers

  • Options
    peregrineperegrine MVP
    edited May 2012 Answer ✓

    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.

  • Options

    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.

  • Options
    aeryaery Gtricks Forum in 2.2 :) ✭✭✭
    edited May 2012

    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.

  • Options
    peregrineperegrine MVP
    edited May 2012

    I did the exact opposite that of what you wanted. Yes remove the not.

    $Excerpt = "";
    <div class="Excerpt"><?php echo $Excerpt; ?></div>  
    

    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.

  • Options
    aeryaery Gtricks Forum in 2.2 :) ✭✭✭

    @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.

  • Options
    peregrineperegrine MVP
    edited May 2012 Answer ✓

    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.

  • Options
    aeryaery Gtricks Forum in 2.2 :) ✭✭✭

    Genius :)

    There was an error rendering this rich post.

  • Options

    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.

  • Options
    aeryaery Gtricks Forum in 2.2 :) ✭✭✭
    edited May 2012

    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.

  • Options

    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.

  • Options
    aeryaery Gtricks Forum in 2.2 :) ✭✭✭

    @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.

  • Options
    peregrineperegrine MVP
    edited July 2012

    so it won't ork with that....

    if  (   ((preg_match("/http/", $Excerpt)) || (preg_match("/www/", $Excerpt)))  &&
    (!preg_match("/http/yoursite.com", $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.

  • Options
    aeryaery Gtricks Forum in 2.2 :) ✭✭✭
    edited July 2012

    I have even tried by adding another if statement that matches if the link is from forum itself but now the problem is the links are relative and does not contain forum url.

    As said, since the link is relative starting from / therefore yoursite.com doesnt work :(

    There was an error rendering this rich post.

  • Options
    peregrineperegrine MVP
    edited July 2012

    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.

  • Options
    aeryaery Gtricks Forum in 2.2 :) ✭✭✭
    edited July 2012

    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.

  • Options

    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.

Sign In or Register to comment.