TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 03-10-2010, 04:16 AM   #1 (permalink)
The Contributor
 
Tim Dobson's Avatar
 
Join Date: Feb 2010
Posts: 69
Thanks: 16
Tim Dobson is on a distinguished road
Default word filter help

I have this code:
PHP Code:
<?php
                    
$myFile 
"quotes.txt";
$fh fopen($myFile'r');
$ToFilter fread($fhfilesize($myFile));
fclose($fh);
function 
LangFilter($ToFilter)

{

   
// Open the foul.txt for extracting the foul words

   
$Foul = @file("foul.txt");

   
// Loop through the foul words

   
foreach ($Foul as $FoulWord)

   {

      
// Store the current foul word in a variable

      
$FoulWord trim($FoulWord);

      
// If there's a match for the fould world inside the string

      
if (preg_match("/".$FoulWord."/i"$ToFilter))

      {

         
// Get the word length, so that we know how many characters

         // we need to replace with asterisks

         
$WordLength strlen($FoulWord);

         
// Loop through the word's characters

         
for ($i 1$i <= $WordLength$i++)

         {

            
// Replace the characters of the foul word with * (asterisks)

            
$RepChar .= "*";

         }

         
// Replace the dirty string with the filtered string

         
$ToFilter eregi_replace($FoulWord$RepChartrim($ToFilter));

         
$RepChar "";

      }

   }

   
// Return the new string

   
return $ToFilter;

}
echo 
$ToFilter;
?>
quotes.txt is data that is to be loaded to the page and foul.txt is a text file containing all words that are to be filtered. Although its not working... obviously its not right could somone plz correct me, new to php!
Tim Dobson is offline  
Reply With Quote
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
How Can read and search a word from pdf file nanhe Advanced PHP Programming 5 10-15-2009 04:31 AM
Spell Check / Words similar to word - MYSQL russellharrower Advanced PHP Programming 5 08-10-2009 12:43 PM
How to go to a particular page when i click on a particular word? sandhyagupta Absolute Beginners 18 07-03-2009 02:43 PM
Use one word... Alan @ CIT The Lounge 7 03-08-2008 08:09 AM
how to filter textboxes or fields from xss sarmenhb Absolute Beginners 5 02-18-2008 09:58 PM


All times are GMT. The time now is 11:32 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design