Block means of contact with PHP

0

I'm developing a system where I need to not allow forms of contact like email, skype, facebook and phone. I wanted to use str_replace() only I would have to make a giant list with a few words that contain those items and replace with '' . Would there be a plugin or an open-source that already does this service? Or even a base code?

    
asked by anonymous 06.10.2014 / 20:45

1 answer

2

Users will find a way to pass on personal information.

If you can not email: [email protected] , someone will change until your rule fails: papa arroba charlie ponto com, papa(a)charlie dot com ... infinite possibilities.

I recommend an algorithm that looks for certain words, but does not prevent the registration, just create an alert that there is a possible contact information for you to do analysis.

  • An ER can find email or phone numbers, Skype or FB profile, Twitter, or any other social networking site.

  • You can create an array of (0, 1, 2, ... 9) and an array of (zero, um, dois, ... nove) and scroll through the text to find possible combinations between numbers and text.

    I made a simple example, you can see in the ideone .

    function validate( $string )
    {
        // caracteres que serão encontrados em sequencia
        $block[]   = array(1,2,3,4,5,6,7,8,9,0);
        $block[]   = array('um','dois','tres','quatro','cinco','seis','sete','oito','nove','zero');
        $block     = array_merge( $block[0] , $block[1] );
    
        // agrupa a sequencia encontrada
        $sequencia = array();
        $string    = explode( ' ' , $string );
    
        // procura a sequencia de 3 caracteres quee stiverem no 'array block'
        // palavra anterior + palavra atual + palavra seguinte formando uma sequencia de 3 caracteres
        foreach( $string as $i => $palavra )
        {
            $match = array();
    
            if( isset( $string[$i-1] ) )
            $match[] = $string[$i-1];
    
            $match[] = $string[$i];
    
            if( isset( $string[$i+1] ) )
            $match[] = $string[$i+1];
    
    
            $possivel = array_intersect( $match , $block );
            if( count( $possivel ) === 3 )
            $sequencia[] = $possivel;
        }
    
        return $sequencia;
    }
    

    In this example below the output will be a multidimensional array with array('1' , 'dois' , '3' ) and array('quatro' , 'cinco' , 'zero' )

    $sequencia = validate( "meu 1 dois 3 telefone ligue quatro cinco zero" );
    
    if( count( $sequencia ) > 0 )
    {
        echo printr( 'possível sequência: ' );
        echo printr( $sequencia );
    }
    else
    {
        echo printr( 'parece ok.' );
    }
    

    Note that the sequence will take the spelling into account. You can increment an ER together so spelling is not an impediment. It's simple and server-based.

        
  • 07.10.2014 / 02:36