J
J
Jasee Cambatch2017-11-27 00:12:07
Yii
Jasee Cambatch, 2017-11-27 00:12:07

How to install a mat-filter for a website in php?

Tell me how to install the replacement of obscene (and not only) words with **** or any word.
There are codes, but there are no instructions for installing them.
one of the codes
@setlocale(LC_ALL, array ('ru_RU.CP1251', 'rus_RUS.1251'));
$pattern = "/\w{0,5}[xx]([xx\s\[email protected]#\$%\^&*+-\|\/]{0,6})[yy]([yy \s\[email protected]#\$%\^&*+-\|\/]{0,6})[Єileeeuy¤]\w{0,7}|\w{0,6}[pr]([ pp\s\[email protected]#\$%\^&*+-\|\/]{0,6})[iе]([iе\s\[email protected]#\$%\^&*+-\| \/]{0,6})[3ss]([3ss\s\[email protected]#\$%\^&*+-\|\/]{0,6})[dd]\w{0,10 }|[ccs][yy]([yy\[email protected]#\$%\^&*+-\|\/]{0,6})[4chk]\w{1,3}|\w{0 ,4}[bb]([bb\s\[email protected]#\$%\^&*+-\|\/]{0,6})[ll]([ll\s\[email protected]#\$% \^&*+-\|\/]{0,6})[y¤]\w{0,10}|\w{0,8}[eЄ][bb][[email protected] ivl]\w{0,8}|\w{0,4}[ee]([ee\s\[email protected]#\$%\^&*+-\|\/]{0,6})[ bb]([bb\s\[email protected]#\$%\^&*+-\|\/]{0,6})[uy]([uy\s\[email protected]#\$%\^&* +-\|\/]{0.6})[h4h]\w{0.4}|\w{0.4}[eeЄ]([eeЄ\s\[email protected]#\$%\^&* +-\|\/]{0,6})[bb]([bb\s\[email protected]#\$%\^&*+-\|\/]{0,6})[нn]([ нn\s\[email protected]#\$%\^&*+-\|\/]{0,6})[yy]\w{0,4}|\w{0,4}[ee]([ ee\s\[email protected]#\$%\^&*+-\|\/]{0,6})[bb]([bb\s\[email protected]#\$%\^&*+-\| \/]{0,6})([[email protected]\s\[email protected]#\$%\^&*+-\|\/]{0,6})[tnnt]\w{0,4}|\w{0,10}[Є]([Є\[email protected]#\$%\^&*+-\|\/]{0,6} )[b]\w{0,6}|\w{0,4}[pp]([pp\s\[email protected]#\$%\^&*+-\|\/]{0,6} )[eeei]([eeei\s\[email protected]#\$%\^&*+-\|\/]{0,6})[dd]([dd\s\[email protected]#\$%\^ &*+-\|\/]{0,6})([[email protected]\s\[email protected]#\$%\^&*+-\|\/]{0,6} )[pr]\w{0,12}/i";
$replacement = "÷censorship";
$text = preg_replace($pattern, $replacement, $text);
/*
$pattern - what we are looking for
$replacement - what we will replace with
$text - what we are processing
*/

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
M
Maxim, 2019-09-10
@Bally

In Yii, scripts must be included in the layout in a special way:
Add to the view:

<?php 
$js = <<< JS
      function initMap() {
        var map = new google.maps.Map(document.getElementById('map'), {
          zoom: 8,
          center: {lat: -34.397, lng: 150.644}
        });
        var geocoder = new google.maps.Geocoder();

        document.getElementById('submit').addEventListener('click', function() {
          geocodeAddress(geocoder, map);
        });
      }

      function geocodeAddress(geocoder, resultsMap) {
        var address = document.getElementById('address').value;
        geocoder.geocode({'address': address}, function(results, status) {
          if (status === 'OK') {
            resultsMap.setCenter(results[0].geometry.location);
            var marker = new google.maps.Marker({
              map: resultsMap,
              position: results[0].geometry.location
            });
          } else {
            alert('Geocode was not successful for the following reason: ' + status);
          }
        });
      }
