Файл: mklik.tk/news/comm.add.php
Строк: 180
<?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';
@mysql_query("update `".prefix."users` set `mesto`='Добовляет комментарий к новостям', `online`='".time()."' where `id` = '".$_USER['id']."';");
$news_id = mysql_escape_string(trim(intval($_GET['news_id'])));
$date = date("d.m.Y, H:i");
$text = mysql_escape_string(trim($_POST['text']));
$login = mysql_escape_string(trim($_GET['user']));
if (empty($login)) {}
else{$loginvst = ''.$login.', ';}
$user = ''.$_USER['login'].'';
$sql = mysql_query("SELECT * FROM `news_news` WHERE `id` = '$news_id'");
if (mysql_num_rows($sql) < '1') {
header("Location: /news/");
}
if (empty($text)) {
echo ' <div class="downsw"><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="comm.add.php?news_id=$news_id" name="post" method="POST" onsubmit="return checkForm(this)">
<textarea name="text" rows="6" class="form" onselect="storeCaret(this);" onclick="storeCaret(this);" onkeyup="storeCaret(this);">$loginvst</textarea>
<br />
<input type="submit" class="form" value="Добавить" /> <input type="reset" value="Oчиcтить"/>
</form>
HTML;
}
else
{
echo ' <form action="comm.add.php?news_id='.$news_id.'" name="post" method="POST">
<textarea type="text" name="text" rows="6"/>'.$loginvst.'</textarea>
<br />
<input type="submit" class="form" value="Добавить" /> <input type="reset" value="Oчиcтить"/>
</form>';
}
} else {
if (empty($user)) { echo'<div class="menuindex">
Что бы оставлять комментарии войдите в систему!</div>';
include "../header/end.inc.php";
break;}
$strlen=strlen($text);
if ($strlen<3 || $strlen>1000){echo'<div class="menuindex">
Сообщение слишком длинное или короткое. Минимум 3 максимум 1000</div>';
include "../header/end.inc.php";
break;}
$povt = mysql_query("SELECT * FROM `news_comment` where `user` = '".$_USER['login']."' ORDER by `id` desc LIMIT 3");
while($pov=mysql_fetch_array($povt))
if($pov['text']==$text){
echo'<div class="menuindex">Недавно вы уже писали такой комментарий!</div>';
include "../header/end.inc.php";
break;
}
$sql_add = @mysql_query("INSERT INTO `news_comment` VALUES ('', '$news_id', '$user', '$date', '$text', '', '')");
$sql_update = @mysql_query("UPDATE `news_news` SET `comm` = `comm` + 1 WHERE `id` = '$news_id'");
if ($sql_add && $sql_update) {
//header("Location: http://".$u['url']);
header("Location: comment.php?news_id=".$news_id);
} 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";
?>