Webmaster общности: Predpriemach.com | SearchEngines.bg

    PHP – Система за цензуриране на думи

    Създайте файл : censor.php Тозй файл ще взима думите от файла words.txt (който трябва също да създадете), Във файла words.txt сложете думите които искате да се цензурират.

    censor.php code

    <?
    //Grab Word File
    $bad_words = @file("words.txt");
    function censor($text){
    $rop='*';
    //words.txt will be where all the bad words will be stored. What this does is it grabs
    it and feeds it to the small script below
    
    //Start Censoring
    for ($i=1;$i<strlen($text);$i++){
    $replace .= $rop;
    }
    $text = substr_replace($text, $replace, 1);
    return $text;
    }
    
    //The above code will take the words its being fed and add * to them so it will not display the full word(s)
    
    //Finished Product
    
    for ($i=0; $i<count($bad_words); $i++) {
    $yourVar = eregi_replace($bad_words[$i], $this->censor($bad_words[$i]), $yourVar);
    }
    echo $yourVar;
    
    //This is the last part to the script what this does is echos the word so lets say you have the word: hell
    on the censor list it
    will probably be echod as: h***
    
    ?>

    Оставете коментар