Dave |
|
---|---|
Hi, so as urlkiller asked me to post that in forums, here it is: setup: <?PHP /* ==================== [BEGIN_SED_EXTPLUGIN] Code=wordcensor Name=Word Censor Description=neocrome.net Version=0.9 Date=12-09-2007 Author=urlkiller Copyright= Notes=This plugin was coded in 12-09-2007, 23.02.2012 i took it together so people could use it. SQL= Auth_guests=RW Lock_guests=RW Auth_members=RW Lock_members=RW [END_SED_EXTPLUGIN] ==================== */ if ( !defined('SED_CODE') ) { die("Wrong URL."); } ?> wordcensor.forum.php <?PHP /* ==================== [BEGIN_SED] File=plugins/wordcensor/wordcensor.forum.php Version= Updated= Type=Plugin Author=urlkiller Description= [END_SED] [BEGIN_SED_EXTPLUGIN] Code=wordcensor Part=forums File=wordcensor.forum Hooks=forums.posts.loop Tags= Order=10 [END_SED_EXTPLUGIN] ==================== */ // include word list only once ;) require_once('inc/wordcensor.wordlist.php'); // overwrite the original output from forum posts... $t->assign(array( // the posts text itself "FORUMS_POSTS_ROW_TEXT" => str_replace($wc_censor,$wc_replace,$row['fp_text']), // the tile of the forums post "FORUMS_POSTS_PAGETITLE" => str_replace($wc_censor,$wc_replace,$toptitle), )); wordcensor.page.php: "PAGE_TEXT" => sed_parse(sed_cc(str_replace($wc_censor,$wc_replace,$pag['page_text']))), $cfg['parsebbcodepages'], $cfg['parsesmiliespages'], 1, // comments of a page "PAGE_COMMENTS_DISPLAY" => str_replace($wc_censor,$wc_replace,$comments_display), // the page title itself "PAGE_TITLE" => str_replace($wc_censor,$wc_replace,$pag['page_fulltitle']), wordcensor.comments.php: "COMMENTS_ROW_TEXT" => str_replace($wc_censor,$wc_replace,$com_text), works good on 0,6,21 except minichat thing however i think it can be replaced by bbcode 'pcre' (preg_replace) i dunno if the part for the bbcode is correct but it works in the minichat Your advertisement here :-)
Cotonti Genoa based site: forgotten-garage.pl |
|
Отредактировано: Dave (16.02.2016 17:25, 8 лет назад) |
Trustmaster |
|
---|---|
Why not upload it to Downloads instead? Another note: sed_cc() function is deprecated. Use htmlspecialchars() instead. May the Source be with you!
|
esclkm |
|
---|---|
Why do you does not use callbacks for templates? littledev.ru - мой маленький зарождающийся блог о котонти.
снижение стоимости программирования и снижение стоимости производства разные вещи. Первое можно скорее сравнить с раздачей работникам дешевых инструментов, чем со снижением зарплаты |
Dave |
|
---|---|
guys, easy, maybe i simply named it wrong, its more like WIP, if urlkiller will help get the minichat working ill upload to downloads if he will let me alos i'd expect that easer way would be use bbcode / preg_replace thing also :p as u see u gave some tips, questions, so ill try to develop it a bit, so it wont be some old code ;p Your advertisement here :-)
Cotonti Genoa based site: forgotten-garage.pl |
urlkiller |
|
---|---|
@Dave, this is actually looking not that bad... ! you'll need to make a part for the list.tpls too.
as for comments, this will be a little bit harder then for pages and lists.
this should do the trick.. Added 39 seconds later: and yes, check for deprecated stuff please!!! in PHP as well as cotonti!! URL shortener: <a href="http://bbm.li/!7AD5C7">http://bbm.li/!7AD5C7</a>
|
Dave |
|
---|---|
hey ppl, i did some small porting to SIENA 9.18 and i stopped, for now, its like i have to make these for tons of 'parts' (like urlkiller mentioned: list), basicly i have doubts about the idea, i mean first of all there has to be a way to make php file for every input and the second - which way is better, such plugin or simply bbcode (pcre) i did dig in google but still not sure <?PHP /* ==================== [BEGIN_COT_EXT] Code=wordcensor Name=Word Censor Description=Word filter Version=0.9b Date=16-feb-2016 Author=Dave Copyright=urlkiller (neocrome.net) Notes=This plugin was coded in 12-09-2007 by urlkiller<br /> Ported to Cotonti Genoa / Siena in 2012-2016.<br />-Dave. Auth_guests=R Lock_guests=W12345A Auth_members=R Lock_members=W12345A [END_COT_EXT] ==================== */ defined('COT_CODE') or die('Wrong URL'); ?> <?PHP /* ==================== [BEGIN_COT_EXT] Hooks=forums.posts.loop [END_COT_EXT] ==================== */ defined('COT_CODE') or die('Wrong URL'); require_once cot_incfile('wordcensor', 'plug'); // overwrite the original output from forum posts... $t->assign(array( "FORUMS_POSTS_ROW_TEXT" => str_replace($wc_censor,$wc_replace,$row['fp_text']), "FORUMS_POSTS_PAGETITLE" => str_replace($wc_censor,$wc_replace,$toptitle), )); // note: need to add line for topic_description ?> <?PHP include('wordlist.php'); $filename = $cfg['plugins_dir']."/wordcensor/inc/words.txt"; $fp = fopen( $filename, "r" ) or die("Couldn't open $filename"); while ( ! feof( $fp ) ) { $line = fgets( $fp ); if (trim($line) != "") { $values = explode("\t", $line); array_push($wc_censor, "/".$values[0]."/i"); array_push($wc_replace, $values[1]); } } ?> <?PHP $wc_censor = array( 'word', 'word2' 'www.link.com' 'www.link2.com' ); $wc_replace = array( ' CENZORED ', ' CENZORED_different_way ', ' FORBIDDEN LINK ' ' ALSO FORBIDDEN' , ); ?>
Your advertisement here :-)
Cotonti Genoa based site: forgotten-garage.pl |
Raylandar |
|
---|---|
I would add it as a module, and store the items you want filtered in the database.
You could easily create a table, that had three items id, as int, badword, as varchar(75), permission(as tinyint) Reference the array instead of bad words by loading the db query
|