Question

Filter Code Goes On Which Line ?

By phprepublican ·
Folks,

The following code is cURL script fetching a page and filtering it's content for banned words.

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

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

Filter 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("****", "nut");
// 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);
?>
0 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Share your knowledge
Back to Web Development Forum
0 total posts (Page 1 of 1)  

Related Discussions

Related Forums