Файл: besedka/ans.php
Строк: 164
<?php
session_name('im');
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';
// Проверка IP
$login = $_USER['login'];
$enterip = $_USER['enterip'];
$ip = $_SERVER['REMOTE_ADDR'];
if ($ip !== $enterip) {
echo '<div class="downsw"><font color="#FF3300"><b>Провал!</b></font><br/>
<font color="#00FF00">Войдите в систему!</font><br/></div>';
session_destroy();
include '../header/end.inc.php';
exit;
}
$mode=@mysql_query("SELECT * FROM `".prefix."moderka` WHERE `mod`='".$_USER['login']."'");
If(!$mode){echo 'err';}
if (mysql_num_rows($mode)!=0){
$moder = $_USER['login'];
}
If ($_USER['admin'] || $moder){
@mysql_query("update `".prefix."users` set `mesto`='Добовляет ответ на сообщение в беседке', `online`='".time()."' where `id` = '".$_USER['id']."';");
$id = intval($_GET['id']);
$ans = mysql_escape_string(trim($_POST['ans']));
$sql = mysql_query("SELECT * FROM `".prefix."chat` WHERE `id` = '$id'");
if (mysql_num_rows($sql) < '1') {
header("Location: /besedka/");
}
if (empty($ans)) {
$sql = mysql_query("SELECT * FROM `".prefix."chat` WHERE `id` = '$id'");
$row = mysql_fetch_assoc($sql);
$text = nl2br($row['text']);
$ansr = $row['ans'];
echo '
<div class="downsw"><b>Ответ</b></div>
<div class="menuindex">
<b> ID: </b> '.$row[id].'<br />
<b> Текст: </b> <br />
'.$text.'
</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.ans;
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="/images/bb/re.png" alt="red" title="Красный" border="0"/></a>
<a href="javascript:bbcode('[green][/green]')"><img src="/images/bb/gr.png" alt="green" title="Зеленый" border="0"/></a>
<a href="javascript:bbcode('[blue][/blue]')"><img src="/images/bb/bl.png" alt="blue" title="Синий" border="0"/></a>
<a href="javascript:bbcode('[b][/b]')"><img src="/images/bb/b.png" alt="b" title="Жирный" border="0"/></a>
<a href="javascript:bbcode('[i][/i]')"><img src="/images/bb/i.png" alt="i" title="Наклонный" border="0"/></a>
<a href="javascript:bbcode('[u][/u]')"><img src="/images/bb/u.png" alt="u" title="Подчеркнутый" border="0"/></a>
<a href="javascript:bbcode('[s][/s]')"><img src="/images/bb/s.png" alt="s" title="Зачеркнутый" border="0"/></a>
<a href="javascript:bbcode('[url=][/url]')"><img src="/images/bb/l.png" alt="url" title="Ссылка" border="0"/></a>
<a href="javascript:bbcode('[c][/c]')"><img src="/images/bb/q.png" alt="quote" title="Цитата" border="0"/></a>
<a href="javascript:bbcode('[img alt=]http://[/img]')"><img src="/images/bb/img.png" alt="img" title="Ссылка" border="0"/></a>
<a href="javascript:bbcode('[left][/left]')"><img src="/images/bb/vl.png" alt="quote" title="Выравнивание влево" border="0"/></a>
<a href="javascript:bbcode('[center][/center]')"><img src="/images/bb/vc.png" alt="quote" title="Выравнивание по центру" border="0"/></a>
<a href="javascript:bbcode('[right][/right]')"><img src="/images/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="ans.php?id=$id" name="post" method="POST" onsubmit="return checkForm(this)">
<textarea name="ans" rows="6" class="form" onselect="storeCaret(this);" onclick="storeCaret(this);" onkeyup="storeCaret(this);">$ansr</textarea>
<br />
<input type="submit" class="form" value="Добавить" /> <input type="reset" value="Oчиcтить"/>
</form>
HTML;
}
else{
echo ' <form action="ans.php?id='.$id.'" name="post" method="POST"> <textarea type="text" name="ans" rows="6"/>'.$ansr.'</textarea>
<br />
<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 {
$user = ''.$_USER['login'].'';
$sql = mysql_query("UPDATE `".prefix."chat` SET `ans` = '$ans', `ansuser` = '$user' 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>';
include "../header/end.inc.php";
break;
}
include "../header/end.inc.php";
?>