За това ли говориш:
Код:
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<script type="text/javascript">
//Variables for controlling opening and closing tags (function tag)
var b = 2;
var i = 2;
var u = 2;
var q = 2;
var c = 2;
var url = 2;
var img = 2;
//Function for creating non-font tags
function tag(v, tagadd, newbut, tagclose, oldbut, name) {
if (eval(v)%2 == 0) {
eval("window.document.editform."+name+".value = newbut;");
var post = window.document.editform.post.value;
window.document.editform.post.value = post + tagadd;
window.document.editform.post.focus();
} else {
eval("window.document.editform."+name+".value = oldbut;");
var post = window.document.editform.post.value;
window.document.editform.post.value = post + tagclose;
window.document.editform.post.focus();
}
eval(v+"++;");
}
//Function for adding font color and size tags
function font(bbopen, bbclose) {
var post = document.editform.post;
post.value += bbopen + bbclose;
post.focus();
return;
}
//Function for adding smilies
function smilie (smilie) {
var post = document.editform.post;
post.value += smilie;
post.focus();
return;
}
//Helpbox messages
bold_help = "Bold text: [b]text[/b]";
italic_help = "Italic text: [i]text[/i]";
underline_help = "Underline text: [u]text[/u]";
quote_help = "Quote text: [quote]text[/quote] or [quote="name"]text[/quote]";
code_help = "Code display: [code]code
";
img_help = "Insert image:
";
url_help = "Insert URL:
http://url or
URL text";
fontcolor_help = "Font color:
text Tip: you can also use color=#FF0000";
fontsize_help = "Font size:
small text";
//Function for displaying help information
// Shows the help messages in the helpline window
function helpline(help) {
var helpbox = document.editform.helpbox;
helpbox.value = eval(help + "_help");
}
//Function to confirm reset
function confirm_reset () {
if(confirm("If you continue you will loose everything you have entered so far. \n \n" +
"Click OK to proceed and start again. \n \n Alternatively click cancel to continue " +
"working on your post.")) {
return true;
}
else {
return false;
}
}
//Check the form submission for errors
function checkForm() {
var subject = document.editform.subject;
var post = document.editform.post;
//Check to make sure post lengths are sensible
if (subject.value.length < 2 && post.value.length < 2) {
alert("This is a short post!" + " \n \n " +
"We require that each post (and subject) \n" +
"be at least 2 characters long. \n \n" +
"Go back and try again.");
return false;
}
else { if (subject.value.length < 2) {
alert("We require that the subject \n" +
"be at least 2 characters long. \n \n" +
"Go back and try again.");
return false;
}
else { if (post.value.length < 2) {
alert("We require that each post \n" +
"be at least 2 characters long. \n \n" +
"Go back and try again.");
return false;
}
else {
return true;
}
}
}
}
</script>
<?php
function bbcode($text){
$text=preg_replace("/\[b\](.+?)\[\/b\]/s", '<b>$1</b>',$text);
$text=preg_replace("/\[i\](.+?)\[\/i\]/s", '<i>$1</i>',$text);
$text=preg_replace("/\[u\](.+?)\[\/u\]/s", '<u>$1</u>',$text);
$text=preg_replace("/\[quote\](.+?)\[\/quote\]/s", '<table cellspacing="1" width="100%" border="0"><tr><td>Quote:</td></tr><tr><td width="100%" style="border:solid 1px black">$1</td></tr></table>',$text);
$text=preg_replace("/\[quote\=(.+?)](.+?)\[\/quote\]/s", '<table cellspacing="1" width="100%" border="0"><tr><td>$1 каза:</td></tr><tr><td width="100%" style="border:solid 1px black">$2</td></tr></table>',$text);
$text=preg_replace("/\[url\](.+?)\[\/url\]/s", '<a href="$1">$1</a>',$text);
$text=preg_replace("/\[url\=(.+?)\](.+?)\[\/url\]/s", '<a href="$1">$2</a>',$text);
$text=preg_replace("/\[img\](.+?)\[\/img\]/s", '<img src="$1" alt="User submitted image" title="User submitted image"/>',$text);
$text=preg_replace("/\[color\=(.+?)\](.+?)\[\/color\]/s", '<span style="color:$1">$2</span>',$text);
$text=preg_replace("/\[size\=(.+?)\](.+?)\[\/size\]/s", '<span style="font-size:$1">$2</span>',$text);
$text=preg_replace("/\[code\](.+?)\[\/code\]/s",'<table cellspacing="1" width="100%" border="0"><tr><td>Code:</td></tr><tr><td width="100%" style="border:solid 1px black">$1</td></tr></table>',$text);
$text = nl2br($text);
return $text;
}
$htmlcode = $_POST['post'];
if (!$htmlcode){
?>
<form action="bbcode_form.php" method="post" name="editform" onsubmit="return checkForm(this)">
<input type="button" class="button" value="bold" name="bold" onclick="javascript:tag('b', '
', 'bold*', '', 'bold', 'bold');" onMouseOver="helpline('bold')" />
<input type="button" class="button" value="italic" name="italic" onclick="javascript:tag('i', '
', 'italic*', '', 'italic', 'italic');" onMouseOver="helpline('italic')" />
<input type="button" class="button" value="underline" name="underline" onclick="javascript:tag('u', '
', 'underline*', '', 'underline', 'underline');" onMouseOver="helpline('underline')" />
<input type="button" class="button" value="quote" name="quote" onclick="javascript:tag('q', '
', 'quote', 'quote');" onMouseOver="helpline('quote')" />
<input type="button" class="button" value="code" name="code" onclick="javascript:tag('c', '
', 'code', 'code');" onMouseOver="helpline('code')" />
<input type="button" class="button" value="url" name="url" onclick="javascript:tag('url', '
', 'url*', '', 'url', 'url');" onMouseOver="helpline('url')" />
<input type="button" class="button" value="img" name="img" onclick="javascript:tag('img', '
', 'img', 'img');" onMouseOver="helpline('img')" />
<hr>
Font size: <select name="fontsize" onChange="font('.value + ']', ''); this.selectedIndex=2;" onMouseOver="helpline('fontsize')" class="form_elements_dropdown">
<option value="50%" >Tiny</option>
<option value="75%" >Small</option>
<option value="100%" selected >Normal</option>
<option value="150%" >Large</option>
<option value="200%" >Huge</option>
</select>
Font color: <select name="fontcolor" onChange="font('[color=' + this.form.fontcolor.options[this.form.fontcolor.selectedIndex].value + ']', '[/color]'); this.selectedIndex=0;" onMouseOver="helpline('fontcolor')" class="form_elements_dropdown" >
<option value="black" style="color:black">Black</option>
<option value="silver" style="color:silver">Silver</option>
<option value="gray" style="color:gray">Gray</option>
<option value="maroon" style="color:maroon">Maroon</option>
<option value="red" style="color:red">Red</option>
<option value="purple" style="color

urple">Purple</option>
<option value="fuchsia" style="color:fuchsia">Fuchsia</option>
<option value="navy" style="color:navy">Navy</option>
<option value="blue" style="color:blue">Blue</option>
<option value="aqua" style="color:aqua">Aqua</option>
<option value="teal" style="color:teal">Teal</option>
<option value="lime" style="color:lime">Lime</option>
<option value="green" style="color:green">Green</option>
<option value="olive" style="color

live">Olive</option>
<option value="yellow" style="color:yellow">Yellow</option>
<option value="white" style="color:white">White</option> </select>
<hr>
<textarea rows="10" cols="56" name="post" class="form_elements_text"></textarea>
<hr>
<input type="submit" name="Post" value="Пусни" class="button"/>
<input type="reset" value="Започни наново" class="button" onclick="javascript:confirm_reset();"/>
<?php
} else {
$htmlcode = htmlspecialchars("$htmlcode", ENT_QUOTES);
echo bbcode("$htmlcode");
}
?>[/code]
?