View file include/mans.php

File size: 15.56Kb
<?
if( in_array($status, array('admin', 'moderator')) )
			{
$f = intval($_GET['f']);
if($status == "admin") $ip = "127.0.0.1"; else $ip = empty($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['REMOTE_ADDR'] : $_SERVER['HTTP_X_FORWARDED_FOR'] ;
$ip = htmlspecialchars(sql($ip));
if($status == "admin") $user = "Admin"; else $user = htmlspecialchars(sql($_SERVER['HTTP_USER_AGENT']));
$query = mysql_query("SELECT mthemes.*, mforums.name AS fname
					  FROM mthemes, mforums
					  WHERE mthemes.id=".$f."
					  AND mthemes.id_forum=mforums.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=1&amp;v=wml&amp;sid='.$sid.'">Форумы</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=1&amp;v=xhtml&amp;sid='.$sid.'">Форумы</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=1&amp;v=wml&amp;sid='.$sid.'">Форумы</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=1&amp;v=xhtml&amp;sid='.$sid.'">Форумы</a>
'.$tagC.'</td></tr></table>
</body></html>');
		}
	}
	elseif(!$authorize)
	{
		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=1&amp;v=wml&amp;sid='.$sid.'">Форумы</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=1&amp;v=xhtml&amp;sid='.$sid.'">Форумы</a>
'.$tagC.'</td></tr>
</table>
</body></html>');
		}
	}
	elseif(ban($username, $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=1&amp;v=wml&amp;sid='.$sid.'">Форумы</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=1&amp;v=xhtml&amp;sid='.$sid.'">Форумы</a>
'.$tagC.'</td></tr></table>
</body></html>');
				}
		}
	else
	{
			if(empty($_POST['ansm']))
			{
				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 />
Логин ['.$username.']
 <br />
Тема ['.$data['tname'].'] <br />
Сообщение: <br />'.$tagC.'
<input type="text" name="mess'.$ref.'" maxlength="500" /><br />');
	if(is_author($f, $username) or $status == "admin")
	{
		echo($tag.'Закрыть тему:'.$tagC.'<br />
<select name="closed'.$ref.'" value="0">
<option value="0">Нет</option>
<option value="1">Да</option>
</select><br />');
	}
echo('<anchor>[Ответить]
<go href="./?p=8&amp;v=wml&amp;sid='.$sid.'&amp;f='.$f.'" method="post">
<postfield name="mess" value="$(mess'.$ref.')" />');
	if(is_author($f, $username) or $status == "admin")
	{
		echo('<postfield name="closed" value="$(closed'.$ref.')"/>');
	}
echo('<postfield name="ans" value="true"/>
</go></anchor><br />'.$tag.'

<a href="./?p=29&amp;v=wml&amp;sid='.$sid.'">Смайлы</a><br/>
<a href="./?p=5&amp;v=wml&amp;sid='.$sid.'&amp;t='.$f.'">Назад втему</a><br/>
<a href="./?p=3&amp;v=wml&amp;sid='.$sid.'&amp;f='.$data['id_forum'].'">Назад в "'.$data['fname'].'"</a><br/>
<a href="./?p=1&amp;v=wml&amp;sid='.$sid.'">Форумы</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=8&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="'.$style['bottomcolor'].'"><td colspan="2"></td></tr>
<tr bgcolor="'.$style['text'].'"><td>'.$tag.'Имя:'.$tagC.'</td><td>'.$tag.'['.$username.']'.$tagC.'</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>');
	if(is_author($f, $username) or $status == "admin")
	{
		echo('<tr bgcolor="'.$style['text'].'"><td nowrap>'.$tag.'Закрыть тему:'.$tagC.'</td>
<td><select name="closed">
<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="ansm" value="true">
<input type="submit" value="Ответить" /></td></tr>
<tr bgcolor="'.$style['bottom'].'"><td colspan="2">'.$tag.'
<a href="./?p=29&amp;v=xhtml&amp;sid='.$sid.'">Смайлы</a><br/>
<a href="./?p=5&amp;v=xhtml&amp;sid='.$sid.'&amp;t='.$f.'">Назад в тему</a><br/>
<a href="./?p=3&amp;v=xhtml&amp;sid='.$sid.'&amp;f='.$data['id_forum'].'">Назад в "'.$data['fname'].'"</a><br/>
<a href="./?p=1&amp;v=xhtml&amp;sid='.$sid.'">Форумы</a>
'.$tagC.'</td></tr></table>
</form>
</body></html>');
				}
			} else
			{
				$message = $_POST['mess'];
				if($transl == "on")
  			{
  				$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($status == "admin" or $starus == "moderator")
				{
					$message= preg_replace("|\[b\](.*)\[/b\]|i", "<b>\\1</b>", $message);
					$message = preg_replace("|\[i\](.*)\[/i\]|i", "<i>\\1</i>", $message);
				}

				if(strpos($message, "http://") !== false)
				{
					$message = preg_replace("|(http://[^\s]+)|i", "<a href=\"go/?\\1\">\\1</a>", $message);
				}
				else
				{
					$message = preg_replace("|\[urltag=(.*)\](.*)\[/url\]|is", "<a href=\"go/?http://\\1\">\\2</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 />
Имя: ['.$username.'] <br />
Тема: ['.$data['tname'].'] <br />
Сообщение: '.$tagC.'<br />
<input type="text" name="mess'.$ref.'" maxlength="600" /><br />');
	if(is_author($f, $username) or $status == "admin")
	{
		echo($tag.'Закрыть тему:'.$tagC.'<br />
<select name="closed'.$ref.'" value="0">
<option value="0">Нет</option>
<option value="1">Да</option>
</select><br />');
	}
echo('
<anchor>[Ответить]
<go href="./?p=8&amp;v=wml&amp;sid='.$sid.'&amp;f='.$f.'" method="post">
<postfield name="mess" value="$(mess'.$ref.')" />');
	if(is_author($f, $username) or $status == "admin")
	{
		echo('<postfield name="closed" value="$(closed'.$ref.')" />');
	}
echo('
<postfield name="ansm" value="true" />
</go></anchor><br />
'.$tag.'
<a href="./?p=29&amp;v=wml&amp;sid='.$sid.'">Смайлы</a><br/>
<a href="./?p=5&amp;v=wml&amp;sid='.$sid.'&amp;t='.$f.'">Назад в тему</a><br/>
<a href="./?p=3&amp;v=wml&amp;sid='.$sid.'&amp;f='.$data['id_forum'].'">Назад в "'.$data['fname'].'"</a><br/>
<a href="./?p=1&amp;v=wml&amp;sid='.$sid.'">Форумы</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=8&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="'.$style['bottomcolor'].'"><td colspan="2">'.$tag.'<b>Ошибка!!! Поле "Сообщение" пустое или содержит плохие символы!</b>'.$tagC.'</td></tr>
<tr bgcolor="'.$style['text'].'"><td>'.$tag.'Имя:'.$tagC.'</td><td>'.$tag.'['.$username.']'.$tagC.'</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>');
	if(is_author($f, $username) or $status == "admin")
	{
		echo('<tr bgcolor="'.$style['text'].'"><td nowrap>Закрыть тему:</td>
<td><select name="closed">
<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="ansm" value="true">
	<input type="submit" value="Ответить" /></td></tr>
	<tr bgcolor="'.$style['bottom'].'"><td colspan="2">'.$tag.'
	<a href="./?p=29&amp;v=xhtml&amp;sid='.$sid.'">Смайлы</a><br/>
	<a href="./?p=5&amp;v=xhtml&amp;sid='.$sid.'&amp;t='.$f.'">Назад в тему</a><br/>
	<a href="./?p=3&amp;v=xhtml&amp;sid='.$sid.'&amp;f='.$data['id_forum'].'">Назад в "'.$data['fname'].'"</a><br/>
	<a href="./?p=1&amp;v=xhtml&amp;sid='.$sid.'">Форумы</a>
				'.$tagC.'</td></tr></table>
				</form>
				</body></html>');
						}
					} 
					elseif(strtolower($postR) == strtolower($message))
					{
					header("Location: ".$forumdir."p=3&f=".$data['id_forum']."&v=".$version."&sid=".$sid);
					}
					else
					{
						if(mysql_result(
				  		   mysql_query("SELECT COUNT(*)
				                        FROM `mposts`
				                        WHERE `name` = '$username'
				                        AND `id_theme` = ".$f."
				                        AND `crc32` = ".crc32($message)), 0))
				                {
				                	header("Location: ".$forumdir."p=3&f=".$data['id_forum']."&v=".$version."&sid=".$sid);
				                	exit();
				                }
							if(($status == "admin" or is_author($f, $username)) and $_POST['closed'] == "1")
							{
								mysql_query("UPDATE `mthemes`
								             SET `close`='on' WHERE `id`=".$f);
							}

						mysql_query("INSERT INTO `mposts` VALUES(0, '".$username."', '".$message."', ".crc32($message).", ".$f.", ".time().", '".$user."', '".$ip."')");
						header("Location: ".$forumdir."p=3&f=".$data['id_forum']."&v=".$version."&sid=".$sid);

					}
			}
	}
	}
?>