emsy Posted April 20, 2010 Report Share Posted April 20, 2010 function coloris($value) { $value = preg_replace('/(\[color=)(.+?)(\])(.+)(\[\/color\])/', '<span style=\'color:\\2;\'>\\4</span>', $value); return $value; } Problēma tāda, ka ja bbkodi ir izmantoti vairāki, un starp viņiem nav \n, tad viss tiek tā kā samests kopā. Piem. Input: asd[color=#000]asd[/color]asd[color=#fff]asd[/color]asd [color=#000]asd[/color] Output: asd<span style='color:#000;'>asd[/color]asd[color=#fff]asd</span>asd <span style='color:#000;'>asd</span> Cik zinu (.+) neakceptē \n tāpēc bbkodi kuri ir citā rindā neriktējas kopā, bet vienalga paliek problēma, kā novērst viņu riktēšanos kopā?? Quote Link to comment Share on other sites More sharing options...
briedis Posted April 20, 2010 Report Share Posted April 20, 2010 (edited) Nav vajadzības izgudrot riteni no jauna... http://php.net/manual/en/book.bbcode.php Edited April 20, 2010 by briedis Quote Link to comment Share on other sites More sharing options...
chizijs Posted April 20, 2010 Report Share Posted April 20, 2010 function coloris($value) { $value = preg_replace('/(\[color=)(.+?)(\])(.+?)(\[\/color\])/', '<span style=\'color:$1\'>$1</span>', $value); return $value; } ā šita? Quote Link to comment Share on other sites More sharing options...
briedis Posted April 20, 2010 Report Share Posted April 20, 2010 (edited) function coloris($value) { $value = preg_replace('/(\[color=)(.+?)(\])(.+?)(\[\/color\])/', '<span style=\'color:$1\'>$1</span>', $value); return $value; } ā šita? Uzhakos jūsu lapas vienā rāvienā. Es tak iedevu linku! [color=blablabla'<script>alert('xss');</script>]color[/color], jauki, ne? (dotais piemērs nestrādās, bet domu sapratāt, es ceru...) Edited April 20, 2010 by briedis Quote Link to comment Share on other sites More sharing options...
chizijs Posted April 20, 2010 Report Share Posted April 20, 2010 htmlspecialcahrs $value = htmlspecialchars($value); $value = preg_replace.. Quote Link to comment Share on other sites More sharing options...
marcis Posted April 20, 2010 Report Share Posted April 20, 2010 BB kods jau nav noiets etaps? WYSIWYG FTW Bet par tēmu - http://lv.php.net/manual/en/reference.pcre.pattern.modifiers.php U (PCRE_UNGREEDY)This modifier inverts the "greediness" of the quantifiers so that they are not greedy by default, but become greedy if followed by ?. It is not compatible with Perl. It can also be set by a (?U) modifier setting within the pattern or by a question mark behind a quantifier (e.g. .*?). Quote Link to comment Share on other sites More sharing options...
Grey_Wolf Posted April 20, 2010 Report Share Posted April 20, 2010 BB kods jau nav noiets etaps? WYSIWYG FTW nee noteikti nee ... ir Ljoti daudz viets kur nelielai eertibai varetu atstat B un i ka arii dazus citus formatesanas riikus, bet noteikti ne WYSIWYG, kas idejiski ir baazets uz Brauzera editesanas iespejam... Quote Link to comment Share on other sites More sharing options...
marcis Posted April 21, 2010 Report Share Posted April 21, 2010 Es tik un tā uzskatu, ka BB kods ir domāts advancētākiem cilvēkiem. Neredzu problēmu to pašu bold, italic, underline pasniegt vizuāli -> "cmuki kā vōrdā". Quote Link to comment Share on other sites More sharing options...
codez Posted April 21, 2010 Report Share Posted April 21, 2010 WYSIWYG bbcode editors: http://wysiwygbbcode.codeplex.com/ Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.