bbcode в сайта ми

nasko4

Registered
Здравейте имам сайт в който през админ панел се въвежда текст в форма с текст ареа и така слагам текст в сайта. Но в текст ареата нямам форматиране на текста и другите екстри които ми трябват. Чувал съм че може да се сложи bbcode и текст ареата да стане като тази по форомите (като тази тук също) Някой ще ми каже ли възможно ли е и ако да как да го направя. Мн ще съм ви благодарен защото ми е спешно благодаря ви.


П.С Ако има варянт за добавяне на екстри към текст ареа също е добра идея :)
 
Намерих това и го интегрирах в сайта си http://tinymce.moxiecode.com/ , но накрая резултата е че ми показва текста с кода за форматиране


Юнска версия
<p> <ul type="disc"> <li class="MsoNormal"><span lang="EN-US">Български език и литература- 17 май 2009г., начало 08:00 ч</span></li> <li class="MsoNormal"><span lang="EN-US">Втори държавен зрелостен изпит- 19 май 2009г., начало 08:00</span>ч</li> <li class="MsoNormal"><span lang="EN-US">Държавни зрелостни изпити по желание на ученика, като следва:</span></li> </ul> </p>

Скрипта който използвам за текста е :


Код:
<?php 
echo '<html><head>' ;
echo '<script type="text/javascript" src="tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
tinyMCE.init({

// General options

mode : "textareas",

theme : "advanced",

plugins : "safari,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink
,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,c
ontextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xh
tmlxtras,template,imagemanager,filemanager",

// Theme options
theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justif
ycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizese
lect",
theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,out
dent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|
,insertdate,inserttime,preview,|,forecolor,backcolor",
theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iesp
ell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,c
ite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pa
gebreak,|,insertfile,insertimage",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : true,
// Example content CSS (should be your site CSS)
content_css : "css/example.css",
// Drop lists for link/image/media/template dialogs
template_external_list_url : "js/template_list.js",
external_link_list_url : "js/link_list.js",
external_image_list_url : "js/image_list.js",
media_external_list_url : "js/media_list.js",
// Replace values for the template plugin
template_replace_values : {
username : "Some User",
staffid : "991234"
}
});
</script>' ;
echo '</head><body> ';
echo '<table width="300" height="10" border="1">' ;
echo '<tr><td><a href="index.php">Начало</a> | <a href="add_index.php">Добави текст</a> | <a href="admin.php">АДМИН Панел</a></td></tr></table>' ;
echo '<form action="" method="post">
Заглавие: <br />
<input type="text" name="name" />
<br />
Текст: <br />
<textarea name="txt" cols="100" rows="30"></textarea>
<br />
<input type="submit" name="submit" value="Добави" />
</form>' ;
echo '</body>
</html>' ;

if (isset($_POST["submit"])) {
//настройки за база данни
$dbhost = "localhost";
$dbuser = "***";
$dbpass = "***";
$dbname = "***";
$conn = mysql_connect($dbhost, $dbuser, $dbpass)or die(mysql_error());
mysql_select_db($dbname, $conn)or die(mysql_error());
if (!empty($_POST["name"])) $name = htmlspecialchars($_POST["name"]);
else $errMsg = "Не сте въвели заглавие!<br />";
if (!empty($_POST["txt"])) $txt = htmlspecialchars($_POST["txt"]);
else $errMsg = "Не сте въвели текст!<br />";
if (empty($errMsg)) {
$insert = mysql_query("INSERT INTO nachalo (name, txt) VALUES('$name', '$txt')")or die(mysql_error());
echo 'Текста е добавен успешно! <a href="index.php">Начало</a>';
} else echo $errMsg;
mysql_close();
}
?>


а този за показване на текста е :


Код:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<script type="text/javascript" src="tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
tinyMCE.init({

// General options

mode : "textareas",

theme : "advanced",

plugins : "safari,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,imagemanager,filemanager",

// Theme options
theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak,|,insertfile,insertimage",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : true,
// Example content CSS (should be your site CSS)
content_css : "css/example.css",
// Drop lists for link/image/media/template dialogs
template_external_list_url : "js/template_list.js",
external_link_list_url : "js/link_list.js",
external_image_list_url : "js/image_list.js",
media_external_list_url : "js/media_list.js",
// Replace values for the template plugin
template_replace_values : {
username : "Some User",
staffid : "991234"
}
});
</script>
	<title> ПГМТ "Проф. Цветан Лазаров" гр. Пловдив </title>
	<meta http-equiv="content-type" content="text/html; charset=windows-1251" />
</head>

