<? include('checkcookie.php'); ?>
<h3>Добавление новостей</h3>
<br><br>
<?
	function fuckquot($newstext)
	{
	$newstext=str_replace("'","&quot;",$newstext);
	$newstext=str_replace('"',"&quot;",$newstext);
	RETURN $newstext;
	}
	?>
<?
if(isset($_POST["newstext"]))
{
	$newstext=fuckquot($_POST["newstext"]);

	$tema=fuckquot($_POST["tema"]);
	$d=date('d.m.Y');

	mysql_query("insert into tb_news (data,tema,newstext) values ('$d','$tema','$newstext')");

	echo "Новость добавлена";
}
?>
         <script>   function appendtag(text1, text2)
            {
                if ((document.selection))
                {
                    document.surforder.newstext.focus();
                    document.surforder.document.selection.createRange().text = text1+document.surforder.document.selection.createRange().text+text2;
                } else if(document.surforder.newstext.selectionStart != undefined) {
                    var element    = document.surforder.newstext;
                    var str     = element.value;
                    var start    = element.selectionStart;
                    var length    = element.selectionEnd - element.selectionStart;
                    element.value = str.substr(0, start) + text1 + str.substr(start, length) + text2 + str.substr(start + length);
                } else document.surforder.newstext.value += text1+text2;
            }</script>
			<style>
			.knopka {
			background: #ccc;
			border: 1px solid black;
			padding: 5px;
			}
			.knopka:hover{
			background: #fff;
			border: 1px solid blue;
				padding: 5px;
			}
			</style>
<table class='adn'>
<tr class='lineb'>
<td align=center>Значение</td>
<td align="left"><table class="adn"><tr><td align="left" style="border: none; padding: 0">Описание</td><td align="right" style="border: none; padding: 0"><a href="#" onclick="document.getElementById('MainForm').submit(); return false" class="liv">Добавить</a></td></tr></table></td>
</tr><tr class='liney ell'><td align=left>
<form action="adminmain.php?p=newsadd" method="POST" id='MainForm' name='surforder'>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="tema"></td><td algin=left>Тема новости</td></tr>
<tr class='liney ell'>
<td align=left>
<textarea rows="9" cols="70" name="newstext">Текст новости</textarea>
<div style='float:left'>
<span class='knopka' onClick="javascript:appendtag('[url]','[/url]'); return false;">[URL]</span><br><br><br>
<span class='knopka' onClick="javascript:appendtag('[b]','[/b]'); return false;"><b>[B]</b></span><br><br><br>
<span class='knopka' onClick="javascript:appendtag('[u]','[/u]'); return false;"><u>[U]</u></span><br><br><br>
<span class='knopka' onClick="javascript:appendtag('[i]','[/i]'); return false;"><i>[I]</i></span><br>
</div>

</td><td align=left>Текст новости</td>
</tr>
</table>

<br>* - Разрешены бб коды:<br>
[url],[b],[u],[i],[s],[img],[color=],[size=],[h1],[h2]-[h6]

** В SeoEdit не используйте теги [h1]-[h6] - портится внешний вид...

</form>