Просмотр файла akcii/edit.php

Размер файла: 5.93Kb
<?php

include '../header/config.inc.php';
include '../header/function.inc.php';
include '../header/header.inc.php';
include '../header/connect.inc.php';
include '../header/click-club.class.php';
If (!isset($_GET['log'])) define("anybody","true");
include '../header/enter.inc.php';
include '../ban.php';

If ($_USER['admin']){
@mysql_query("update `".prefix."users` set `mesto`='Редактирует акции', `online`='".time()."' where `id` = '".$_USER['id']."';");

$id		=	trim(intval($_GET['id']));
$news	=	mysql_escape_string(trim($_POST['news']));

if (empty($news)) {

	$sql	=	mysql_query("SELECT * FROM `akcii` WHERE `id` = '$id'");
	$row	=	mysql_fetch_assoc($sql);

if (mysql_num_rows($sql) < '1') {
	header("Location: /akcii/");
}

echo 	' <div class="downsw"><b>Редактирование акции</b></div>
<div class="menuindex">Дата: <b>'.$row[date].'</b><br />
ID: <b>'.$row[id].'</b> <br />
Комментарии: <a href="/akcii/comment.php?news_id='.$row[id].'">'.$row[comm].'</a>

</div>
';
  if($_USER['java']=='0'){

   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="menuindex">
<a href="javascript:ShowOrHide('1')">[BBcode]<img src="/images/niz.png" alt="red" title="Развернуть" border="0"/></a> <a href="javascript:ShowOrHide('2')">[Смайлы]<img src="/images/niz.png" alt="red" title="Развернуть" border="0"/></a></div>
<div id="1" style="display:none;"><div class="downsw">
<a href="javascript:bbcode('[red][/red]')"><img src="/includes/bb/re.png" alt="red" title="Красный" border="0"/></a>
<a href="javascript:bbcode('[green][/green]')"><img src="/includes/bb/gr.png" alt="green" title="Зеленый" border="0"/></a>
<a href="javascript:bbcode('[blue][/blue]')"><img src="/includes/bb/bl.png" alt="blue" title="Синий" border="0"/></a>
<a href="javascript:bbcode('[b][/b]')"><img src="/includes/bb/b.png" alt="b" title="Жирный" border="0"/></a>
<a href="javascript:bbcode('[i][/i]')"><img src="/includes/bb/i.png" alt="i" title="Наклонный" border="0"/></a>
<a href="javascript:bbcode('[u][/u]')"><img src="/includes/bb/u.png" alt="u" title="Подчеркнутый" border="0"/></a>
<a href="javascript:bbcode('[s][/s]')"><img src="/includes/bb/s.png" alt="s" title="Зачеркнутый" border="0"/></a>
<a href="javascript:bbcode('[url=][/url]')"><img src="/includes/bb/l.png" alt="url" title="Ссылка" border="0"/></a>
<a href="javascript:bbcode('[c][/c]')"><img src="/includes/bb/q.png" alt="quote" title="Цитата" border="0"/></a>
<a href="javascript:bbcode('[img alt=]http://[/img]')"><img src="/includes/bb/img.png" alt="img" title="Ссылка" border="0"/></a>
<a href="javascript:bbcode('[left][/left]')"><img src="/includes/bb/vl.png" alt="quote" title="Выравнивание влево" border="0"/></a>
<a href="javascript:bbcode('[center][/center]')"><img src="/includes/bb/vc.png" alt="quote" title="Выравнивание по центру" border="0"/></a>
<a href="javascript:bbcode('[right][/right]')"><img src="/includes/bb/vp.png" alt="quote" title="Выравнивание вправо" border="0"/></a>

 </div>

      </div>
      <div id="2" style="display:none;"><div class="downsw">
<a href="javascript:bbcode(':)')"><img src="/smile/1.gif" alt=":)" title=":)" border="0"/></a>
<a href="javascript:bbcode(':(')"><img src="/smile/2.gif" alt=":(" title=":(" border="0"/></a>
<a href="javascript:bbcode('lol')"><img src="/smile/6.gif" alt="lol" title="lol" border="0"/></a>
<a href="javascript:bbcode(':D')"><img src="/smile/7.gif" alt=":D" title=":D" border="0"/></a>
<a href="javascript:bbcode('zloy')"><img src="/smile/8.gif" alt="zloy" title="zloy" border="0"/></a>

<a href="javascript:bbcode('wall')"><img src="/smile/11.gif" alt="wall" title="wall" border="0"/></a>

<a href="javascript:bbcode('=O')"><img src="/smile/12.gif" alt="=O" title="=O" border="0"/></a>

<a href="javascript:bbcode('beer')"><img src="/smile/27.gif" alt="beer" title="beer" border="0"/></a>




 </div>

      </div>
<form action="edit.php?id=$id" name="post" method="POST" onsubmit="return checkForm(this)">
&nbsp;&nbsp;<textarea name="news" rows="6" class="form" onselect="storeCaret(this);" onclick="storeCaret(this);" onkeyup="storeCaret(this);">$row[news]</textarea>
<br />
&nbsp;&nbsp;<input type="submit"  class="form" value="Добавить" />
</form>


HTML;


 }
else
{
	echo ' <form action="edit.php?id='.$id.'" name="post" method="POST">
&nbsp;&nbsp;<textarea type="text" name="news" rows="6"/>'.$row[news].'</textarea>
<br />
&nbsp;&nbsp;<input type="submit"  class="form" value="Добавить" />    <input type="reset" value="Oчиcтить"/>
</form>';
}


} else {

	$sql	=	mysql_query("UPDATE `akcii` SET `news` = '$news' WHERE `id` = '$id'");

	if ($sql) {

header("Location: /akcii/");
exit;

					} else {

echo '	<div class="menuindex">
Произошла ошибка!
</div>';
       include "../header/end.inc.php";

break;

					}

}

} else {

	echo '<div class="menuindex">Как же достали эти хакеры!</div>';
    include "../header/end.inc.php";
    break;
}
                    echo'<div class="menuindex"><a href="/smiles.php'.$_zapros.'">Смайлы</a> | <a href="/bbkod.php'.$_zapros.'">BB-коды</a></div>';

    include "../header/end.inc.php";


?>