Просмотр файла include/anss.php

Размер файла: 19.92Kb
<?
if(!$authorize AND $AuthorAnonim)
{
$f = intval($_GET['f']);
$ip = empty($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['REMOTE_ADDR'] : $_SERVER['HTTP_X_FORWARDED_FOR'] ;
$ip = htmlspecialchars(sql($ip));
$user = htmlspecialchars(sql($_SERVER['HTTP_USER_AGENT']));
$query = mysql_query("SELECT themes.*, forums.name AS fname
					  FROM themes, forums
					  WHERE themes.id=".$f."
					  AND themes.id_forum=forums.id");
$data = mysql_fetch_assoc($query);
	if(mysql_num_rows($query) < 1)
	{
		if($version == "wml")
		{
			header('Content-type: text/vnd.wap.wml; charset=utf-8');
			header("Cache-Control: no-cache");
			echo(doctype("Ошибка").$tag.'
Темы не существует! <br />
-
<a href="./?p=0&amp;v=wml">Форумы</a> '.$tagC.'
</p></card></wml>');
		} elseif($version == "xhtml")
		{
			header("Content-type: text/html; charset=utf-8");
			header("Last-Modified:".gmdate("D, d M Y H:i:s")." GMT");
   header("Cache-Control: no-cache, must-relative");
			echo('<html>
<head>
<title>Ошибка</title>
</head>
<body bgcolor="'.$style['background'].'" link="'.$style['link'].'" vlink="'.$style['link'].'" text="#000000">
<table align="center" border="0" cellspacing="1" cellpadding="5" width="350">
<tr><td align="center" bgcolor="'.$style['title'].'">
<font color="#FFFFFF"><b>Ошибка</b></font>
</td></tr>
<tr><td bgcolor="'.$style['text'].'">'.$tag.'
Темы не существует!
'.$tagC.'</td></tr>
<tr><td bgcolor="'.$style['bottom'].'">'.$tag.'
<a href="./?p=0&amp;v=xhtml">Форумы</a>
'.$tagC.'</td></tr></table>
</body></html>');
		}
	} elseif($data['close'] == "on")
	{
		if($version == "wml")
		{
			header('Content-type: text/vnd.wap.wml; charset=utf-8');
			header("Cache-Control: no-cache");
			echo(doctype("Ошибка").$tag.'
Темы закрыта! <br />

<anchor>Назад<prev /></anchor><br />
<a href="./?p=0&amp;v=wml">Форумы</a>
'.$tagC.'
</p></card></wml>');
		} elseif($version == "xhtml")
		{
			header("Content-type: text/html; charset=utf-8");
			header("Last-Modified:".gmdate("D, d M Y H:i:s")." GMT");
   header("Cache-Control: no-cache, must-relative");
			echo('<html>
<head>
<title>Ошибка</title>
</head>
<body bgcolor="'.$style['background'].'" link="'.$style['link'].'" vlink="'.$style['link'].'" text="#000000">
<table align="center" border="0" cellspacing="1" cellpadding="5" width="350">
<tr><td align="center" bgcolor="'.$style['title'].'">
<font color="#FFFFFF"><b>Ошибка</b></font>
</td></tr>
<tr><td bgcolor="'.$style['text'].'">'.$tag.'
Тема закрыта!
'.$tagC.'</td></tr>
<tr><td bgcolor="'.$style['bottom'].'">'.$tag.'
<a href="./?p=0&amp;v=xhtml">Форумы</a>
'.$tagC.'</td></tr></table>
</body></html>');
		}
	}
	elseif(ban($user, $ip))
	{
				if($version == "wml")
				{
				header('Content-type: text/vnd.wap.wml; charset=utf-8');
				header("Cache-Control: no-cache");
				echo(doctype("Ошибка").$tag.'
Ошибка! Вы заблокированы модератором '.$modername.'. <br />
Причина: '.$banmess.'! <br />
-
<a href="'.$_SERVER['HTTP_REFERER'].'">Назад</a><br />
<a href="./?p=0&amp;v=wml">Форумы</a>
'.$tagC.'</p></card></wml>');
			} elseif($version == "xhtml")
				{
					header("Content-type: text/html; charset=utf-8");
					header("Last-Modified:".gmdate("D, d M Y H:i:s")." GMT");
   header("Cache-Control: no-cache, must-relative");
					echo('<html>
<head>
<title>Ошибка</title>
</head>
<body bgcolor="'.$style['background'].'" link="'.$style['link'].'" vlink="'.$style['link'].'" text="#000000">
<table align="center" border="0" cellspacing="1" cellpadding="5" width="350">
<tr align="center" bgcolor="'.$style['title'].'"><td colspan="2">
<font color="#FFFFFF"><b>Ошибка</b></font>
<tr bgcolor="'.$style['text'].'"><td colspan="2">'.$tag.'Вы заблокированы модератором '.$modername.'</td></tr>
<tr bgcolor="'.$style['text'].'"><td>'.$tag.'Причина:'.$tagC.'</td><td>'.$tag.$banmess.$tagC.'</td></tr>
<tr bgcolor="'.$style['bottom'].'"><td colspan="2">'.$tag.'
<a href="./?p=0&amp;v=xhtml">Форумы</a>
'.$tagC.'</td></tr></table>
</body></html>');
				}
		}
	else
	{
		if(empty($_POST['ans']))
			{
				if($version == "wml")
				{
					header('Content-type: text/vnd.wap.wml; charset=utf-8');
					header("Cache-Control: no-cache");
					echo(doctype("Ответ на тему").$tag.'
<b>Ответить на тему в "'.$data['fname'].'" </b><br /> <br />
Имя: <input type="text" name="author" maxlength="10" />
 <br />
Тема: ['.$data['tname'].'] <br />
Сообщение: <br />'.$tagC.'
<input type="text" name="mess'.$ref.'" maxlength="500" /><br /><anchor>[Ответить]
<go href="./?p=30&amp;v=wml&amp;f='.$f.'" method="post">
<postfield name="mess" value="$(mess'.$ref.')" />');
echo('Транслит:<br />
<select name="transl">
<option value="0">Нет</option>
<option value="1">Да</option>
</select>');
echo('
<postfield name="mess" value="$(mess'.$ref.')" />
<postfield name="transl" value="$(transl'.$ref.')" />
<postfield name="ans" value="true" />
</go></anchor><br />'.$tag.'
<a href="./?p=14&amp;v=wml&amp;f=4">Смайлы</a><br />
<a href="./?p=4&amp;v=wml&amp;t='.$f.'">В тему</a><br />
<a href="./?p=2&amp;v=wml&amp;f='.$data['id_forum'].'">В  «'.$data['fname'].'»</a><br />
<a href="./?p=0&amp;v=wml">Форумы</a>
'.$tagC.'</p></card></wml>');
				} elseif($version == "xhtml")
				{
					header("Content-type: text/html; charset=utf-8");
					header("Last-Modified:".gmdate("D, d M Y H:i:s")." GMT");
   header("Cache-Control: no-cache, must-relative");
					echo('<html>
<head>
<title>Ответ на тему</title>
</head>
<body bgcolor="'.$style['background'].'" link="'.$style['link'].'" vlink="'.$style['link'].'" text="#000000">
<form action="./?p=30&amp;v=xhtml&amp;sid='.$sid.'&amp;f='.$f.'" method="post">
<table align="center" border="0" cellspacing="1" cellpadding="5" width="350">
<tr><td align="center" bgcolor="'.$style['title'].'" colspan="2">
<font color="#FFFFFF"><b>Ответ на тему</b></font>
</td></tr>
<tr bgcolor="'.$style['bottom'].'"><td colspan="2"><b>Ответить на тему в "'.$data['fname'].'"</b></td></tr>
<tr bgcolor="#deebf1"><td colspan="2"></td></tr>
<tr bgcolor="'.$style['text'].'"><td>'.$tag.'Имя:'.$tagC.'</td><td><input type="text" name="author" maxlength="10" /></td></tr>
<tr bgcolor="'.$style['text'].'"><td>'.$tag.'Тема:'.$tagC.'</td><td>'.$tag.'[Re: '.$data['tname'].']'.$tagC.'</td></tr>
<tr bgcolor="'.$style['text'].'"><td>'.$tag.'Сообщение:'.$tagC.'</td><td><textarea name="mess" cols="30" rows="5"></textarea></td></tr>');
echo('<tr bgcolor="'.$style['text'].'"><td nowrap>'.$tag.'Транслит:'.$tagC.'</td>
<td><select name="transl">
<option value="0">Нет</option>
<option value="1">Да</option>
</select></td></tr>');
echo('
<tr bgcolor="'.$style['text'].'"><td align="center" colspan="2">
<input type="hidden" name="ans" value="true">
<input type="submit" value="Ответить" /></td></tr>
<tr bgcolor="'.$style['bottom'].'"><td colspan="2">'.$tag.'
<a href="./?p=14&amp;v=xhtml&amp;f=4">Смайлы</a><br />
<a href="./?p=4&amp;v=xhtml&amp;t='.$f.'">В тему</a><br />
<a href="./?p=2&amp;v=xhtml&amp;f='.$data['id_forum'].'">В  «'.$data['fname'].'»</a><br />
<a href="./?p=0&amp;v=xhtml">Форумы</a>
'.$tagC.'</td></tr></table>
</form>
</body></html>');
				}
			} else
			{
				$message = $_POST['mess'];
				$transl=sql(htmlspecialchars(trim(chop($_POST['transl']))));
				$username=sql(htmlspecialchars(trim(chop($_POST['author']))));
				$username=translatenick($username);
				if($transl == "1")
  			{
  				$message = translate($message);
  			}
  			$message = preg_replace("|[\r\n]+|", " \r\n", $message);
 			$message = preg_replace("|[\n]+|", "\n", $message);
				$message = sql(htmlspecialchars(trim(chop(cutString($message, 1024)))));
				$message = preg_replace_callback("|&lt;(\d{1,20})&gt;|", "smile", $message);
				if(strpos($message, "http://") !== false)
				{
					$message = preg_replace("|(http://[^\s]+)|i", "<a href=\"go/?\\1\">\\1</a>", $message);
				}
				else if(strpos($message, "HTTP://") !== false)
				{
					$message = preg_replace("|(HTTP://[^\s]+)|i", "<a href=\"go/?\\1\">\\1</a>", $message);
				} 
				$R = mysql_query("SELECT * FROM `posts`
			                          WHERE `name`='".$username."'
			                          AND `id_theme`=".$f);
			    $aR = mysql_fetch_array($R);
			    $postR=$aR['post'];
					if(!preg_match("|^[-a-z0-9а-яё_!?№#;:%^&*()+=~\|\\\/ @.,\[\]\{\}\"'<>\s]*$|iu", $message) or empty($message))
					{
						if($version == "wml")
						{
							header('Content-type: text/vnd.wap.wml; charset=utf-8');
							header("Cache-Control: no-cache");
							echo(doctype("Ответ на тему").$tag.'
<b>Ответить в тему в "'.$data['fname'].'"</b><br /> <br />
<b>Поле "Сообщение" пустое или содержит плохие символы! </b><br />
Имя: <input type="text" name="author" maxlength="10" /> <br />
Тема: ['.$data['tname'].'] <br />
Сообщение: '.$tagC.'<br />
<input type="text" name="mess'.$ref.'" maxlength="600" /><br />');
echo($tag.'Транслит:'.$tagC.'<br />
<select name="transl'.$ref.'" value="0">
<option value="0">Нет</option>
<option value="1">Да</option>
</select><br />');
echo('
<anchor>[Ответить]
<go href="./?p=30&amp;v=wml&amp;f='.$f.'" method="post">
<postfield name="mess" value="$(mess'.$ref.')" />');
echo('<postfield name="transl" value="$(transl'.$ref.')" />');
echo('
<postfield name="ans" value="true" />
</go></anchor><br />
'.$tag.'
<a href="./?p=14&amp;v=wml&amp;f=4">Смайлы</a><br />
<a href="./?p=4&amp;v=wml&amp;t='.$f.'">В тему</a><br />
<a href="./?p=2&amp;v=wml&amp;f='.$data['id_forum'].'">В  «'.$data['fname'].'»</a><br />
<a href="./?p=0&amp;v=wml">Форумы</a>
'.$tagC.'</p></card></wml>');
						} elseif($version == "xhtml")
						{
							header("Content-type: text/html; charset=utf-8");
							header("Last-Modified:".gmdate("D, d M Y H:i:s")." GMT");
   header("Cache-Control: no-cache, must-relative");
							echo('<html>
<head>
<title>Ответ на тему</title>
</head>
<body bgcolor="'.$style['background'].'" link="'.$style['link'].'" vlink="'.$style['link'].'" text="#000000">
<form action="./?p=30&amp;v=xhtml&amp;f='.$f.'" method="post">
<table align="center" border="0" cellspacing="1" cellpadding="5" width="350">
<tr><td align="center" bgcolor="'.$style['title'].'" colspan="2">
<font color="#FFFFFF"><b>Ответ на тему</b></font>
</td></tr>
<tr bgcolor="'.$style['bottom'].'"><td colspan="2">
<b>Ответить на тему в "'.$data['fname'].'"</b>
</td></tr>
<tr bgcolor="#deebf1"><td colspan="2">'.$tag.'<b>Ошибка!!! Поле "Сообщение" пустое или содержит плохие символы!</b>'.$tagC.'</td></tr>
<tr bgcolor="'.$style['text'].'"><td>'.$tag.'Имя:'.$tagC.'</td><td><input type="text" name="author" maxlength="10" /></td></tr>
<tr bgcolor="'.$style['text'].'"><td>'.$tag.'Тема:'.$tagC.'</td><td>'.$tag.'[Re: '.$data['tname'].']'.$tagC.'</td></tr>
<tr bgcolor="'.$style['text'].'"><td>'.$tag.'Сообщение:'.$tagC.'</td><td><textarea name="mess" cols="30" rows="5"></textarea></td></tr>');
		echo('<tr bgcolor="'.$style['text'].'"><td nowrap>Транслит:</td>
<td><select name="transl">
<option value="0">Нет</option>
<option value="1">Да</option>
</select></td></tr>');
	echo('
	<tr bgcolor="'.$style['text'].'"><td align="center" colspan="2">
	<input type="hidden" name="ans" value="true">
	<input type="submit" value="Ответить" /></td></tr>
	<tr bgcolor="'.$style['bottom'].'"><td colspan="2">'.$tag.'
	<a href="./?p=14&amp;v=xhtml&amp;f=4">Смайлы</a><br />
	<a href="./?p=4&amp;v=xhtml&amp;t='.$f.'">В тему</a><br />
	<a href="./?p=2&amp;v=xhtml&amp;f='.$data['id_forum'].'">В  «'.$data['fname'].'»</a><br />
	<a href="./?p=0&amp;v=xhtml">Форумы</a>
				'.$tagC.'</td></tr></table>
				</form>
				</body></html>');
						}
					}
					elseif(mysql_result(mysql_query("SELECT COUNT(*) FROM `users` WHERE username='".$username."'"), 0) > 0)
					{
						if($version == "wml")
						{
							header('Content-type: text/vnd.wap.wml; charset=utf-8');
							header("Cache-Control: no-cache");
							echo(doctype("Ответ на тему").$tag.'
<b>Ответить в тему в "'.$data['fname'].'"</b><br /> <br />
<b>Ошибка!!! Для использования этого имени необходима авторизация! </b><br />
Имя: <input type="text" name="author" maxlength="10" /> <br />
Тема: ['.$data['tname'].'] <br />
Сообщение: '.$tagC.'<br />
<input type="text" name="mess'.$ref.'" maxlength="600" /><br />');
echo($tag.'Транслит:'.$tagC.'<br />
<select name="transl'.$ref.'" value="0">
<option value="0">Нет</option>
<option value="1">Да</option>
</select><br />');
echo('
<anchor>[Ответить]
<go href="./?p=30&amp;v=wml&amp;f='.$f.'" method="post">
<postfield name="mess" value="$(mess'.$ref.')" />');
echo('<postfield name="transl" value="$(transl'.$ref.')" />');
echo('
<postfield name="ans" value="true" />
</go></anchor><br />
'.$tag.'
<a href="./?p=14&amp;v=wml&amp;f=4">Смайлы</a><br />
<a href="./?p=4&amp;v=wml&amp;t='.$f.'">В тему</a><br />
<a href="./?p=2&amp;v=wml&amp;f='.$data['id_forum'].'">В  «'.$data['fname'].'»</a><br />
<a href="./?p=0&amp;v=wml">Форумы</a>
'.$tagC.'</p></card></wml>');
						} elseif($version == "xhtml")
						{
							header("Content-type: text/html; charset=utf-8");
							header("Last-Modified:".gmdate("D, d M Y H:i:s")." GMT");
   header("Cache-Control: no-cache, must-relative");
							echo('<html>
<head>
<title>Ответ на тему</title>
</head>
<body bgcolor="'.$style['background'].'" link="'.$style['link'].'" vlink="'.$style['link'].'" text="#000000">
<form action="./?p=30&amp;v=xhtml&amp;f='.$f.'" method="post">
<table align="center" border="0" cellspacing="1" cellpadding="5" width="350">
<tr><td align="center" bgcolor="'.$style['title'].'" colspan="2">
<font color="#FFFFFF"><b>Ответ на тему</b></font>
</td></tr>
<tr bgcolor="'.$style['bottom'].'"><td colspan="2">
<b>Ответить на тему в "'.$data['fname'].'"</b>
</td></tr>
<tr bgcolor="#deebf1"><td colspan="2">'.$tag.'<b>Ошибка!!! Для использования этого имени необходима авторизация</b>'.$tagC.'</td></tr>
<tr bgcolor="'.$style['text'].'"><td>'.$tag.'Имя:'.$tagC.'</td><td><input type="text" name="author" maxlength="10" /></td></tr>
<tr bgcolor="'.$style['text'].'"><td>'.$tag.'Тема:'.$tagC.'</td><td>'.$tag.'[Re: '.$data['tname'].']'.$tagC.'</td></tr>
<tr bgcolor="'.$style['text'].'"><td>'.$tag.'Сообщение:'.$tagC.'</td><td><textarea name="mess" cols="30" rows="5"></textarea></td></tr>');
		echo('<tr bgcolor="'.$style['text'].'"><td nowrap>Транслит:</td>
<td><select name="transl">
<option value="0">Нет</option>
<option value="1">Да</option>
</select></td></tr>');
	echo('
	<tr bgcolor="'.$style['text'].'"><td align="center" colspan="2">
	<input type="hidden" name="ans" value="true">
	<input type="submit" value="Ответить" /></td></tr>
	<tr bgcolor="'.$style['bottom'].'"><td colspan="2">'.$tag.'
	<a href="./?p=14&amp;v=xhtml&amp;f=4">Смайлы</a><br />
	<a href="./?p=4&amp;v=xhtml&amp;t='.$f.'">В тему</a><br />
	<a href="./?p=2&amp;v=xhtml&amp;f='.$data['id_forum'].'">В  «'.$data['fname'].'»</a><br />
	<a href="./?p=0&amp;v=xhtml">Форумы</a>
				'.$tagC.'</td></tr></table>
				</form>
				</body></html>');
						}
					}
					elseif(!preg_match("|^[<>@\[\] -\.\_0-9a-zA-Zа-яА-Я]+$|u", $username) or strlen($username) > 20)
					{
					if($version == "wml")
						{
							header('Content-type: text/vnd.wap.wml; charset=utf-8');
							header("Cache-Control: no-cache");
							echo(doctype("Ответ на тему").$tag.'
<b>Ответить в тему в "'.$data['fname'].'"</b><br /> <br />
<b>Поле "Имя" пустое или содержит плохие символы! </b><br />
Имя: <input type="text" name="author" maxlength="10" /> <br />
Тема: ['.$data['tname'].'] <br />
Сообщение: '.$tagC.'<br />
<input type="text" name="mess'.$ref.'" maxlength="600" /><br />');
echo($tag.'Транслит:'.$tagC.'<br />
<select name="transl'.$ref.'" value="0">
<option value="0">Нет</option>
<option value="1">Да</option>
</select><br />');
echo('
<anchor>[Ответить]
<go href="./?p=30&amp;v=wml&amp;f='.$f.'" method="post">
<postfield name="mess" value="$(mess'.$ref.')" />');
echo('<postfield name="transl" value="$(transl'.$ref.')" />');
echo('
<postfield name="ans" value="true" />
</go></anchor><br />
'.$tag.'
<a href="./?p=14&amp;v=wml&amp;f=4">Смайлы</a><br />
<a href="./?p=4&amp;v=wml&amp;t='.$f.'">В тему</a><br />
<a href="./?p=2&amp;v=wml&amp;f='.$data['id_forum'].'">В  «'.$data['fname'].'»</a><br />
<a href="./?p=0&amp;v=wml">Форумы</a>
'.$tagC.'</p></card></wml>');
						} elseif($version == "xhtml")
						{
							header("Content-type: text/html; charset=utf-8");
							header("Last-Modified:".gmdate("D, d M Y H:i:s")." GMT");
   header("Cache-Control: no-cache, must-relative");
							echo('<html>
<head>
<title>Ответ на тему</title>
</head>
<body bgcolor="'.$style['background'].'" link="'.$style['link'].'" vlink="'.$style['link'].'" text="#000000">
<form action="./?p=30&amp;v=xhtml&amp;f='.$f.'" method="post">
<table align="center" border="0" cellspacing="1" cellpadding="5" width="350">
<tr><td align="center" bgcolor="'.$style['title'].'" colspan="2">
<font color="#FFFFFF"><b>Ответ на тему</b></font>
</td></tr>
<tr bgcolor="'.$style['bottom'].'"><td colspan="2">
<b>Ответить на тему в "'.$data['fname'].'"</b>
</td></tr>
<tr bgcolor="#deebf1"><td colspan="2">'.$tag.'<b>Ошибка!!! Поле "Имя" пустое или содержит плохие символы!</b>'.$tagC.'</td></tr>
<tr bgcolor="'.$style['text'].'"><td>'.$tag.'Имя:'.$tagC.'</td><td><input type="text" name="author" maxlength="10" /></td></tr>
<tr bgcolor="'.$style['text'].'"><td>'.$tag.'Тема:'.$tagC.'</td><td>'.$tag.'[Re: '.$data['tname'].']'.$tagC.'</td></tr>
<tr bgcolor="'.$style['text'].'"><td>'.$tag.'Сообщение:'.$tagC.'</td><td><textarea name="mess" cols="30" rows="5"></textarea></td></tr>');
		echo('<tr bgcolor="'.$style['text'].'"><td nowrap>Транслит:</td>
<td><select name="transl">
<option value="0">Нет</option>
<option value="1">Да</option>
</select></td></tr>');
	echo('
	<tr bgcolor="'.$style['text'].'"><td align="center" colspan="2">
	<input type="hidden" name="ans" value="true">
	<input type="submit" value="Ответить" /></td></tr>
	<tr bgcolor="'.$style['bottom'].'"><td colspan="2">'.$tag.'
	<a href="./?p=14&amp;v=xhtml&amp;f=4">Смайлы</a><br />
	<a href="./?p=4&amp;v=xhtml&amp;t='.$f.'">В тему</a><br />
	<a href="./?p=2&amp;v=xhtml&amp;f='.$data['id_forum'].'">В  «'.$data['fname'].'»</a><br />
	<a href="./?p=0&amp;v=xhtml">Форумы</a>
				'.$tagC.'</td></tr></table>
				</form>
				</body></html>');
						}
					}
					elseif(strtolower($postR) == strtolower($message))
					{
					header("Location: ".$forumdir."p=2&f=".$data['id_forum']."&v=".$version);
					}
					else
					{
						if(mysql_result(
				  		   mysql_query("SELECT COUNT(*)
				                        FROM `posts`
				                        WHERE `name` = '$username'
				                        AND `id_theme` = ".$f."
				                        AND `crc32` = ".crc32($message)), 0))
				                {
				                	header("Location: ".$forumdir."p=2&f=".$data['id_forum']."&v=".$version);
				                	exit();
				                }
						mysql_query("UPDATE `themes`
								             SET `time`=".time()." WHERE `id`=".$f);
						mysql_query("INSERT INTO `posts` VALUES(0, '".$username."', '".$message."', ".crc32($message).", ".$f.", ".time().", '".$user."', '".$ip."')");
						header("Location: ".$forumdir."p=2&f=".$data['id_forum']."&v=".$version);
		}
	}
}
}
?>