Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Where & on Which Line Banned Word Filter Code On Mini Proxy to be Put in PHP?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 742
    Answer it

    Folks,

    Where on Mini Proxy, on which line, would I add the banned words filter code (the code which you see below) so that, when banned words are found on the proxied pages, then the banned words are substituted ?

    Mini Proxy is here:
    https://github.com/joshdick/miniProxy/blob/master/miniProxy.php

    Filter Code:

    [php]

    <?php

    /*
    ERROR HANDLING
    */
    //declare(strict_types=1);
    ini_set('display_errors', '1');
    ini_set('display_startup_errors', '1');
    error_reporting(E_ALL);
    mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);

    // 1). Set banned words.
    $banned_words = array("blow", "nut", "bull****");
    // 2). $curl is going to be data type curl resource.
    $curl = curl_init();
    // 3). Set cURL options.
    curl_setopt($curl, CURLOPT_URL, 'https://www.buzzfeed.com/mjs538/the-68-words-you-cant-say-on-tv?utm_term=.xlN0R1Go89#.pbdl8dYm3X');
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true );
    // 4). Run cURL (execute http request).
    $result = curl_exec($curl);
    if (curl_errno($curl)) {
        echo 'Error:' . curl_error($curl);
    }
    $response = curl_getinfo( $curl );
    if($response['http_code'] == '200' )
    {
        $regex = '/\b';     
        $regex .= implode('\b|\b', $banned_words);   
        $regex .= '\b/i'; 
        $substitute = '****';
        $cleanresult = preg_replace($regex, $substitute, $result);
        echo $cleanresult;
    }
    curl_close($curl);
    ?>

    [/php]

 0 Answer(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: