Help with protection

0
Hello, I'm developing a simple thing comments system, I'm using php with ajax, and storing in a MySQL database, my question is as follows,

input

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

How can I avoid comments of this type.

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

What breaks the whole site?

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

My system already has a login, only those who can post are users!

    
asked by anonymous 04.04.2018 / 04:33

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: link by: Daniel_Moraes

    
04.04.2018 / 04:39