Php Lovers!
I am NOT searching for banned words within other words on a page but searching for banned words within a loaded page.
I am not actually looking for banned words within other words but within the page (meta tags, content).
And so, if I am looking for the word "cock", then the word "cockerel" should not trigger the filter.
I just tested this code and, yes, as expected the code works but as you can guess there is a lot of cpu power cycling through. One moment the page loads, the other moment it goes grey and shows signs that the page is taking too long to load. And all this on localhost. Now, I can imagine what my webhost would do!
So now, we will have to come-up with a better solution. Any ideas ?
How-about we do not get the script to check on the loaded page for all the banned words ? How-about we get the script to halt as soon as 1 banned word is found and an echo has been made which banned word has been found and where on the page ? (meta tags, body content, etc.).
Any code suggestions ?
Here is what I got so far:
I am NOT searching for banned words within other words on a page but searching for banned words within a loaded page.
I am not actually looking for banned words within other words but within the page (meta tags, content).
And so, if I am looking for the word "cock", then the word "cockerel" should not trigger the filter.
I just tested this code and, yes, as expected the code works but as you can guess there is a lot of cpu power cycling through. One moment the page loads, the other moment it goes grey and shows signs that the page is taking too long to load. And all this on localhost. Now, I can imagine what my webhost would do!
So now, we will have to come-up with a better solution. Any ideas ?
How-about we do not get the script to check on the loaded page for all the banned words ? How-about we get the script to halt as soon as 1 banned word is found and an echo has been made which banned word has been found and where on the page ? (meta tags, body content, etc.).
Any code suggestions ?
Here is what I got so far:
Code:
<?php
/*
ERROR HANDLING
*/
// 1). $curl is going to be data type curl resource.
$curl = curl_init();
// 2). 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 );
// 3). Run cURL (execute http request).
$result = curl_exec($curl);
$response = curl_getinfo( $curl );
if( $response['http_code'] == '200' )
{
//Set banned words.
$banned_words = array("Prick","Dick","***");
//Separate each words found on the cURL fetched page.
$word = explode(" ", $result);
//var_dump($word);
for($i = 0; $i <= count($word); $i++)
{
foreach ($banned_words as $ban)
{
if (strtolower($word[$i]) == strtolower($ban))
{
echo "word: $word[$i]<br />";
echo "Match: $ban<br>";
}
else
{
echo "word: $word[$i]<br />";
echo "No Match: $ban<br>";
}
}
}
}
// 4). Close cURL resource.
curl_close($curl);