WebsiteBaker 2.13.8 is now available!
R.I.P Dietmar (luisehahne) and thank you for all your valuable work for WBhttps://forum.websitebaker.org/index.php/topic,32355.0.html
... I was wondering if there is an easy way to call them from within php, rather than html?
$myBadWords = array('kacka' => '(badword!)','vucker' => '(don\'t use this word, man!)','bimber' => '(censored!)',)
$content = str_replace(array_keys($myBadWords), array_values($myBadWords), $content );
function bad_word_filter(&$output){ $database = new database(); $badwords = $database->get_one("SELECT code FROM mod_droplets WHERE name = 'bad_word_list';"); if($badwords == '') { $badwords = 'bad, word, list'; } $iarray = explode(",",$badwords) ; foreach($iarray as $i){ $checklist = explode(" ",$output) ; foreach($checklist as $c){ if(metaphone(trim($c))== metaphone(trim($i))){ $output = eregi_replace($c,'###',$output) ; } } } foreach($iarray as $i){ $output = eregi_replace(trim($i),'##',$output) ; } return $output ;}
It is a lazy programmers technique for saving some values in a table that is easy to get to, so I can edit the list whenever I like from the backend.
<?php function opff_bad_word_filter(&$content, $page_id, $section_id, $module, $wb) { $values['badwords'] = "my, bad, words, string, comma, separated"; $iarray = explode(",",$values['badwords']) ; if(!empty($iarray)){ foreach($iarray as $i){ $checklist = explode(" ",$content) ; foreach($checklist as $c){ if(metaphone(trim($c))== metaphone(trim($i))) $content = eregi_replace($c,'###',$content); } } foreach($iarray as $i) $content = eregi_replace(trim($i),'##',$content) ; } return(TRUE);}?>
<?php$content = str_replace( $c, str_repeat( '#', strlen($c)) , $content );?>
<?php$content = str_replace( $c, substr($c, 0, 1).str_repeat( '*', strlen($c)-2).substr($c, -1) , $content );?>
[joke] I ask myself only what the pharmaceutical industry will pay for this excellent sedativum? [/joke]
Your idea is a good one though, and I wonder if there is a need for a WB Function_Store module where developers can create functions and store them in a central data file - similar to Droplets (and Snippets). The benefit of this idea is that functions developed for a module can be used by other modules, instead of re-inventing the wheel, or copying code, for every new module.
please try to refactoring this function to optimize the speed to a acceptable manner and reduce the CPU load!