<?
# Slashster: Open Source Friend of a Friend Software
# Copyright 2004 Mark El-Wakil
# Contact: hide@address.com
# http://seventhcycle.net
#
# This file is part of Slashster.
#
# Slashster is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# Slashster is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Slashster; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import_request_variables("gPc");
require_once("PageClass.php");
$mpage = new PageClass("authonly");
$mpage->MembersOnly();
$goto="";
if ($showcomment)
{
PageTrans($showcomment);
}
$mpage->exec_arr["authremainder"]["jsgoto"] = $goto;
$mpage->Initialize("authremainder");
?>
<table height=500px width=100%>
<tr>
<td width=560>
<div style="height:500px; width=100%; overflow:auto;">
<?
if ($postid)
{
$msgowner = PostPrint($postid, $page, $reply, $topicid);
}
else
{
TopicPrint($topicid, $page);
}
?>
</td>
<td width=200>
<div style="height:500px; width=100%; overflow:auto;">
<?
if ($postid)
{
PostSide($msgowner);
}
else
{
TopicSide();
}
?>
</div>
</td>
</tr>
</table>
<?
$mpage->ClosePage();
function PostPrint($postid, $page, $reply, $topicid)
{
global $mpage;
$utbl = $mpage->utbl;
$page = (is_numeric($page)) ? $page : "1";
$limit = "limit " . ($page - 1) * 10 . ", 10";
$sql = "select * from CommentHead where Id = \"$postid\" ";
$rp = $mpage->DoQuery($sql,1);
if (!sizeof($rp))
{
echo "No such valid post.";
$mpage->ClosePage();
}
$rp = $rp[0];
$level = $mpage->UserDistance($rp[FSubm]);
if (($level < 0) || ($level > 2))
{
echo "<P><B>Sorry</b></P>";
echo "You do not have permission to view this thread.";
echo "<P>You may only view threads from your friends, or their friends.";
$mpage->ClosePage();
}
global $topicidc;
$topicidc = $rp[Section];
$sql = "select SQL_CALC_FOUND_ROWS CommentTable.*, UserTable.Fname, UserTable.Lname,
UserTable.BBSSig,
UserTable.PicDefault, UserTable.Karma, UNIX_TIMESTAMP(UserTable.DateJoined) as UJoin,
UNIX_TIMESTAMP(CommentTable.DateSub) as UT,
UTCTO.Fname as LoginB, UNIX_TIMESTAMP(CT.DateSub) as CTUT, CT.Txt as CTxt
from CommentTable
left join CommentTable as CT on CT.Id = CommentTable.Parent
left join UserTable as UTCTO on UTCTO.Id = CT.Submittee
left join UserTable on CommentTable.Submittee = UserTable.Id
where CommentTable.Head = \"$postid\" order by Id asc $limit";
$r = $mpage->DoQuery($sql,1);
$sql = "select FOUND_ROWS()";
$tpsc = $mpage->DoQuery($sql);
$tpsc = $tpsc[0][0];
$tpsc = ($tpsc) ? $tpsc : 1;
$tpsc = ceil($tpsc / 10);
?>
<center>
<? if ($tpsc != 1) { ?>
<BR>
<table width=95% cellpadding=0 cellspacing=0>
<tr><td>
<? if ($page != 1) { ?>
<a href="bbs.php?postid=<?= $postid ?>&page=<?= ($page-1) ?>"><< Prev</a>
<? } ?>
<td><td align=right>
<? if ($page != $tpsc) { ?>
<a href="bbs.php?postid=<?= $postid ?>&page=<?= ($page+1) ?>"">Next >></a>
<? } ?>
</td></tr>
</table>
<? } ?>
<BR>
<table width=95% border=1 bordercolor=black cellspacing=0>
<tr>
<td colspan=2 class="stdtable">
<table class="stdtable" width=100% cellpadding=0 cellspacing=0>
<form method=get action="bbs.php">
<input name=postid value="<?= $postid ?>" type=hidden>
<tr><td class="stdtxt">
<B><?= $rp[Name] ?></b>
</td><td width=100 align=right>
<select name=page>
<? for ($x=1; $x<=$tpsc; $x++) { ?>
<option value="<?= $x ?>" <?= ($x == $page) ? "selected" : "" ?>>Page <?= $x ?></option>
<? } ?>
</select>
<input type=submit class=submit value="Go!">
</td></tr>
</form>
</table>
</td>
</tr>
<?
foreach ($r as $s)
{ ?>
<tr>
<td width=100 valign=top class="stdtable">
<a name="<?= $s[Id] ?>">
<a href="user.php?id=<?= $s[Submittee] ?>">
<img src = "userpics/<?= $mpage->PicPr($s[PicDefault], $s[Submittee]) ?>-b.jpg" width=80 height=60 border=0></a>
<?= $s[Fname] ?>
<BR>User #<?= $s[Submittee] ?>
<BR>Distance: <?= $dst = $mpage->UserDistance($s[Submittee]) ?>
<BR>Karma: <?= $mpage->CalcKarma($s[Karma], $s[UJoin]) ?>
<BR><BR><BR><BR>
</td>
<td valign=top width=800 class="stdfilling" style="padding-left: 5px;">
<? if ($s[Parent]) { ?>
On <?= date("F d, Y h:i:a", $s[CTUT]) ?>, <a href="~<?= $s[LoginB] ?>"><?= ucfirst($s[LoginB]) ?></a> said:
(<a href="bbs.php?showcomment=<?= $s[Parent] ?>">link</a>)
<BR><BR>
<center>
<div align=left style="overflow:auto;width=90%;height=125px;border=1;"
class=stdtable>
<?= $s[CTxt] ?>
</div>
</center>
<BR>
<a href="user.php?id=<?= $s[Submittee] ?>"><?= $s[Fname] ?></a>'s
Response:
<BR><BR>
<? } ?>
<?= $s[Txt] ?>
<BR>
</td>
</td></tr>
<? if ($s[BBSSig]) { ?>
<tr><td class="stdtable" align=right><B>Signature: </b>
</td><td style="padding-left: 5px;">
<i><?= htmlentities($s[BBSSig]) ?></i>
</td></tr>
<? } ?>
<tr>
<?
$tmel = 24 * 3600 * 5;
if ($dst2 = (
($dst) &&
(!$s[Rating]) &&
($mpage->IdNum == $rp[FSubm]) &&
($mpage->user[ModToday]) &&
($s[UT] > time() - $tmel)
)) { ?>
<td align=center class="stdtable">
<small>
<a class="stdtxt" href="mod.php?id=<?= $s[Id] ?>">Mod Up</a> |
<a class="stdtxt" href="mod.php?id=<?= $s[Id] ?>&d=1">Down</a>
</small>
</td>
<? } ?>
<td align=right colspan= <?= ($dst2) ? "1" : "2" ?> class="stdtable">
<a class="stdtxt" href="bbs.php?showcomment=<?= $s[Id] ?>">Rated
<?= ($s[Rating] >= 0) ? "+" : "" ?>
<?= $s[Rating] ?></a>
<? if (!$rp[Locked]) { ?>
|
<a class="stdtxt" href="postcomment.php?section=<?=
$rp[Section] ?>&postid=<?= $postid ?>&reply=<?= $s[Id] ?>">Reply</a>
<? } ?>
| <a class="stdtxt" href="bbs.php?showcomment=<?= $s[Id] ?>">Link</a>
</td>
</tr>
<?
}
?>
</table>
<? if ($tpsc != 1) { ?>
<BR>
<table width=95% cellpadding=0 cellspacing=0>
<tr><td>
<? if ($page != 1) { ?>
<a href="bbs.php?postid=<?= $postid ?>&page=<?= ($page-1) ?>"><< Prev</a>
<? } ?>
<td><td align=right>
<? if ($page != $tpsc) { ?>
<a href="bbs.php?postid=<?= $postid ?>&page=<?= ($page+1) ?>"">Next >></a>
<? } ?>
</td></tr>
</table>
<? } ?>
<BR><BR>
</center>
<?
return array($rp[FSubm], $rp[Section]);
}
function TopicPrint($topicid, $page)
{
global $mpage;
$btp = 25;
$page = (is_numeric($page)) ? $page : "1";
$limit = "limit " . ($page - 1) * $btp . ", " . $btp;
$sql = "select * from BoardSections";
$bss = $mpage->DoQuery($sql,1);
$brd = array();
foreach ($bss as $b)
{
$brd[$b[Id]] = $b;
if ($b[Id] == $topicid)
{
$bsc = $b;
}
}
$sql = "select * from BoardSections where Id = \"$topicid\" ";
$bsc = $mpage->DoQuery($sql, 1);
if (sizeof($bsc))
{
if ($bsc[0][Head])
{
$whr = " AND CommentHead.Section=". $topicid;
}
else
{
$sql = "select * from BoardSections where Head = \"$topicid\" ";
$bsc = $mpage->DoQuery($sql,1);
foreach ($bsc as $k => $v) $bsc[$k] = $v[Id];
$whr = " AND CommentHead.Section IN (".join(",", $bsc).")";
}
}
$gtt = array_merge($mpage->Friend[0], $mpage->Friend[1], $mpage->Friend[2]);
$sql = "select SQL_CALC_FOUND_ROWS CommentHead.*, UNIX_TIMESTAMP(Fdt) as Fdta, UNIX_TIMESTAMP(Ndt) as Ndta,
Uta.Fname as LoginA, Utb.Fname as LoginB from CommentHead
left join UserTable as Uta on Uta.Id = FSubm
left join UserTable as Utb on Utb.Id = NSubm
WHERE FSubm IN (".join(",", $gtt).") $whr
order by CommentHead.Newest desc $limit";
$tps = $mpage->DoQuery($sql,1);
$sql = "select FOUND_ROWS()";
$tpsc = $mpage->DoQuery($sql);
$tpsc = $tpsc[0][0];
$tpsc = ($tpsc) ? $tpsc : 1;
$tpsc = ceil($tpsc / $btp);
?>
<BR>
<center>
<table width=95% border=1 cellspacing=0 class="stdtable">
<? if (!sizeof($tps)) { ?>
<tr>
<td valign = "top" colspan=4 class="stdtable">
<B>Sorry</b>
</td>
</tr>
<tr>
<td valign = "top" colspan=5 class="stdfilling">
There aren't any posts within this section. <P>Why don't you make one?
</td>
</tr>
<? } ?>
<? if ($tpsc != 1) { ?>
<tr>
<td valign = "top" colspan=4 class="stdaltfilling">
<table width=100% cellpadding=0 cellspacing=0>
<tr><td>
<? if ($page != 1) { ?>
<a href="bbs.php?topicid=<?= $topicid ?>&page=<?= ($page-1) ?>"><< Prev</a>
<? } ?>
<td><td align=right>
<? if ($page != $tpsc) { ?>
<a href="bbs.php?topicid=<?= $topicid ?>&page=<?= ($page+1) ?>"">Next >></a>
<? } ?>
</td></tr>
</table>
</td></tr>
<? } ?>
<? foreach ($tps as $t) { ?>
<tr>
<td valign = "top" colspan=4 class="stdtable">
<a class="stdtxt"
href = "bbs.php?postid=<?= $t["Id"] ?>">
<?= ($t[Name]) ? $t[Name] : "(Untitled)" ?></a>
<BR>
<?
$tmp = $t[Section];
$bid = $brd[$t[Section]][Id];
$bnm = $brd[$t[Section]][BoardName];
$hid = $brd[ $brd[$t[Section]][Head] ][Id];
$hnm = $brd[ $brd[$t[Section]][Head] ][BoardName];
?>
<small>
<a class="stdtxt" href="bbs.php?topicid=<?= $hid ?>"><?= $hnm ?></a> =>
<a class="stdtxt" href="bbs.php?topicid=<?= $bid ?>"><?= $bnm ?></a>
</small>
</td>
</tr>
<tr>
<td width=12px valign=top class="stdtable">
<? if ($t[Locked]) { ?>
<img src = "images/padlock.gif" width = 12 height = 15 align = center
alt = "This Thread is now Locked. No more posts to this.">
<? } else { ?>
<? } ?>
</td>
<td width = 150 valign=top class="stdfilling">
<?= $t[LoginA] ?>
<BR><B>
<? $tm = time() - $t[Fdta]; ?>
<? if ($tm >= (3600 * 24)) { ?>
<?= floor( $tm / (3600 * 24) ) ?> Day(s) Old
<? } elseif ($tm > 3600) { ?>
<?= floor( $tm / 3600 ) ?> Hour(s) Old
<? } else { ?>
<?= floor( $tm / 60 ) ?> Minute(s) Old
<? } ?>
</b>
<BR> <?= date("D m/d/y h:i:a", $t[Fdta]) ?>
</td>
<td width = 75 valign = "top" class="stdfilling">
<I><B><?= $t[NumComments] ?> Post(s)</B></I>
</td>
<td width = 150 class="stdfilling">
<?= $t[LoginB] ?>
<BR>
<a href="bbs.php?showcomment=<?= $t[Newest] ?>">Go:
<B>
<? $tm = time() - $t[Ndta]; ?>
<? if ($tm >= (3600 * 24)) { ?>
<?= floor( $tm / (3600 * 24) ) ?> Day(s) Old
<? } elseif ($tm > 3600) { ?>
<?= floor( $tm / 3600 ) ?> Hour(s) Old
<? } else { ?>
<?= floor( $tm / 60 ) ?> Minute(s) Old
<? } ?>
</b>
</a>
<BR> <?= date("D m/d/y h:i:a", $t[Ndta]) ?>
</td>
</tr>
<? } ?>
<tr>
<td colspan = 5 class="stdtable"> </td>
</tr>
</table>
</center>
<BR><BR>
<? }
function TopicSide()
{
global $topicidc, $mpage;
OtherTopics();
NewPost();
Explain();
}
function Explain()
{
global $mpage;
?>
<BR>
<table border=1 cellpadding=2px cellspacing=0 width=100%>
<tr><td align=center class=stdtable>
<B><?= $mpage->sys[sitename] ?> BBS</b>
</td></tr>
<tr><td align=center class="stdaltfilling">
This messageboard contains all the posts / threads of your friends, and their friends.
In order to see more of the posts that exist within the <?= $mpage->sys[sitename] ?> system, please
<a href="invite.php">Invite</a> more people to the site, or <a href="people.php">Make
more friends</a>
</td></tr>
</table>
<? }
function PostSide($msgowner)
{
global $mpage, $topicidc;
PostHere();
if ($msgowner[0] == $mpage->IdNum) ModMenu($msgowner[1]);
OtherTopics($topicidc);
if ($msgowner[0] != $mpage->IdNum) AboutAuthor();
}
function AboutAuthor()
{
global $mpage,$postid;
$sql = "select UserTable.* from CommentTable
left join UserTable on UserTable.Id = CommentTable.Submittee
where Head = '$postid' ";
$r = $mpage->DoQuery($sql,1);
if (!count($r)) return;
$r = $r[0];
?>
<BR>
<table border=1 width=100% cellspacing=0>
<tr><td align=center class=stdtable>
<B>About <?= $r[Fname] ?></b>
</td></tr>
<tr><td align=center class="stdaltfilling">
<table width=100% border=0><tr>
<td width=85><img src="userpics/<?= $mpage->PicPr($r[PicDefault], $r[Id]) ?>-b.jpg"></td><td width=55%>
<a href="user.php?id=<?= $r[Id] ?>"><?= $r[Fname] ?></a><BR>
User #<?= $r[Id] ?><BR>
</td></tr>
<tr><td colspan=2>
<?
$bio = $mpage->PrintBio($r[Bio]);
?>
<? if (strlen($bio) > 175) { ?>
<?= strip_tags(substr($bio,0,175)) ?>...
<? } elseif(strlen($r[Bio]) > 0) { ?>
<?= strip_tags($bio) ?>
<? } else { ?>
This user does not have a bio... yet.
<? } ?>
</td></tr>
</table>
</td></tr>
</table>
<?
}
function ModMenu($g)
{
global $mpage, $postid, $topicid;
$sql = "select * from CommentHead where Id = \"$postid\" ";
$gt = $mpage->DoQuery($sql,1);
$gt = $gt[0];
$title = ($gt[Locked]) ? "Unlock" : "Lock";
?>
<BR>
<table border=1 cellspacing=0 width=100%>
<tr><td align=center class="stdtable">
<B>
You Own This Thread
</b>
</td></tr>
<tr><td align=center class="stdaltfilling">
<P>You currently have <?= $mpage->user[ModToday] ?> owner points left for today.
<P><a href="threadlock.php?id=<?= $postid ?>"><?= $title ?> this
thread</a>
<P>Which topic is this thread in?
<form method="post" action="editthread.php">
<select name=topicid>
<option value="">View All Topics
<? $mpage->GetOptions($g) ?>
</select>
<input type=hidden name=id value="<?= $gt[Id] ?>">
<input type=submit class=submit value="Set Category!">
</form>
</td></tr>
</table>
<?
}
function PostHere()
{
global $mpage, $postid, $topicid;
$sql = "select * from CommentHead where Id = \"$postid\" ";
$gt = $mpage->DoQuery($sql,1);
$gt = $gt[0];
$sql = "select * from BoardSections where Id != \"$topicid\" ";
?>
<BR>
<table border=1 cellpadding=2px cellspacing=0 width=100%>
<? if ($gt[Locked]) { ?>
<tr><td align=center class="stdtable">
<img src="images/padlock.gif">
<B>Locked Thread</b>
<img src="images/padlock.gif">
</td></tr>
<tr><td align=center class="stdaltfilling">
Sorry, but the post here has been locked by its owner.
<? } elseif (sizeof($mpage->Friend[1])) { ?>
<tr><td align=center class="stdtable">
<b>Post a Comment</b>
</td></tr>
<tr><td align=center class="stdaltfilling">
<BR>
Want to post a comment on this topic. Be sure you have read the rules for this section
and click here:
<form method="post" action="postcomment.php">
<input name="section" type="hidden" value="<?= $gt[Section] ?>">
<input name="postid" type="hidden" value="<?= $postid ?>">
<input type=submit class=submit value="Make a Post Here">
</form>
<? } else { ?>
<tr><td align=center class=stdtable>
<B>Submit a New Topic</b>
</td></tr>
<tr><td align=center class="stdaltfilling">
<P>Sorry, but you can't post on the BBS unless you have some friends on
the <?= $mpage->sys[sitename] ?> network. The reason for this is that you can only see posts
on the messageboard from people who are within your friend network.
<P>Please, <a href="invite.php">Invite some friends</a> to the site, and try
again later.</p>
</td></tr>
<? } ?>
</td></tr>
</table>
<?
}
function OtherTopics($g="")
{
$g = (!$g) ? $_GET[topicid] : $g;
global $mpage;
?>
<br>
<table border=1 cellpadding=2px cellspacing=0 width=100%>
<form method=get>
<tr><td align=center class="stdtable">
<B>Sections</B>
</td></tr>
<tr><td align=center class="stdaltfilling">
<select name=topicid>
<option value="">View All Topics
<? $mpage->GetOptions($g) ?>
</select>
<input type=submit class=submit value="Gooooooo!">
</td></tr>
</form>
</table>
<?
}
function NewPost()
{
global $mpage;
if (sizeof($mpage->Friend[1])) { ?>
<BR>
<form method="post" action="postcomment.php">
<table border=1 cellpadding=2px cellspacing=0 width=100%>
<tr><td align=center class=stdtable>
<B>Submit a New Topic</b>
</td></tr>
<tr><td align=center class="stdaltfilling">
<BR>
Want to submit a new topic?<BR><BR>
<input type="submit" class="submit" value="Add A New Topic">
</td></tr>
</table>
</form>
<? } else { ?>
<BR>
<table border=1 cellpadding=2px cellspacing=0 width=100%>
<tr><td align=center class=stdtable>
<B>Submit a New Topic</b>
</td></tr>
<tr><td align=center class="stdaltfilling">
<P>Sorry, but you can't post on the BBS unless you have some friends on
the <?= $mpage->sys[sitename] ?> network. The reason for this is that you can only see posts
on the messageboard from people who are within your friend network.
<P>Please, <a href="invite.php">Invite some friends</a> to the site, and try
again later.</p>
</td></tr>
</table>
<? }
}
function PageTrans($to)
{
global $mpage, $postid, $page, $goto;
$sql = "select CommentTable.* from CommentTable
left join CommentHead on CommentTable.Head = CommentHead.Id
where CommentTable.Id = \"$to\" ";
$r = $mpage->DoQuery($sql,1);
if (!sizeof($r)) return;
$r = $r[0];
$sub = $r[Head];
$sql = "select Id from CommentTable where Head = $sub order by
Id asc";
$r = $mpage->DoQuery($sql);
for ($x = 0; $x < sizeof($r); $x++) $r[$x] = $r[$x][0];
$pge = array_search($to, $r) + 1;
$pge = ceil($pge / 10);
$postid = $sub;
$page = $pge;
$goto = "$to";
return;
}
?>