File size: 2.94Kb
<?php
include 'includes/config.php';
include 'includes/connect.php';
include 'includes/admin.valid.php';
include 'themes/head.php';
$news = mysql_escape_string(trim($_POST['news']));
if (!empty($_USER['login'])) {
if (empty($news)) {
echo <<<HTML
<script language="javascript" type="text/javascript">
function ShowOrHide(d1) {
if (d1 != '') DoDiv(d1);
}
function DoDiv(id) {
var item = null;
if (document.getElementById) {
item = document.getElementById(id);
} else if (document.all){
item = document.all[id];
} else if (document.layers){
item = document.layers[id];
}
if (!item) {
}
else if (item.style) {
if (item.style.display == "none"){ item.style.display = ""; }
else {item.style.display = "none"; }
}else{ item.visibility = "show"; }
}
function bbcode(text) {
var txtarea = document.post.news;
text = '' + text + '';
if (txtarea.createTextRange && txtarea.caretPos) {
var caretPos = txtarea.caretPos;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + text + ' ' : caretPos.text + text;
txtarea.focus();
} else {
txtarea.value += text;
txtarea.focus();
}
}
</script>
<div class="t">Добавить новость</div>
<div class="m">
<div class="menu2">
<form action="" name="post" method="POST" onsubmit="return checkForm(this)">
<textarea name="news" rows="6" class="form" onselect="storeCaret(this);" onclick="storeCaret(this);" onkeyup="storeCaret(this);"></textarea>
<br /><br />
<input type="submit" class="form" value="Добавить" />
</form>
<a href="javascript:ShowOrHide('1')">[BBcode]</a>
<div id="1" style="display:none;">
<a href="javascript:bbcode('[b][/b]')">[b]</a> <a href="javascript:bbcode('[i][/i]')">[i]</a> <a href="javascript:bbcode('[u][/u]')">[u]</a> <a href="javascript:bbcode('[s][/s]')">[s]</a> <a href="javascript:bbcode('[url=http://][/url]')">[url]</a> <a href="javascript:bbcode('[img alt=]http://[/img]')">[img]</a> <br />
<a href="javascript:bbcode('[left][/left]')">[left]</a> <a href="javascript:bbcode('[center][/center]')">[center]</a> <a href="javascript:bbcode('[right][/right]')">[right]</a>
</div>
</div></div>
HTML;
} else {
$date = date("d.m.Y");
$news = mysql_escape_string(trim($_POST['news']));
$sql = @mysql_query("INSERT INTO `".$db_pref."news` VALUES ('', '$date', '$news', '')");
if ($sql) {
echo <<<HTML
<div class="t">Добавить новость</div>
<div class="m">
<div class="menu2">
Новость успешно добавлена!
</div></div>
HTML;
} else {
echo <<<HTML
<div class="t">Добавить новость</div>
<div class="m">
<div class="menu2">
Произошла ошибка!
</div></div>
HTML;
}
}
} else {
echo <<<HTML
<div class="t">Ошибка</div>
<div class="m">
<div class="menu2">
Доступ запрещен!
</div></div>
HTML;
}
include 'themes/foot.php';
?>