473,378 Members | 1,577 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Finding Banned Words On A Page And Not Within Other Words!

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:

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. /*
  4. ERROR HANDLING
  5. */
  6.  
  7. // 1). $curl is going to be data type curl resource.
  8. $curl = curl_init();
  9.  
  10. // 2). Set cURL options.
  11. curl_setopt($curl, CURLOPT_URL, 'https://www.buzzfeed.com/mjs538/the-68-words-you-cant-say-on-tv?utm_term=.xlN0R1Go89#.pbdl8dYm3X');
  12. curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
  13. curl_setopt($curl, CURLOPT_RETURNTRANSFER, true );
  14.  
  15. // 3). Run cURL (execute http request).
  16. $result = curl_exec($curl);
  17. $response = curl_getinfo( $curl );
  18.  
  19. if( $response['http_code'] == '200' )
  20.    {
  21.     //Set banned words.
  22.     $banned_words = array("Prick","Dick","***");
  23.  
  24.     //Separate each words found on the cURL fetched page.
  25.     $word = explode(" ", $result);
  26.  
  27.    //var_dump($word);
  28.  
  29.    for($i = 0; $i <= count($word); $i++)
  30.       {
  31.       foreach ($banned_words as $ban) 
  32.          {
  33.          if (strtolower($word[$i]) == strtolower($ban))
  34.             {
  35.              echo "word: $word[$i]<br />";
  36.              echo "Match: $ban<br>";
  37.             }
  38.          else
  39.             {
  40.              echo "word: $word[$i]<br />";
  41.              echo "No Match: $ban<br>";  
  42.             }
  43.          }
  44.       }
  45.    }  
  46.  
  47. // 4). Close cURL resource.
  48. curl_close($curl);
  49.  
  50.  
Oct 3 '17 #1
0 1545

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Christoph Pingel | last post by:
Hi all, an interesting problem for regex nerds. I've got a thesaurus of some hundred words and a moderately large dataset of about 1 million words in some thousand small texts. Words from the...
1
by: Ken Fine | last post by:
I need a client-side check against a static list of "banned words" before a form is submitted. Can someone point me to a script that does this?
4
by: Bik | last post by:
I'm building a list of customer orders via ASP/VBscript. e.g: 51 John Doe $1,201.50 52 Jane Smith $ 500.00 53 Jim Miller $1,250.25 I want order numbers 51, 52, 53 hyperlinked...
11
by: tmshaw | last post by:
I'm a newb in a c++ class... I need to read the standard input into a couple strings. Then determine whether or not the same word is used IN SUCCESSION (ex. this cat cat is really mean.). ...
3
by: Rob | last post by:
You can find datagrid in page by refering the form. Gatagrid is a child control of Form. Here is the code ----------------- Dim ctl As New Control For Each ctl In...
6
by: John Sedlak | last post by:
Hello, in one of my pages I have an include: <!--#include file="console.aspx" --> Now...Inside console.aspx, I want to be able to find the name of the page that included it. This is because I...
4
by: zdrakec | last post by:
Hello all: I have a detail page from which the user clicks a hyperlink to get a list page. On the list page, I have included a hyperlink whose NavigateURL property is set, at run time, to be the...
7
by: Timo Haberkern | last post by:
Hi there, i have some troubles with my TSearch2 Installation. I have done this installation as described in http://www.sai.msu.su/~megera/oddmuse/index.cgi/Tsearch_V2_compound_words...
3
by: bagelman | last post by:
Hi, I want to find repeating words in a long string with Regular Expressions. I tried to write a regular expression but it didn't work. "\b(?<word>\w+)\s+(\k<word>)\b" This RegEx finds...
2
by: dechen | last post by:
How do I compare words of sentences with a dictionary and get it's corresponding value. e.g, This is the dictionary format. WORD Pronunciation try t-r-y-0| ...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.