JS;

$this->registerJs( $js, $position = yii\web\View::POS_READY, $key = null );
?>

<?php 
$js = <<< JS
      var autocompletes, marker, infowindow, map;
    function initMap() {
         map = new google.maps.Map(document.getElementById('map'), {
          center: {lat: -33.8688, lng: 151.2195},
          zoom: 13
        });
        infowindow = new google.maps.InfoWindow();

        marker = new google.maps.Marker({
          map: map
        });

        // адрес откуда
        var inputs = document.querySelector('#place_departure');
        autocompletes = new google.maps.places.Autocomplete(inputs);
        
        google.maps.event.addListener(autocompletes, 'place_changed', function () {
            marker.setVisible(false);
            infowindow.close();

            var place = autocompletes.getPlace();
            if (!place.geometry) {
                window.alert("No details available for input: '" + place.name + "'");
                return;
            }
            
              if (place.geometry.viewport) {
                map.fitBounds(place.geometry.viewport);
              } else {
                map.setCenter(place.geometry.location);
                map.setZoom(17);
              }
              
              marker.setIcon(({
                url: place.icon,
                scaledSize: new google.maps.Size(35, 35)
              }));
              marker.setPosition(place.geometry.location);
              marker.setVisible(true);
              
              var place_departure = '';
              if (place.address_components) {
                place_departure = [
                  (place.address_components[0] && place.address_components[0].short_name || ''),
                  (place.address_components[1] && place.address_components[1].short_name || ''),
                  (place.address_components[2] && place.address_components[2].short_name || '')
                ].join(' ');
              }

              infowindow.setContent('<div><strong>' + place.name + '</strong><br>' + place_departure);
              infowindow.open(map, marker);
        });
    }
JS;

$this->registerJs( $js, $position = yii\web\View::POS_READY, $key = null );
?>

Adding to the template (layout)
<script async defer src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap"></script>

S
Sergei Makhlenko, 2017-11-30
@weblive

from an old well-known script.

// выражения, которые где угодно считаются матом
   $f_pregmat='~'.
   '[^и][hхx][уyu][йyяij]|'.   // защита от: прихуй
   '[hхx][уyu][eеЁ][tlvлвт]|'.
   '[hхx][уyu][йyijoeоеёЁ]+[vwbв][oiоы]|'.
   '[pп][ieие][dдg][eaoеао][rpр]|'.
   '[scс][yuу][kк][aiuаи]|'.
   '[scс][yuу][4ч][кk]|'.  
   '[3zsз][aа][eiе][bpб][iи]|'.
   '[^н][eе][bpб][aа][lл]|'.   // защита от: не бал*
   'fuck|xyu|'.                             
   '[pп][iи][zsз3][dд]|'.
   '[z3ж]h?[оo][pп][aаyуыiеe]'.
   '~si';

// сложные слова, типа "оскорблять", писать с пробелом перед словом
   $f_pregmat2='~'.
   ' фак |'.
   ' лох |'.
   ' [бb6][лl]([яy]|ay)|'.
   ' [eiе][bpб][iи]|'.
   ' [eiе][bpб][aeаеёЁ][tlтл]'.
   '~si';

if (preg_match($f_pregmat," $tmp ") || preg_match($f_pregmat2," $tmp ")) {
    echo 'Не нужно ругаться!';
}

L
lxfr, 2017-11-27
@lxfr

Umm ...
We take and replace.
$text = "a bunch of mate";
$replacement = "÷censorship";
$text = preg_replace($pattern, $replacement, $text);
echo $text;
ALL.
Whether this regular season is working or not, I have no idea.

P
profesor08, 2017-11-27
@profesor08

Whatever you think of, in a couple of seconds I will find a way to write everything I need, and no filters will help. It is necessary to do such filtering optionally, so that the user can choose. Secondly, you only need a dictionary of "bad" words, replace everything that is found there with something. Regulator won't help you.

K
kstyle, 2017-11-27
@kstyle

https://github.com/vearutop/php-obscene-censor-rus

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question