<body bgcolor="#aad9f7" link="#000000">
	<div width="800px" height="200px"     style="position: relative ; top:5px; left:300px; ">
		<img src="images/header.jpg">

	</div>

	<div width="800px" height="500px" style="position: relative ; top:60px ; left: 350px;">
		<img src="images/content_box2.jpg">
	</div>

	<div width="225px" height="209px" style="position: relative ; top:-755px; left:50px;">
		<img src="images/emblema2.jpg">
	</div>

	<div width="319px" height="308px" style="position: relative; top:-690px ; left:15px;">
		<img src="images/menu.jpg">
	</div>

	
	<div width="200px" height="30px" style="position:relative; top:-935px; left:40px;">
		<a style="text-decoration : none"; href="index.php"><font face="arial, helvetica, sans-sherif" size="4" color="#000000"> >> Начало </font></a>
 	</div>
	<div width="200px" height="30px" style="position:relative; top:-920px; left:40px;">
		<a style="text-decoration : none"; href="news.php"><font face="arial, helvetica, sans-sherif" size="4" color="#000000"> >> Новини </font></a>
 	</div>
	<div width="200px" height="30px" style="position:relative; top:-905px; left:40px;">
		<a style="text-decoration : none"; href="specialnosti.php"><font face="arial, helvetica, sans-sherif" size="4" color="#000000"> >> Специалности </font></a>
 	</div>
	<div width="200px" height="30px" style="position:relative; top:-885px; left:40px;">
		<a style="text-decoration : none"; href="istoriq.php"><font face="arial, helvetica, sans-sherif" size="4" color="#000000"> >> История </font></a>
 	</div>
	<div width="200px" height="30px" style="position:relative; top:-865px; left:40px;">
		<a style="text-decoration : none"; href="galeriq.php"><font face="arial, helvetica, sans-sherif" size="4" color="#000000"> >> Галерия </font></a>
 	</div>
	<div width="200px" height="30px" style="position:relative; top:-850px; left:40px;">
		<a style="text-decoration : none"; href="proekti.php"><font face="arial, helvetica, sans-sherif" size="4" color="#000000"> >> ПРОЕКТИ </font></a>
 	</div>
	
	<div width="200px" height="30px" style="position:relative; top:-610px; left:460px;">
		<a style="text-decoration : none"; href="index.php"><font face="arial, helvetica, sans-sherif" size="3" color="#000000"> Начало | </font></a>
		<a style="text-decoration : none"; href="news.php"><font face="arial, helvetica, sans-sherif" size="3" color="#000000"> Новини |</font></a>
		<a style="text-decoration : none"; href="specialnosti.php"><font face="arial, helvetica, sans-sherif" size="3" color="#000000"> Специалности |</font></a>
		<a style="text-decoration : none"; href="istoriq.php"><font face="arial, helvetica, sans-sherif" size="3" color="#000000"> История |</font></a>
		<a style="text-decoration : none"; href="galeriq.php"><font face="arial, helvetica, sans-sherif" size="3" color="#000000"> Галерия|</font></a>
		<a style="text-decoration : none"; href="proekti.php"><font face="arial, helvetica, sans-sherif" size="3" color="#000000"> Проекти |</font></a>
		<a style="text-decoration : none"; href="kontakti.php"><font face="arial, helvetica, sans-sherif" size="3" color="#000000"> Контакти </font></a>
 	</div>
	<div width="381px" height="208px" style="position: relative ; top:-1150px ; left:1000px ;">
		<a href="http://www.hrdc.bg/news.php" target="_blank"><img title="logo2" src="images/logo2.jpg" width="210" height="200" border="0"></a>
	</div>
	
	<div width="381px" height="208px" style="position: relative ; top:-1000px ; left:480px ;">
	<p align="center"><embed src="http://www.respectsoft.com/onlineclock/ballclock.swf" width="125" height="125" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" wmode="transparent"></embed><br></p>
                
	</div>
>

<div width="50px" height="30px" style="position:relative; top:-1525px; left:370px;">
    	<?php
//настройки за база данни
$dbhost = "localhost";
$dbuser = "nasko4_nasko4";
$dbpass = "atanas";
$dbname = "nasko4_db";
$conn = mysql_connect($dbhost, $dbuser, $dbpass)or die(mysql_error());
mysql_select_db($dbname, $conn)or die(mysql_error());

$select = mysql_query("SELECT * FROM nachalo ORDER BY id DESC")or die(mysql_error());
$num = mysql_num_rows($select);
for ($i=0;$i<$num;$i++) {
$name = mysql_result($select, $i, "name");
$txt = mysql_result($select, $i, "txt");
echo '<table width="300" height="10" border="0">';
echo '<tr><td> <b>'.$name.'</b></td>
<tr><td>'.$txt.'</td></tr>
<br />';
}

mysql_close();
?>
    	    

</div>
	
</body>
<html>
 

Back
Горе