PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
hob_goblin
Forum Regular
Posts: 978 Joined: Sun Apr 28, 2002 9:53 pm
Contact:
Post
by hob_goblin » Sun Aug 11, 2002 6:07 pm
I just want your opinions before i put this code i made into use:
Code: Select all
function finalize($string){
$string = strip_tags($string);
$string = eregi_replace(
"\їurl=(їa-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+]+)\](.*)\ї/url\]",
"<a href="\\1" target="_blank">\\2</a>",
$string);
$string = eregi_replace(
"\їurl\](їa-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+]+)\ї/url\]",
"<a href="\\1" target="_blank">\\1</a>",
$string);
$string = eregi_replace(
"\їimg\](їa-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+]+)\ї/img\]",
"<img src="\\1" border="0" />",
$string);
$string = eregi_replace(
"\їb\](.*)\ї/b\]",
"<b>\\1</b>",
$string);
$string = eregi_replace(
"\їu\](.*)\ї/u\]",
"<u>\\1</u>",
$string);
$string = eregi_replace(
"\їi\](.*)\ї/i\]",
"<i>\\1</i>",
$string);
return $string;
}
lc
Forum Contributor
Posts: 188 Joined: Tue Apr 23, 2002 6:45 pm
Location: Netherlands
Post
by lc » Sun Aug 11, 2002 8:15 pm
I think it looks amazing, but that's prolly due to the fact that I have no idea what it would do
hob_goblin
Forum Regular
Posts: 978 Joined: Sun Apr 28, 2002 9:53 pm
Contact:
Post
by hob_goblin » Sun Aug 11, 2002 8:19 pm
the equivalent of like [ url ] thing [ /url ] and [ b ] [ / b ] etc...
daemorhedron
Forum Commoner
Posts: 52 Joined: Tue Jul 23, 2002 11:03 am
Post
by daemorhedron » Sun Aug 11, 2002 8:52 pm
Looks good. Don't know how you are using it, but from the looks of it, it wouldn't allow me to type something like <example>this is a test</example>. That might not be an important or even a wanted feature for you of course, but thought I would mention it. If you do want to allow things like that, you may want to look into htmlspecialchars() and the like.
HTH
fatalcure
Forum Contributor
Posts: 141 Joined: Thu Jul 04, 2002 12:57 pm
Contact:
Post
by fatalcure » Sun Aug 11, 2002 10:38 pm
i use this:
Code: Select all
function parseCode($data) {
$data = " " . $data;
$data = preg_replace("#\їb\](.*?)\ї\/b\]#si", "<b>\\1</b>", $data);
$data = preg_replace("#\їi\](.*?)\ї\/i\]#si", "<i>\\1</i>", $data);
$data = preg_replace("#\їu\](.*?)\ї\/u\]#si", "<u>\\1</u>", $data);
//img
$data = preg_replace("#\їimg\](http:\/\/)?(.*?)\ї\/img\]#si", "<IMG SRC="http://\\2" BORDER=0>", $data);
//url validation
$data = eregi_replace('(її:space:]()ї{}])(www.ї-a-zA-Z0-9@:%_\+.~#?&//=]+)', '\\1<A HREF="http://\\2" target="_blank">\\2</a>', $data);
$data = eregi_replace('(її:space:]()ї{}])(http://.ї-a-zA-Z0-9@:%_\+.~#?&//=]+)', '\\1<A HREF="\\2" target="_blank">\\2</a>', $data);
$data = preg_replace("/\їurl\](http:\/\/)?(.*?)\ї\/url\]/si", "<A HREF="http://\\2" TARGET="_blank">\\2</A>", $data);
$data = preg_replace("/\їurl=(http:\/\/)?(.*?)\](.*?)\ї\/url\]/si", "<A HREF="http://\\2" TARGET="_blank">\\3</A>", $data);
$data = preg_replace("/\їemail\](.*?)\ї\/email\]/si", "<A HREF="mailto:\\1">\\1</A>", $data);
//color
$data = preg_replace("#\їcolor=(\#ї0-9A-F]{6}|їa-z\-]+)\](.*?)\ї/color\]#si", "<font color=\\1>\\2</font>", $data);
//size
$data = preg_replace("#\їsize=(ї0-5])\](.*?)\ї/size\]#si", "<font size=\\1pt>\\2</font>", $data);
return trim($data);
}
hob_goblin
Forum Regular
Posts: 978 Joined: Sun Apr 28, 2002 9:53 pm
Contact:
Post
by hob_goblin » Sun Aug 11, 2002 10:48 pm
ahh, thanks a TON.