View file include/mposts.php

File size: 10.76Kb
<?
if( in_array($status, array('admin', 'moderator')) )
			{
	$p = intval($_GET['t']);
	$s = intval($_GET['s']);
	$queryTheme = mysql_query("SELECT * FROM mthemes 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 />
-
<a href="./?p=1&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'].'">'.$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.'
<div class="bottom"><a href="./?p=1&v=xhtml&amp;sid='.$sid.'">Форумы</a>
'.$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 />
-
<a href="./?p=3&amp;v=wml&amp;sid='.$sid.'&amp;f='.$info['id_forum'].'">Назад</a><br />
<a href="./?p=1&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>'.$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.'
<a href="./?p=3&amp;v=xhtml&amp;sid='.$sid.'&amp;f='.$info['id_forum'].'">Назад</a><br />
<a href="./?p=1&amp;v=xhtml">Форумы</a>
'.$tagC.'
</td></tr></table>
</body></html>');
		}
		} else

	{
		if(($status == "admin" || is_author($p, $username))  and !empty($_GET['o']))
		{
			mysql_query("UPDATE `mthemes` SET `close`='off' WHERE `id`=".$p);
		}
		if($s == 0)
		{
		$s = "1";
		}
		$title=''.$s.'-'.$info['tname'].'';
		$back = mysql_fetch_assoc(mysql_query("SELECT *
											   FROM `mforums`
											   WHERE `id`=".$info['id_forum']));

		$count = mysql_result(
		         mysql_query("SELECT COUNT(*)
		                      FROM mposts
		                      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 mposts
										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)
				{
				echo("<a accesskey=\"1\" href=\"./?p=5&amp;v=wml&amp;sid=".$sid."&amp;t=".$p."&amp;s=".($count - 5)."\">Вниз (1)</a><br />\r\n");
				}
				if($count > ceil($count / ($pageSize / 1000)))
				{
					echo("<a href=\"./?p=18&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>'.cutString($title, 25).'</b></font>
</td></tr>
<tr><td bgcolor="'.$style['bottom'].'">'.$tag);
					if($count > 5)
					{
						echo("<a href=\"./?p=5&amp;v=xhtml&amp;sid=".$sid."&amp;t=".$p."&amp;s=".($count - 5)."\">Вниз</a><br />\r\n");
					}
                    if($count > ceil(($count / ($pageSize / 1000))))
					{
					echo("<a href=\"./?p=18&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 == "admin")
			{
				echo("<form action=\"./?p=25&amp;v=xhtml&amp;sid=".$sid."&amp;tid=".$p."&amp;mode=checkboxm\" method=\"post\">\r\n");
			}
			}
			$aposts = mysql_query("SELECT *
			FROM `mposts`
			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")
					{
					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;th=".$color."\">".$posts['name']."</a></b>\r\n");
					}
					if($status == "admin")
					{
						echo(' <a href="./?p=25&amp;id='.$posts['id'].'&amp;v='.$version.'&amp;sid='.$sid.'&amp;mode=mpostm&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 == "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']);
					if($s + $thisPageSize + (250 * abs($int - $start)) > $pageSize)
					{
						if($int != $count)
						{
							$next = $int;
						}
						break;
					}

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