Help with protection

Asked

Viewed 47 times

0

Hello I am developing a simple thing comment system, I am using php with ajax, and storing in a Mysql database, my question is the following,

entree

$MENSAGEM = filter_var($text, FILTER_SANITIZE_STRING, FILTER_FLAG_ENCODE_AMP);

how can I avoid from the comments of this type.

pppppp........ ou udaisoduasiudaosidua....   repetindo...

that ends up breaking the whole site?

I know you can do this by adjusting with css, but I wanted to bar this post using php.

my system already counts with login, only those who can post are users!

  • could you post your code and give more details of your question? The idea would be to create a "black list" of comments? Could explain better the "breaking the whole site"?

  • simple thing, I’m using php with ajax, and storing in a Mysql database.

  • Yes, I understood that. But if the field is opened, there is no way to predict what the user will type. A letter different from your rule, will stick. What you can do is send this comment to a moderator for approval before publication. Or also create a "Blacklist" containing the most commonly used words of "spam" and do a treatment before posting, but even so the chance to pass is great.

  • 1

    Problem solved using CSS and Character Limiting and Moderation!

  • I’ll do it, thank you all!!

1 answer

1

<?php

$str = "sssrrrry";

$v = array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "y", "z");


for($i = 0; $i < 25; $i++){

$quant = substr_count($str, $v[$i]);

$cont[] = $quant;

}

rsort($cont);

if($cont[0] > 1){

echo "Houve ". $cont[0] ." duplicações de somente 1 caractere na string";

}



?>

reference: https://forum.imasters.com.br/topic/473081-remover-caracteres-repetidos/ by : Daniel_moraes

  • And still you can put a str_replace() to correct the error, avoiding the user to look for where you missed

  • the problem is that if the user posts random letters pass this there, and the result is the same. ex: udaisoduasiudaosiduaiosa .....

  • @Camilaf girl, what kind of comment you can not put a haushudahushduahsud KKKKKKK, I think better improve your structure on your site kkk

  • then make sentence restrictions, big words etc... and as is common the use of "kkkk" or laughter that involves "h" just make the release of these two letters for big words, it is up to you as programmer the restrictions of your system.

  • All right! Thank you.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.