Просмотр файла mforum/viewtop.php

Размер файла: 9.79Kb
<?php
	$pid=$HTTP_GET_VARS['pid'];
	require "inc.php";
	$myid=$_COOKIE["usid"];
	$mypass=$_COOKIE["pass"];
	$db=mysql_connect($dbhost, $dbuser, $dbpass);
	mysql_select_db($dbname,$db);
	if (!isset($myid)) $myid=0;
	$sqlc="select * from users where usid=$myid";
	$c=mysql_query($sqlc);
	$resc=mysql_fetch_array($c);
	if ($resc[pass]!=$mypass)
	{
		setcookie("usid", 0);
		setcookie("pass", 0); 
	}
		$sqlv="select * from forum where pid='$pid'";
		$av=mysql_query($sqlv);
		$resv=mysql_fetch_array($av);
		$vvv=$resv[views]+1;
		$sqlv="Update forum set views='$vvv' where pid='$pid'";
		$av=mysql_query($sqlv);
		if (!isset($page))
		{
			$page=1;
		}
		$sql="select * from forum where pid='$pid'";
		$a=mysql_query($sql);
		$b=mysql_num_rows($a);
		if($b==0)
		{
			$ok=false;
		} else
		{
			$result=mysql_fetch_array($a);
			$msg=$result[post];
			$topicname=$result[topic];
		}
		echo"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n";
		echo"<html>\n";
		echo"<head>\n";
		echo"<title></title>\n";
		echo"<meta name=\"description\" content=\"\">\n";
		echo"<meta name=\"keywords\" content=\"\">\n";
		echo"</head>\n";
		echo"<body bgcolor=\"#FFFFFF\" text=\"#000000\" link=\"#006699\" vlink=\"#006699\" alink=\"#006699\">\n";
		echo"\n";
		echo"<STYLE type=\"text/css\">\n";
		echo"A {text-decoration: none;}\n";
		echo"body\n";
		echo"{\n";
		echo"margin-left: 1%;\n";
		echo"margin-right: 1%;\n";
		echo"font-family: Arial, Helvetica, sans-serif;\n";
		echo"font-size: 10pt;\n";
		echo"background-color: #F0F0F0;\n";
		echo"}\n";
		echo"</STYLE>\n";
		include "top.php";
		echo"<FONT size=2 color=\"#000000\" face=\"Arial\">\n";
		echo"<DIV>\n";
		echo"<TABLE width=100% bgcolor=\"#F0F0F0\" border=0 cellpadding=5 bordercolor=\"#000000\" cellspacing=1>\n";
		echo"	<TR valign=top>\n";
		echo"		<TD>\n";
		echo"			<FONT size=2 color=\"#000000\" face=\"Arial\">\n";
		echo"				<DIV><a href=\"..\">[Main page]</a> <a href=\"index.php\">[Forum]</a> <b>[$topicname</b>";
		if ($resc[usid]>0) echo "<a href=\"reply.php?pid=$pid&page=$page\">(Reply)</a>";
		echo "<b>]</b></DIV>\n";
		echo"			</FONT>\n";
		echo"		</TD>\n";
		echo"		<TD>\n";
		echo"			<FONT size=2 color=\"#000000\" face=\"Arial\">\n";
		echo"				<DIV align=\"right\">\n";
		
		$from=15*($page-1);
		$sql2="select * from replies where pid=$pid";
		$res2=mysql_query($sql2);
		$a=mysql_num_rows($res2);
		$b=ceil($a/15);
		$sql="select * from replies where pid=$pid order by 'pid' desc limit $from,15";
		$a=mysql_query($sql);
		if ($b!=1)
		{
			for ($i=1; $i<=$b; $i++) 
			{
				if ($i!=$page) 
				{
					echo "<a href=viewtop.php?pid=$pid&page=$i>";
				} else echo "<b>[";
				echo "$i";
				if ($i!=$page)
				{
					echo "</a>";
				} else echo "]</b>";
				echo " ";
			}
		}
		if ($resc[usid]>0)
		{
			echo " <a href=\"logout.php\">Logout($resc[name])</a>\n";
			echo " <a href=\"profile.php\">Profile</a>\n";
		}else
		{
			echo " <a href=\"login.php\">Login</a>\n";
			echo " <a href=\"reg.php\">Register</a>\n";
		}
		echo"				</DIV>\n";
		echo"			</FONT>\n";
		echo"		</TD>\n";
		echo"	</TR>\n";
		echo"	</TABLE>\n";
	
		echo"<FONT size=2 color=\"#000000\" face=\"Arial\">\n";
		echo"<DIV><TABLE width=100% border=1 cellpadding=1 bordercolor=\"#222288\" cellspacing=0>\n";
		echo"<TR valign=top>\n";
		echo"<TD>\n";
		echo"\n";
		echo"<FONT size=2 color=\"#000000\" face=\"Arial\">\n";
		echo"<DIV><TABLE width=100% bgcolor=\"#FFFFFF\" border=0 cellpadding=5 cellspacing=1>\n";
		echo"<TR valign=top>\n";
		echo"<TD align=\"center\" bgcolor=\"#8B93A0\" width=\"15%\"><FONT size=2 color=\"#000000\" face=\"Arial\">\n";
		echo"<DIV><b>Author</b></DIV>\n";
		echo"</FONT>\n";
		echo"</TD>\n";
		echo"<TD align=\"center\" bgcolor=\"#8B93A0\"><FONT size=2 color=\"#000000\" face=\"Arial\">\n";
		echo"<DIV><b>Message</b></DIV>\n";
		echo"</FONT>\n";
		echo"</TD>\n";
		echo"</TR>\n";
	
		if (!isset($page))
		{
			$page=1;
		}
		
		$sql="select * from forum where pid='$pid'";
		$a=mysql_query($sql);
		$b=mysql_num_rows($a);
		if($b==0)
		{
			$ok=false;
		} elseif ($page==1)
		{
			$result=mysql_fetch_array($a);
			$sqlus="select * from users where usid='$result[usid]'";
			$us=mysql_query($sqlus);
			$rus=mysql_fetch_array($us);
			$msg=$result[post];
			$msg = ereg_replace(chr(13), '<br/>', $msg);
			echo"<TR valign=top>\n";
			echo"<TD align=\"center\" bgcolor=\"#D5DAEA\"><FONT size=2 color=\"#697180\" face=\"Arial\">\n";
			echo"<DIV><a href=\"mailto:$rus[email]\"><b>$rus[name]</b></a></DIV></FONT>\n";
			echo"<DIV><img src=\"img/$rus[avatar]\"></DIV>\n";
			if 		($rus[posts]<10)
			 	echo"<DIV><img src=\"img/rt0.gif\"></DIV>\n";
			else if ($rus[posts]<20)
			 	echo"<DIV><img src=\"img/rt1.gif\"></DIV>\n";
			else if ($rus[posts]<40)
			 	echo"<DIV><img src=\"img/rt2.gif\"></DIV>\n";
			else if ($rus[posts]<80)
			 	echo"<DIV><img src=\"img/rt3.gif\"></DIV>\n";
			else if ($rus[posts]<100)
			 	echo"<DIV><img src=\"img/rt4.gif\"></DIV>\n";
			else echo"<DIV><img src=\"img/rt5.gif\"></DIV>\n";
			echo"<FONT size=2 color=\"#000000\" face=\"Arial\">\n";
			echo"<DIV><small>posts:$rus[posts]</small></DIV>\n";
			echo"</FONT>\n";
			echo"</TD>\n";
			echo"<TD bgcolor=\"#D5DAEA\">\n";
			echo"\n";
			echo"<FONT size=2 color=\"#000000\" face=\"Arial\">\n";
			echo"<DIV><TABLE width=100% bgcolor=\"#FFFFFF\" border=0 cellpadding=2 cellspacing=0>\n";
			echo"<TR valign=top>\n";
			echo"<TD bgcolor=\"#C4C9D9\"><FONT size=2 color=\"#000000\" face=\"Arial\">\n";
			echo"<DIV><small>Posted: $result[date] $result[time]</small></DIV>\n";
			echo"</FONT>\n";
			echo"</TD>\n";
			echo"</TR>\n";
			echo"<TR valign=top>\n";
			echo"<TD bgcolor=\"#D5DAEA\"><FONT size=2 color=\"#000000\" face=\"Arial\">\n";
			echo"<DIV>$msg</DIV>\n";
			echo"</FONT>\n";
			echo"</TD>\n";
			echo"</TR>\n";
			echo"</TABLE>\n";
			echo"</DIV>\n";
			echo"</FONT>\n";
			echo"</TD>\n";
			echo"</TR>\n";
		}
		
		$from=15*($page-1);
		$sql2="select * from replies where pid=$pid";
		$res2=mysql_query($sql2);
		$a=mysql_num_rows($res2);
		$b=ceil($a/15);
		$sql="select * from replies where pid=$pid order by 'rid' limit $from,15";
		$a=mysql_query($sql);
	
		while($result=mysql_fetch_array($a))
		{
			$nm=mysql_num_rows($a);
			$sqlus="select * from users where usid='$result[usid]'";
			$us=mysql_query($sqlus);
			$rus=mysql_fetch_array($us);
			$msg = $result[messg];
			$msg = ereg_replace(chr(13), '<br/>', $msg);
			echo"<TR valign=top>\n";
			echo"<TD align=\"center\" bgcolor=\"#D5DAEA\"><FONT size=2 color=\"#697180\" face=\"Arial\">\n";
			echo"<DIV><a href=\"mailto:$rus[email]\"><b>$rus[name]</b></a></DIV></FONT>\n";
			echo"<DIV><img src=\"img/$rus[avatar]\"></DIV>\n";
			if 		($rus[posts]<10)
			 	echo"<DIV><img src=\"img/rt0.gif\"></DIV>\n";
			else if ($rus[posts]<20)
			 	echo"<DIV><img src=\"img/rt1.gif\"></DIV>\n";
			else if ($rus[posts]<40)
			 	echo"<DIV><img src=\"img/rt2.gif\"></DIV>\n";
			else if ($rus[posts]<80)
			 	echo"<DIV><img src=\"img/rt3.gif\"></DIV>\n";
			else if ($rus[posts]<100)
			 	echo"<DIV><img src=\"img/rt4.gif\"></DIV>\n";
			else echo"<DIV><img src=\"img/rt5.gif\"></DIV>\n";
			echo"<FONT size=2 color=\"#000000\" face=\"Arial\">\n";
			echo"<DIV><small>posts:$rus[posts]</small></DIV>\n";
			echo"</FONT>\n";
			echo"</TD>\n";
			echo"<TD bgcolor=\"#D5DAEA\">\n";
			echo"\n";
			echo"<FONT size=2 color=\"#000000\" face=\"Arial\">\n";
			echo"<DIV><TABLE width=100% bgcolor=\"#FFFFFF\" border=0 cellpadding=2 cellspacing=0>\n";
			echo"<TR valign=top>\n";
			echo"<TD bgcolor=\"#C4C9D9\"><FONT size=2 color=\"#000000\" face=\"Arial\">\n";
			echo"<DIV><small>Posted: $result[date] $result[time]</small> ";
			if ($resc[usid])
			{
				$pg=$page;
				if ($nm==1) $pg=$pg-1;
				if ($pg==0) $pg=1;
				echo"<a href=\"delrep.php?pid=$pid&rid=$result[rid]&page=$pg\"><small>[delete]</small></a>";
			}
			echo"</DIV>\n";
			echo"</FONT>\n";
			echo"</TD>\n";
			echo"</TR>\n";
			echo"<TR valign=top>\n";
			echo"<TD bgcolor=\"#D5DAEA\"><FONT size=2 color=\"#000000\" face=\"Arial\">\n";
			echo"<DIV>$msg</DIV>\n";
			echo"</FONT>\n";
			echo"</TD>\n";
			echo"</TR>\n";
			echo"</TABLE>\n";
			echo"</DIV>\n";
			echo"</FONT>\n";
			echo"</TD>\n";
			echo"</TR>\n";
		}
		echo"</TABLE>\n";
		echo"</DIV>\n";
		echo"</FONT>\n";
		echo"\n";
		echo"</TD>\n";
		echo"</TR>\n";
		echo"</TABLE>\n";
		echo"</DIV>\n";
		echo"</FONT>\n";
		echo"<FONT size=2 color=\"#000000\" face=\"Arial\">\n";
		echo"<DIV>\n";
		echo"<TABLE width=100% bgcolor=\"#F0F0F0\" border=0 cellpadding=5 bordercolor=\"#000000\" cellspacing=1>\n";
		echo"	<TR valign=top>\n";
		echo"		<TD>\n";
		echo"			<FONT size=2 color=\"#000000\" face=\"Arial\">\n";
		echo"				<DIV><a href=\"..\">[Main page]</a> <a href=\"index.php\">[Forum]</a> <b>[$topicname</b>";
		if ($resc[usid]>0) echo "<a href=\"reply.php?pid=$pid&page=$page\">(Reply)</a>";
		echo "<b>]</b></DIV>\n";
		echo"			</FONT>\n";
		echo"		</TD>\n";
		echo"		<TD>\n";
		echo"			<FONT size=2 color=\"#000000\" face=\"Arial\">\n";
		echo"				<DIV align=\"right\">\n";
			
		$from=15*($page-1);
		$sql2="select * from replies where pid=$pid";
		$res2=mysql_query($sql2);
		$a=mysql_num_rows($res2);
		$b=ceil($a/15);
		$sql="select * from replies where pid=$pid order by 'rid' limit $from,15";
		$a=mysql_query($sql);
		if ($b!=1)
		{
			for ($i=1; $i<=$b; $i++) 
			{
				if ($i!=$page) 
				{
					echo "<a href=viewtop.php?pid=$pid&page=$i>";
				}else echo "<b>[";
				echo "$i";
				if ($i!=$page)
				{
					echo "</a>";
				}else echo "]</b>";
				echo " ";
			}
		}
		echo"				</DIV>\n";
		echo"			</FONT>\n";
		echo"		</TD>\n";
		echo"	</TR>\n";
		echo"	</TABLE>\n";
		include "bottom.php";
		echo"</body>\n";
		echo"</html>\n";
?>