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

Размер файла: 7.45Kb
<?php
/**********************************
*	@year: 2015				      *
*	@author: Klubv	              *
*   @icq: 611940693			      *
*	@link: http://klubv.ru        *
**********************************/
 error_reporting(0);
session_name('PHP');
session_start();

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['login']){
 @mysql_query("update `".prefix."users` set `mesto`='Редактирует сообщение в беседке', `online`='".time()."' where `id` = '".$_USER['id']."';");

$id		=	intval($_GET['id']);

$text	=	mysql_escape_string(trim($_POST['text']));
 $nastr=intval($_POST['nastr']);
if($nastr == "1") $nast='';
if($nastr == "2") $nast='[<font color = "#0000FF">Весело</font>]';
if($nastr == "3") $nast='[<font color = "#0000FF">Грустно</font>]';
if($nastr == "4") $nast='[<font color = "#0000FF">Гopдo</font>]';
if($nastr == "5") $nast='[<font color = "#0000FF">Шeпoтoм</font>]';
if($nastr == "6") $nast='[<font color = "#0000FF">Гpoмкo</font>]';
if($nastr == "7") $nast='[<font color = "#0000FF">Увepeннo</font>]';

 $sql	=	mysql_query("SELECT * FROM `".prefix."chat` WHERE `id` = '$id'");
if (mysql_num_rows($sql) < '1') {
	header("Location: /besedka/");
}


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

	$textt	=	nl2br($row['text']);
	$user	=	$row['user'];
	       if($_USER['login']==$user || $_USER['admin'])  {
if (empty($text)) {



echo '
<div class="downsw"><b>Редактирование</b></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.text;
        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="text" rows="6" class="form" onselect="storeCaret(this);" onclick="storeCaret(this);" onkeyup="storeCaret(this);">$textt</textarea>
<br />
&nbsp;Настроение: <select name="nastr">
<option value="1">Без эмоций</option>
<option value="2">Beceлo</option>
<option value="3">Гpycтнo</option>
<option value="4">Гopдo</option>
<option value="5">Шeпoтoм</option>
<option value="6">Гpoмкo</option>
<option value="7">Увepeннo</option></select><br />

&nbsp;&nbsp;<input type="submit"  class="form" value="Добавить" />    <input type="reset" value="Oчиcтить"/>
</form>


HTML;

}
else
{
	echo ' <form action="edit.php?id='.$id.'" name="post" method="POST">
&nbsp;&nbsp;<textarea type="text" name="text" rows="6"/>'.$textt.'</textarea>
<br />
&nbsp;Настроение: <select name="nastr">
<option value="1">Без эмоций</option>
<option value="2">Beceлo</option>
<option value="3">Гpycтнo</option>
<option value="4">Гopдo</option>
<option value="5">Шeпoтoм</option>
<option value="6">Гpoмкo</option>
<option value="7">Увepeннo</option></select><br />

&nbsp;&nbsp;<input type="submit"  class="form" value="Добавить" />    <input type="reset" value="Oчиcтить"/>
</form>';
}

                      echo'<div class="menuindex"><a href="/smiles.php'.$_zapros.'">Смайлы</a> | <a href="/bbkod.php'.$_zapros.'">BB-коды</a></div>';

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


break;

} else {     


	$sql	=	mysql_query("UPDATE `".prefix."chat` SET `text` = '$text', `nastr` = '$nast' WHERE `id` = '$id'");

	if ($sql) {


header("Location: /besedka/");
exit;
	} else {
echo '	<div class="menuindex">
Произошла ошибка!
</div>';
       include "../header/end.inc.php";

break;
	}

}  }
else{echo'<div class="menuindex">Свои сообщения редактируй а не чужие!</div>';}

} else {
	echo '<div class="menuindex">Что бы редактировать сообщения войдите в систему!</div>';
    include "../header/end.inc.php";

break;

}

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

?>