View file include/posts.php

File size: 13.26Kb
<?
	$p = intval($_GET['t']);
	$s = intval($_GET['s']);
	$queryTheme = mysql_query("SELECT * FROM themes WHERE id=".$p);
	$info = mysql_fetch_assoc($queryTheme);
	if(mysql_num_rows($queryTheme) < 1)
	{
	 	if($version == "wml")
		{
			header('Content-type: text/vnd.wap.wml; charset=utf-8');
			header("Cache-Control: no-cache");
			echo(doctype("Ошибка").$tag.'Темы не существует!<br/>
-');
if($authorize)
{
echo('<a href="./?p=0&amp;v=wml&amp;sid='.$sid.'">Форумы</a>');
}
else
{
echo('<a href="./?p=0&amp;v=wml">Форумы</a>');
}
echo(''.$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'].'">'.$tag.'
<font color="#FFFFFF"><b>Ошибка</b></font>
'.$tagC.'
</td></tr>
<tr><td bgcolor="'.$style['text'].'">'.$tag.'
<div class="text">Темы не существует!'.$tagC.'
</td></tr>
<tr><td bgcolor="'.$style['bottom'].'">'.$tag.'');
if($authorize)
{
echo('<div class="bottom"><a href="./?p=0&amp;v=xhtml&amp;sid='.$sid.'">Форумы</a>');
}
else
{
echo('<div class="bottom"><a href="./?p=0&amp;v=xhtml">Форумы</a>');
}
echo(''.$tagC.'</td></tr></table>
</body></html>');
		}
	} elseif($info['del'] == 1 and $status != 'admin')
	{
		if($version == "wml")
		{
			header('Content-type: text/vnd.wap.wml; charset=utf-8');
			header("Cache-Control: no-cache");
			echo(doctype("Ошибка").$tag.'
Тема '.$info['tname'].' из '.mysql_num_rows($queryTheme).' сообщений была удалена модератором '.$info['mdel'].'!<br/>
-');
if($authorize)
{
echo('<a href="./?p=2&amp;v=wml&amp;sid='.$sid.'&amp;f='.$info['id_forum'].'">Назад</a><br />
<a href="./?v=wml&amp;sid='.$sid.'">Форумы</a>');
}
else
{
echo('<a href="./?p=2&amp;v=wml&amp;f='.$info['id_forum'].'">Назад</a><br />
<a href="./?p=0&amp;v=wml">Форумы</a>');
}
echo(''.$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>'.$info['tname'].'</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>'.$info['tname'].'</b></font>
</td></tr>
<tr><td bgcolor="'.$style['text'].'">'.$tag.'
Тема '.$info['tname'].' из '.mysql_num_rows($queryTheme).' сообщений была удалена модератором '.$info['mdel'].'!
'.$tagC.'
</td></tr>
<tr><td align="center" bgcolor="'.$style['bottom'].'">'.$tag.'');
if($authorize)
{
echo('<a href="./?p=2&amp;v=xhtml&amp;sid='.$sid.'&amp;f='.$info['id_forum'].'">Назад</a><br />
<a href="./?p=0&amp;v=xhtml&amp;sid='.$sid.'">Форумы</a>');
}
else
{
echo('<a href="./?p=2&amp;v=xhtml&amp;f='.$info['id_forum'].'">Назад</a><br />
<a href="./?p=0&amp;v=xhtml">Форумы</a>');
}
echo(''.$tagC.'</td></tr></table>
</body></html>');
		}
		} else

	{
		if(($status == "moderator" || $status == "admin" || is_author($p, $username))  and !empty($_GET['o']))
		{
			mysql_query("UPDATE `themes` SET `close`='off' WHERE `id`=".$p);
			header("Location: ".$forumdir."p=4&f=".$info['id_forum']."&t=".$p."&v=".$version."&sid=".$sid);
		}
		if($s == 0)
		{
		$s = "1";
		}
		$title=''.$s.'-'.$info['tname'].'';
		$back = mysql_fetch_assoc(mysql_query("SELECT *
		FROM `forums`
		WHERE `id`=".$info['id_forum']));
		//   Навигация
		$count = mysql_result(
		         mysql_query("SELECT COUNT(*)
		                      FROM posts
		                      WHERE id_theme=".$p), 0);
		if(empty($_GET['ss']))
		{
			$start = intval($_GET['s']);
		}
		else
		{
			$start = intval($_GET['ss']) - 1;
		}
		if(!empty($start))
		{
			$limit = "LIMIT ".$start.", ".abs($count - $start);
			$int = $start;
		}
		else
		{
			$int = 0;
		}

		if($version == "xhtml")
		{
			$validChar = '$';
		}
		else
		{
			$validChar = '$$';
		}
		$thisPageSize = 600;

		if($authorize)
		{
			$lastTimeQ = mysql_query("SELECT * FROM `counter`
			                          WHERE `username`='".$username."'
			                          AND `fid`=".$back['id']);
            $lastTimeR = mysql_fetch_assoc($lastTimeQ);
			$lastTime = $lastTimeR['time'];

			$lastMsgTime = mysql_result(
			               mysql_query("SELECT MAX(time)
										FROM posts
										WHERE id_theme = ". $p), 0);
			if($lastTime <=  $lastMsgTime)
			{
				RefreshLastTime($username, $info['id_forum'], $lastMsgTime);
		    }
		}
			if($version == "wml")
			{
				header('Content-type: text/vnd.wap.wml; charset=utf-8');
				header("Cache-Control: no-cache");
				echo(doctype($title).$tag);
				if($count > 5)
				{
				if($authorize)
{
				echo("<a accesskey=\"1\" href=\"./?p=4&amp;v=wml&amp;sid=".$sid."&amp;t=".$p."&amp;s=".($count - 5)."\">Вниз (1)</a><br />\r\n");
				}
				else
				{
				echo("<a accesskey=\"1\" href=\"./?p=4&amp;v=wml&amp;t=".$p."&amp;s=".($count - 5)."\">Вниз (1)</a><br />\r\n");
				}
				}
				if($count > ceil($count / ($pageSize / 1000)))
				{
					echo("<a href=\"./?p=17&amp;v=wml&amp;sid=".$sid."&amp;t=".$p."&amp;c=".$count."\">Перейти к[1-".$count."]</a><br />\r\n");
				}
				if($private = mysql_result(
				              mysql_query("SELECT COUNT(*)
				                           FROM `private`
				                           WHERE `name`='".$username."'
				                           AND `new`=1
				                           AND `mod`='i'"), 0))
			{
				echo('<a href="./?p=24&amp;v=wml&amp;sid='.$sid.'">Приват</a> - <a href="./?p=24&amp;v=wml&amp;sid='.$sid.'&amp;new=1">'.$private."</a><br />\r\n");
			}
			} 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.'</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>'.$title.'</b></font>
</td></tr>
<tr><td bgcolor="'.$style['bottom'].'">'.$tag);
					if($count > 5)
					{
					if($authorize)
{
						echo("<a href=\"./?p=4&amp;v=xhtml&amp;sid=".$sid."&amp;t=".$p."&amp;s=".($count - 5)."\">Вниз</a><br />\r\n");
					}
					else
					{
					echo("<a href=\"./?p=4&amp;v=xhtml&amp;t=".$p."&amp;s=".($count - 5)."\">Вниз</a><br />\r\n");
					}
					}
                    if($count > ceil(($count / ($pageSize / 1000))))
					{
					echo("<a href=\"./?p=17&amp;v=xhtml&amp;sid=".$sid."&amp;t=".$p."&amp;c=".$count."\">Перейти к[1-".$count."]</a><br/>\r\n");
					}
		if($private = mysql_result(
		              mysql_query("SELECT COUNT(*)
		                           FROM `private`
		                           WHERE `name`='".$username."'
		                           AND `new`=1
		                           AND `mod`='i'"), 0))
			{
				echo('<a href="./?p=24&amp;mode=inbox&amp;v=xhtml&amp;sid='.$sid.'">Приват</a> - <a href="./?p=24&amp;v=xhtml&amp;sid='.$sid.'&amp;mode=inbox&amp;new=1">'.$private."</a><br />\r\n");
			}
echo($tagC."</td></tr>
<tr><td bgcolor=\"".$style['text']."\">\r\n".$tag);
			if($status == "moderator"  || $status == "admin")
			{
				echo("<form action=\"./?p=25&amp;v=xhtml&amp;sid=".$sid."&amp;tid=".$p."&amp;mode=checkbox\" method=\"post\">\r\n");
			}
			}
			$aposts = mysql_query("SELECT *
			FROM `posts`
			WHERE id_theme=".$p."
			ORDER BY `id`
			".$limit);
			while($posts = mysql_fetch_assoc($aposts))
			{
				static $s;
				echo(date("d/m/ H:i", $posts['time'])."]");
				$authoriz = mysql_query("SELECT * FROM `users` WHERE `username`='".$username."' AND `password`='".$password."'");
					$Sauthoriz = mysql_fetch_array($authoriz);
					if($Sauthoriz['private'] == "off" or !$authorize)
					{
					echo("<b>".$posts['name']."</b>\r\n");
					}
					elseif($Sauthoriz['private'] == "private")
					{
					echo("<b><a href=\"./?p=24&amp;d=1&amp;uid=".UserName2id($posts['name'])."&amp;v=".$version."&amp;sid=".$sid."\">".$posts['name']."</a></b>\r\n");
					}
					elseif($Sauthoriz['private'] == "user")
					{
					echo("<b><a href=\"./?p=6&amp;v=xhtml&amp;id=".UserName2id($posts['name'])."&amp;sid=".$sid."&amp;th=".$color."\">".$posts['name']."</a></b>\r\n");
					}
					if($status == "moderator" or $status == "admin")
					{
						echo(' <a href="./?p=25&amp;id='.$posts['id'].'&amp;v='.$version.'&amp;sid='.$sid.'&amp;mode=mpost&amp;tid='.$posts['id_theme']."\">X</a><br />\r\n");
						echo('['.strtok($posts['useragent'], '/').' <a href="./?p=25&amp;v='.$version.'&amp;mode=whois&amp;sid='.$sid.'&amp;ip='.$posts['ip'].'">'.$posts['ip']."</a>]\r\n");
					}
					if($status == "moderator" || $status == "admin" && $version == "xhtml")
					{
						echo("<input type=\"checkbox\" name=\"id[]\" value=\"".$posts['id']."\" />\r\n");
					}
					echo('<br/>'.nl2br(str_replace('&#36;', $validChar, $posts['post']))."<br /><br /> \r\n");
					$int++;
					$s += strlen($posts['post'].$posts['name'].$posts['time'].$title);
					if($s + $thisPageSize + (250 * abs($int - $start)) > $pageSize)
					{
						if($int != $count)
						{
							$next = $int;
						}
						break;
					}

			}
			if($version == "wml")
			{
				if(!empty($next))
				{
				if($authorize)
{
					echo("<a accesskey=\"3\" href=\"./?p=4&amp;v=wml&amp;sid=".$sid."&amp;s=".$next."&amp;t=".$p."\">Дальше...(3)</a><br />\r\n");
				}
				else
				{
				echo("<a accesskey=\"3\" href=\"./?p=4&amp;v=wml&amp;s=".$next."&amp;t=".$p."\">Дальше...(3)</a><br/>\r\n");
				}
				}
				if($info['close'] == "on")
				{
					echo('<b>Тема закрыта</b><br/>');
					if(is_author($p, $username) or $status == "moderator" or $status == "admin")
						{
							echo('<a href="./?p=4&amp;v=wml&amp;sid='.$sid.'&amp;o=1&amp;t='.$p.'">[Открыть]</a><br/>');
						}
				}
				if($authorize && $info['close'] != "on" )
				{
					echo('<a href="./?p=7&amp;v=wml&amp;sid='.$sid.'&amp;f='.$p.'">Ответить</a><br/>');
				}
				if($info['del'] == 1)
					{
						echo('Тема была удалена модератором '.$info['mdel']."<br/>\r\n");
					}
					if($authorize)
{
			echo('<a href="./?p=2&amp;f='.$back['id'].'&amp;sid='.$sid.'&amp;v=wml">Назад в '.$back['name'].'</a>');
}
else
{
echo('<a href="./?p=2&amp;f='.$back['id'].'&amp;v=wml">Назад в '.$back['name'].'</a>');
}
echo(''.$tagC.'
</p></card></wml>');
			} elseif($version == "xhtml")
			{
				echo($tagC."</td></tr>
<tr><td bgcolor=\"".$style['bottom']."\">\r\n".$tag);
					if(!empty($next))
					{
					if($authorize)
					{
						echo("<a href=\"./?p=4&amp;v=xhtml&amp;sid=".$sid."&amp;s=".$next."&amp;t=".$p."\">Дальше...</a><br/>\r\n");
					}
					else
					{
					echo("<a href=\"./?p=4&amp;v=xhtml&amp;s=".$next."&amp;t=".$p."\">Дальше...</a><br/>\r\n");
					}
					}
					if($authorize)
					{
					if($info['close'] == "on")
					{
						echo('<b>Тема закрыта</b> ');
						if(is_author($p, $username) or $status == "moderator" or $status == "admin")
						{
							echo('<a href="./?p=4&amp;v=xhtml&amp;sid='.$sid.'&amp;o=1&amp;t='.$p.'">[Открыть]</a><br/>');
						}
						else
						{
						echo"<br/>";
						}
					}
					}
					else
					{
					if($info['close'] == "on")
					{
						echo('<b>Тема закрыта</b><br/>');
						if(is_author($p, $username) or $status == "moderator" or $status == "admin")
						{
							echo('<a href="./?p=4&amp;v=xhtml&amp;sid='.$sid.'&amp;o=1&amp;t='.$p.'">[Открыть]</a><br/>');
						}
					}
					}
					if($authorize && $info['close'] != "on" )
					{
						echo('<a href="./?p=7&amp;v=xhtml&amp;sid='.$sid.'&amp;f='.$p."\">Ответить</a><br/>\r\n");
					}
					if($info['del'] == 1)
					{
						echo('Тема была удалена модератором '.$info['mdel']."<br/>\r\n");
					}
					if($authorize)
{
				echo('<a href="./?p=2&amp;v=xhtml&amp;sid='.$sid.'&amp;f='.$back['id'].'">Назад в '.$back['name']."</a><br/>\r\n");
				}
				else
				{
				echo('<a href="./?p=2&amp;v=xhtml&amp;f='.$back['id'].'">Назад в '.$back['name']."</a><br/>\r\n");
				}
				if($status == "moderator" || $status == "admin")
				{
					echo("<input type=\"submit\" value=\"Удалить отмеченные\" />\r\n");
				}
echo($tagC."</td></tr></table>\r\n</body></html>");
			}
	}
?>