From: Lo?c C. <lo...@us...> - 2001-04-08 21:19:57
|
Update of /cvsroot/phpmychat/phpMyChat-0.15/chat/lib In directory usw-pr-cvs1:/tmp/cvs-serv17715/chat/lib Modified Files: swearing.lib.php3 Log Message: Hadn't been updated to 0.15 version Index: swearing.lib.php3 =================================================================== RCS file: /cvsroot/phpmychat/phpMyChat-0.15/chat/lib/swearing.lib.php3,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** swearing.lib.php3 2001/04/03 20:17:40 1.1 --- swearing.lib.php3 2001/04/08 21:19:55 1.2 *************** *** 1,45 **** ! <? ! // This library allows to check for "bad words". Users cannot login or create a room with such words, ! // in messages they are replaced by the "@#$*!" string or the one you choose. ! // Credit for this lib goes to Gustavo Iwamoto <iw...@za...> and Fabiano R. Prestes <zo...@po...> ! function checkwords ($String, $TestOnly) ! { ! // You can add the words you don't want users to use in the $BadWords array bellow. As an eregi ! // function is called to find them in strings, you may use valid POSIX 1003.2 regular expressions ! // (see second line of the array for an example). ! // Note that search is not case sensitive, except for special characters such as accentued ones. ! $BadWords = array ( ! "shit", ! "fuck([[:alpha:]]*)" ! ); ! $ReplaceString = "@#$*!"; // String that will replace "bad words" ! // Don't modify lines bellow ! $Found = false; ! for (reset($BadWords); $ToFind = current($BadWords); next($BadWords)) { ! $Found = eregi(addslashes($ToFind), $String); ! if ($Found) { ! if ($TestOnly) ! { break; - } else ! { ! $String = eregi_replace(addslashes($ToFind), $ReplaceString, $String); ! }; ! }; ! }; ! ! unset($BadWords); ! return ($TestOnly ? $Found : $String); ! } ?> --- 1,81 ---- ! <?php ! // ! // +--------------------------------------------------------------------------+ ! // | phpMyChat version 0.15.0 | ! // +--------------------------------------------------------------------------+ ! // | Copyright (c) 2000-2001 The phpHeaven-team | ! // +--------------------------------------------------------------------------+ ! // | This library allows to check for 'bad words'. Users cannot login or | ! // | create a room with such words, in messages they are replaced by the | ! // | '@#$*!' string or the one you choose. | ! // | enabled. | ! // | | ! // | It is called by the 'chat/lib/index_libs/main_index.lib.php3' script and | ! // | all the ones that put messages in the database (main 'input' scripts and | ! // | some of the commands). | ! // +--------------------------------------------------------------------------+ ! // | From the phpMyChat project: | ! // | http://www.phpheaven.net/projects/phpMyChat/ | ! // | | ! // | Authors: the phpHeaven-team <php...@ya...> | ! // | Gustavo Iwamoto <iw...@za...> | ! // | Fabiano R. Prestes <zo...@po...> | ! // +--------------------------------------------------------------------------+ ! // ! // $Id$ ! // ! // Does not allow the use of swearings in nicks, rooms'names and messages. ! // ! ! /** ! * Check for swearings and optionnaly replace them by another string of ! * characters. ! * ! * You can add all the swearings you want in the '$swearings' array below. As ! * an eregi function is called to find them in strings, you may use valid ! * POSIX 1003.2 regular expressions (see the second line of the array for an ! * example). ! * Note that search is not case sensitive, except for special characters such ! * as accentued ones. ! * ! * @param string the string to search into ! * @param boolean whether to check only (1) or to check and replace swearings ! * (0) ! * ! * @return mixed whether a swearing has been found or not if '$testOnly' ! * value is 1, the cleaned string else ! * ! * @access public ! */ ! function checkWords($str = '', $testOnly = 0) ! { ! $swearings = array ( 'shit', ! 'fuck([[:alpha:]]*)' ! ); ! $replaceBy = '@#$*!'; // String that will replace swearings ! //--- Don't modify lines bellow --- ! $found = false; ! for (reset($swearings); $toFind = current($swearings); next($swearings)) { ! $found = eregi($toFind, $str); ! if ($found) { ! if ($testOnly) break; else ! $str = eregi_replace($toFind, $replaceBy, $str); ! } ! } ! ! unset($swearings); ! return ($testOnly) ? $found : $str; ! } // end of the 'checkWords()' function ?> |