#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2017
    Posts
    318
    Rep Power
    1

    Question Banned Words Filter


    Folks,

    Q1. Do you consider the following code to be safe & sound to substitute banned words found on the page ?
    If not, then maybe I try str_replace instead of preg_match ?

    PHP Code:
    <?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($curlCURLOPT_URL'https://www.buzzfeed.com/mjs538/the-68-words-you-cant-say-on-tv?utm_term=.xlN0R1Go89#.pbdl8dYm3X');
    curl_setopt($curlCURLOPT_SSL_VERIFYPEERfalse);
    curl_setopt($curlCURLOPT_RETURNTRANSFERtrue );
    // 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);
    ?>
    Q2. How would you code it yourself ? I mean, may I see a code sample ? I've done my best.

    Q3. If I change this:

    PHP Code:
    // 3). Set cURL options.
    curl_setopt($curlCURLOPT_URL'https://www.buzzfeed.com/mjs538/the-68-words-you-cant-say-on-tv?utm_term=.xlN0R1Go89#.pbdl8dYm3X'); 
    to this:

    PHP Code:
    // 3). Set cURL options.
    $url "https://www.buzzfeed.com/mjs538/the-68-words-you-cant-say-on-tv?utm_term=.xlN0R1Go89#.pbdl8dYm3X";
    curl_setopt($curlCURLOPT_URL"$url"); 
    then it works fine. But, is it safe to do it like this ?

    Q4. Where on Mini Proxy, on which line, would I add the banned words filter code (the code which you see in my Q1) or your banned words filter code so that, when banned words are found on the proxied pages, then the banned words are substituted ?

    Folks, you're welcome to add a few lines of code onto the Mini Proxy so that the proxy users are blocked from viewing pages that contain banned words.
    Mini Proxy is here:
    https://github.com/josh****/miniProx.../miniProxy.php

    Finally, kindly attach the script here so that I can get hold of your update and install it on my site. You're welcome to use the proxy regular and you'e welcome to invite others to use it to.
    I've googled but no luck in finding a shared webhost who will allow me to run a web proxy. :banghead:
    Therefore, you're welcome to recommend many. :wink:
    I'll only hire the dedicated server once I've picked-up a lot of regular users.
    Last edited by UniqueIdeaMan; October 17th, 2017 at 08:20 PM.
  2. #2
  3. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Caro, Michigan
    Posts
    14,814
    Rep Power
    4536
    Does it work? If so, I guess you're good.

    PHP Code:
    $url "https://www.buzzfeed.com/mjs538/the-68-words-you-cant-say-on-tv?utm_term=.xlN0R1Go89#.pbdl8dYm3X"
    curl_setopt($curlCURLOPT_URL"$url"); 
    But, is it safe to do it like this ?
    Is it safe to make a variable and then use it? lol....

    Comments on this post

    • UniqueIdeaMan agrees
    -- Cigars, whiskey and wild, wild women. --
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2017
    Posts
    318
    Rep Power
    1
    Originally Posted by Sepodati
    Does it work? If so, I guess you're good.


    Is it safe to make a variable and then use it? lol....
    If I remember correctly, I tested this few wks back and it only worked if I directly typed the url in the parameter. Did not work if I fed the url making it a variable. However, last night it worked. Therefore, suspected it is an intermittent issue. Therefore, best to ask the pros than do guess work.
    Anyway, do you know the answer to my Q4 ?
    Last edited by UniqueIdeaMan; October 18th, 2017 at 08:01 PM.
  6. #4
  7. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Caro, Michigan
    Posts
    14,814
    Rep Power
    4536
    Originally Posted by UniqueIdeaMan
    suspected it is an intermittent issue
    Suspect you ****ed it up. Code executes the same every time.

    Anyway, do you know the answer to my Q4
    lol, no. Do your own work.
    -- Cigars, whiskey and wild, wild women. --
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2017
    Posts
    318
    Rep Power
    1
    Thread closed.

IMN logo majestic logo threadwatch logo seochat tools logo