Размер файла: 13.68Kb
<?php
require "inc.php";
$pid=$HTTP_GET_VARS['pid'];
$page=$HTTP_GET_VARS['page'];
$pid=noSI($pid);
$page=noSI($page);
$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#0\">(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 ($page!=1)
{
$pp=$page-1;
echo "<a href=viewtop.php?pid=$pid&page=$pp><<<</a> ";
}else
{
echo "<FONT size=2 color=\"#888888\" face=\"Arial\"><<<</FONT> ";
}
echo "<b>$page ⁄ $b</b>";
if ($page!=$b)
{
$pp=$page+1;
echo " <a href=viewtop.php?pid=$pid&page=$pp>>>></a>";
}else
{
echo " <FONT size=2 color=\"#888888\" face=\"Arial\">>>></FONT>";
}
/*
echo"<SELECT NAME=\"navSelect\" ONCHANGE=\"top.location.href = this.options[this.selectedIndex].value\">\n";
for ($i=1;$i<=$b;$i++)
{
echo"<OPTION VALUE=\"viewtop.php?pid=$pid&page=$i\">$i</OPTION>\n";
}
echo"</SELECT>\n";
*/
}
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";
$sqlp="select * from poll where usid='$rus[usid]'";
$ap=mysql_query($sqlp);
$num_votes=mysql_num_rows($ap);
echo"<FONT size=2 color=\"#000000\" face=\"Arial\">\n";
echo"<DIV><small>votes:$num_votes</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";
if ($result[ispoll]==1)
{
$sqlp="select * from poll where pid='$pid' and usid='$myid'";
$ap=mysql_query($sqlp);
if (mysql_num_rows($ap)==0) $allow2vote=1; else $allow2vote=0;
if ($myid==0) $allow2vote=0;
echo"<br/>\n";
if ($allow2vote==1) echo"<form action=\"vote.php\" method=\"POST\">";
$sum=$result[poll_res1]+$result[poll_res2]+$result[poll_res3];
if ($sum==0) $summ=1; else $summ=$sum;
$r1=round($result[poll_res1]*100/$summ,2);
$rl1=ceil($r1);
$rr1=100-$rl1;
$r2=round($result[poll_res2]*100/$summ,2);
$rl2=ceil($r2);
$rr2=100-$rl2;
$r3=round($result[poll_res3]*100/$summ,2);
$rl3=ceil($r3);
$rr3=100-$rl3;
if ($allow2vote==1) echo"<input type=\"radio\" name=\"vote\" value=\"1\" checked> ";
echo"$result[poll_var1] - $r1%";
echo"<table cellpadding=0 height=\"12\" width=\"100\"><tr><td bgcolor=\"#8B93A0\" width=\"$rl1%\"></td><td bgcolor=\"#C4C9D9\" width=\"$rr1%\"></td></tr></table>\n";
if ($allow2vote==1) echo"<input type=\"radio\" name=\"vote\" value=\"2\"> ";
echo "$result[poll_var2] - $r2%";
echo"<table cellpadding=0 height=\"12\" width=\"100\"><tr><td bgcolor=\"#8B93A0\" width=\"$rl2%\"></td><td bgcolor=\"#C4C9D9\" width=\"$rr2%\"></td></tr></table>\n";
if ($allow2vote==1) echo"<input type=\"radio\" name=\"vote\" value=\"3\"> ";
echo "$result[poll_var3] - $r3%";
echo"<table cellpadding=0 height=\"12\" width=\"100\"><tr><td bgcolor=\"#8B93A0\" width=\"$rl3%\"></td><td bgcolor=\"#C4C9D9\" width=\"$rr3%\"></td></tr></table>\n";
echo"Votes: $sum<br/><br/>\n";
if ($allow2vote==1)
{
echo"<input type=\"hidden\" name=\"pid\" value=\"$pid\">\n";
echo"<input type=\"hidden\" name=\"page\" value=\"$page\">\n";
echo"<input type=\"submit\" value=\"Vote\">\n</form>";
}
}
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";
$sqlp="select * from poll where usid='$rus[usid]'";
$ap=mysql_query($sqlp);
$num_votes=mysql_num_rows($ap);
echo"<FONT size=2 color=\"#000000\" face=\"Arial\">\n";
echo"<DIV><small>votes:$num_votes</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#0\">(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 " ";
}
*/
if ($page!=1)
{
$pp=$page-1;
echo "<a href=viewtop.php?pid=$pid&page=$pp><<<</a> ";
}else
{
echo "<FONT size=2 color=\"#888888\" face=\"Arial\"><<<</FONT> ";
}
echo "<b>$page ⁄ $b</b>";
if ($page!=$b)
{
$pp=$page+1;
echo " <a href=viewtop.php?pid=$pid&page=$pp>>>></a>";
}else
{
echo " <FONT size=2 color=\"#888888\" face=\"Arial\">>>></FONT>";
}
}
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";
include "bottom.php";
echo"</body>\n";
echo"</html>\n";
?>