<?
# 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();
$mpage->Initialize("authremainder");
$sql = "select * from UserTable where Id = '$id'";
$r = $mpage->DoQuery($sql,1);
$id = (sizeof($r)) ? $r[0][Id] : $mpage->IdNum;
$r = (sizeof($r)) ? $r[0] : $mpage->user;
$level = $mpage->UserDistance($id);
if ($level == -1) NotConnected();
$r[FLevel] = $level;
?>
<BR>
<table width=700 border=0>
<tr><td width=300 valign=top>
<? Title() ?>
<BR>
<? Lst() ?>
<BR>
<? Photos() ?>
<BR>
<? Friends() ?>
</td><td valign=top width=400>
<? Profile() ?>
<BR>
<? Testimonials() ?>
</td></tr>
</table>
<? $mpage->ClosePage(); ?>
<?
function NotConnected()
{
global $mpage;
?>
<p class="title1">Sorry</p>
<P>The person you're trying to see is outside of your Friend Network.
Try making some more friends in order to see this person, or check back later.</p>
<?
$mpage->ClosePage();
}
function Title()
{
global $r, $mpage;
?>
<table width=300 border=1 cellspacing=0 cellpadding=5px>
<tr>
<td colspan=2 align=center class="stdtable">
<? if ($r[FLevel] == 0) { ?>
<B>Hey <?= $r[Fname] ?>!</b>
<? } elseif ($r[FLevel] == 1) { ?>
<B><?= $r[Fname] ?> is your friend</b>
<? } else { ?>
<B>Your connection to <?= $r[Fname] ?></b>
</td></tr>
<tr><td class="stdfilling" align=center>
<?
FindConnection($r[Id], $r[FLevel], 3, $r);
} ?>
</span>
</td></tr>
</table>
<? }
function FindConnection($id, $flevel, $limit, $rr)
{
global $mpage, $gv;
$gv = array();
$r = array();
$fl = $flevel-1;
$tgg = $mpage->Friend[$fl];
$tgg = (sizeof($tgg)) ? join(",",$tgg) : "0";
$sql = "select Start,End, UserTable.Fname, UserTable.Lname from FriendTable
left join UserTable on UserTable.Id = FriendTable.Start
where End = $id AND Start IN ($tgg)";
$r[$fl] = $mpage->DoQuery($sql,1);
while ($fl > 1)
{
$tmp = array();
foreach ($r[$fl] as $v) array_push($tmp, $v[Start]);
$tmp = (sizeof($tmp)) ? $tmp : array(0);
$fl--;
$tgg = $mpage->Friend[$fl];
$tgg = (sizeof($tgg)) ? join(",",$tgg) : "0";
$sql = "select Start,End, UserTable.Fname, UserTable.Lname from FriendTable
left join UserTable on UserTable.Id = FriendTable.Start
where End IN (".join(",", $tmp).") AND Start IN ($tgg)";
$r[$fl] = $mpage->DoQuery($sql,1);
}
Recurse($r, 1, array(), "");
for ($x = 0; $x < sizeof($gv) && $x < $limit; $x++)
{
$g = $gv[$x];
echo "You <=> ";
foreach ($g as $h) { ?>
<a href="user.php?id=<?= $h[0] ?>"><?=
$h[1] . " " . substr($h[2], 0, 1) ?></a> <=>
<? } ?>
<?= $rr[Fname] ?>
<BR>
<? } ?>
<small>[ <?= sizeof($gv) ?> total connections ]</small>
<? }
function Recurse($r, $x, $ar, $sel)
{
global $gv;
$gt = array();
$s = $r[$x];
if (!sizeof($r[$x]))
{
array_push($gv, $ar);
$cnt++;
return $ar;
}
foreach ($s as $k=>$t)
{
if (($t[Start] == $sel) || ($x == 1))
{
$tt = $ar;
array_push($tt, array($t[Start], $t[Fname], $t[Lname]));
Recurse($r, $x+1, $tt, $t[End]);
}
}
}
function Lst()
{
global $mpage, $level, $r;
$lst = array();
if ($level == 0)
{
$lst[0] = array("usersetup.php", "Edit Profile");
$lst[1] = array("editphotos.php", "Edit Photos");
$lst[2] = array("editfriends.php", "Edit Friends");
$lst[3] = array("edittestimonials.php", "Edit Testimonials");
}
elseif ($level == 1)
{
$lst[0] = array("composemessage.php?id=$r[Id]","Send $r[Fname] a message");
$lst[1] = array("comingsoon.php","Forward to a friend");
$lst[2] = array("comingsoon.php","Add to Bookmarks");
$lst[3] = array("addtestimonial.php?id=$r[Id]","Add a Testimonial");
$lst[4] = array("comingsoon.php","Suggest a Match");
$lst[5] = array("report.php?id=$r[Id]","Report User");
$lst[6] = array("editfriends.php?delete=$r[Id]", "Remove Friend");
}
else
{
$lst[0] = array("composemessage.php?id=$r[Id]","Send $r[Fname] a message");
$lst[1] = array("comingsoon.php","Forward to a friend");
$lst[2] = array("comingsoon.php","Add to Bookmarks");
$lst[3] = array("addfriendrequest.php?id=$r[Id]","Add $r[Fname] as Your Friend");
$lst[4] = array("comingsoon.php","Ask for an Introduction");
$lst[5] = array("comingsoon.php","Suggest a Match");
$lst[6] = array("report.php?id=$r[Id]","Report User");
}
?>
<table bordercolor=black width=300 cellspacing=0 cellpadding=2px border=1>
<tr><td class="stdtable"><B>User Menu</b></td></tr>
<? foreach ($lst as $l) { ?>
<tr><td class="stdaltfilling">
<a href="<?= $l[0] ?>"><?= $l[1] ?></a>
</td></tr>
<? } ?>
</table>
<? }
function Photos()
{
global $r, $mpage;
$sql = "select *, (Id=$r[PicDefault]) as p from UserPics where UserId = $r[Id]
order by p desc limit 3";
$gg = $mpage->DoQuery($sql,1);
if (!sizeof($gg)) return;
?>
<table width=300 cellspacing=0 cellpadding=2px border=1>
<tr><td align=center class="stdaltfilling">
<BR>
<? foreach ($gg as $ggg) { ?>
<a target="_blank" href="userpics/<?= $mpage->PicPr($ggg[Id], $ggg[Userid]) ?>-a.jpg">
<img border=0 src="userpics/<?= $mpage->PicPr($ggg[Id], $ggg[Userid]) ?>-b.jpg"></a>
<? } ?>
<BR>
<? if ($r[FLevel] == "0") { ?>
[<a href="editphotos.php">Edit Photos</a>]
<? } else { ?>
[<a href="photos.php?id=<?= $r[Id] ?>">See Photos</a>]
<? } ?>
<BR>
</td></tr>
</table>
<? }
function Friends()
{
global $mpage,$r;
$sql = "select SQL_CALC_FOUND_ROWS UserTable.* from FriendTable
left join UserTable on UserTable.Id = FriendTable.End
where Start=$r[Id] order by Id desc limit 16";
$rr = $mpage->DoQuery($sql,1);
$sql = "select FOUND_ROWS()";
$cnt = $mpage->DoQuery($sql);
$cnt = $cnt[0][0];
?>
<table width=300 border=1 cellspacing=0>
<tr><td class="stdtable" align=center colspan=4>
<B><?= ($r[FLevel]) ? $r[Fname]."'s" : "My" ?>
Friends (<?= sizeof($rr) ?>)</b>
<BR> <small>[<a class="stdtxt" href="friends.php?id=<?= $r[Id] ?>">See all friends</a>]</small>
</td></tr>
<?
for ($x = 0; $x < sizeof($rr); $x++)
{
if ($x % 4 == 0) echo "\n<tr>\n";
?>
<td width=75 align=center class="stdaltfilling"><BR>
<a href="user.php?id=<?= $rr[$x][Id] ?>">
<img border=0 width=48 height=36 src="userpics/<?= $mpage->PicPr($rr[$x][PicDefault], $rr[$x][Id])
?>-c.jpg"></a>
<BR>
<small><a href="user.php?id=<?= $rr[$x][Id] ?>"><?= $rr[$x][Fname] ?>
<?= substr($rr[$x][Lname], 0, 1) ?></a></small>
</td>
<?
if ($x % 4 == 3) echo "\n</tr>\n";
}
for ($x; $x % 4 != 0; $x++)
{
echo "<td width=75 class=\"stdaltfilling\"> </td>";
if ($x % 4 == 3) echo "\n</tr>\n";
}
?>
</table>
<?
}
function Profile()
{
global $r;
?>
<table width=400 border=1 cellspacing=0 cellpadding=5px>
<tr>
<td colspan=2 class="stdtable">
<table cellspacing=0 cellpadding=0 width=100%>
<tr><td colspan=2 align=center class="stdtable">
<B>
<? if ($r[FLevel]) { ?>
<?= $r[Fname] ?>'s Profile
<? } else { ?>
My Profile
<? } ?>
</b>
</td></tr>
<tr><td width=50% align=left class="stdtable">
<small>Joined: <?= $r[DateJoined] ?></small>
</td><td width=50% align=right class="stdtable">
<small>Last Seen: <?= $r[LastSeen] ?></small>
</td></tr>
</table>
</td></tr>
<tr>
<td width=100 class="stdtable">
<b>User Id</b>
</td>
<td width=300 class="stdfilling">
<?= $r[Id] ?>
</td>
</tr>
<tr>
<td width=100 class="stdtable">
<b>Gender</b>
</td>
<td width=300 class="stdfilling">
<?= ($r[Gender] == 1) ? "Male" : "Female" ?>
</td>
</tr>
<tr>
<td width=100 class="stdtable">
<B>Interested in Meeting People for:</b>
</td>
<td width=300 class="stdfilling">
<?
if ($r[Dating]) echo "Dating";
if ($r[Dating] && $r[Relatn]) echo ", ";
if ($r[Relatn]) echo "Relationship";
if ($r[Dating] || $r[Relatn])
{
echo "<BR><B>with ";
if ($r[DrGender] == 1) echo "Men";
elseif ($r[DrGender] == 2) echo "Women";
else echo "Men and Women";
echo "</b>";
}
if ($r[Dating] || $r[Relatn]) echo "<BR>";
if ($r[Friends]) echo "Friends";
if ($r[Friends] && $r[Netbud]) echo ", ";
if ($r[Netbud]) echo "Net Buddy";
if ($r[Friends] || $r[Relatn])
{
echo "<BR><B>with ";
if ($r[FnGender] == 1) echo "Men";
elseif ($r[FnGender] == 2) echo "Women";
else echo "Men and Women";
echo "</b>";
}
?>
</td>
</tr>
<tr>
<td width=100 class="stdtable">
<B>I'm looking to, or might:</b>
</td>
<td width=300 class="stdfilling">
<? if ($r[MeetMe] == 1) { ?>
Chat Online Only
<? } elseif ($r[MeetMe] == 2) { ?>
Call on the Phone
<? } elseif ($r[MeetMe] == 3) { ?>
Meet if in the area
<? } elseif ($r[MeetMe] == 4) { ?>
Might travel and meet up
<? } ?>
</td>
</tr>
<tr>
<td width=100 class="stdtable">
<B>Dating Status:</b>
</td>
<td width=300 class="stdfilling">
<? if ($r[Datestatus] == 0) { ?>
Unspecified
<? } elseif ($r[Datestatus] == 1) { ?>
Single
<? } elseif ($r[Datestatus] == 2) { ?>
Light Dating
<? } elseif ($r[Datestatus] == 3) { ?>
Relationship
<? } elseif ($r[Datestatus] == 4) { ?>
Engaged
<? } elseif ($r[Datestatus] == 5) { ?>
Married
<? } ?>
</td>
</tr>
<tr>
<td width=100 class="stdtable">
<B>Age:</b>
</td>
<td width=300 class="stdfilling">
<?= $r[Age] ?>
</td>
</tr>
<? if ($r[Bio]) { ?>
<tr>
<td width=100 class="stdtable">
<B>Bio:</b>
</td>
<td width=300 class="stdfilling">
<?= $r[Bio] ?>
</td>
</tr>
<? } ?>
<tr>
<td width=100 class="stdtable">
<B>Zipcode:</b>
</td>
<td width=300 class="stdfilling">
<?= $r[Zipcode] ?>
</td>
</tr>
<tr>
<td width=100 class="stdtable">
<B>Country:</b>
</td>
<td width=300 class="stdfilling">
<?= $r[Country] ?>
</td>
</tr>
<tr>
<td width=100 class="stdtable">
<B>Job / Occupation:</b>
</td>
<td width=300 class="stdfilling">
<?= $r[Job] ?>
</td>
</tr>
<tr>
<td width=100 class="stdtable">
<b>Interests:</b>
</td>
<td width=300 class="stdfilling">
<?
$ri = explode(",", $r[Interests]);
foreach ($ri as $k => $v)
{
$v = trim($v);
if (strlen($v) > 3)
$ri[$k] = "<a href=\"searchinterest.php?searchtxt=".urlencode($v)."\">$v</a>";
}
echo join(", ", $ri) . " ";
?>
</td>
</tr>
</table>
<? }
function Testimonials()
{
global $mpage, $r;
$sql = "select Testimonials.*, UserTable.Fname, UserTable.PicDefault, UserTable.Lname
from Testimonials
left join UserTable on Testimonials.Start = UserTable.Id
where End=$r[Id] AND Approved=1";
$m = $mpage->DoQuery($sql,1);
?>
<table cellspacing=0 width=400>
<tr><td align=center class=stdtable colspan=2>
<B><?= ($r[Id] == $mpage->IdNum) ? "Your" : ($r[Fname] . "'s") ?> Testimonials</b>
</td></tr>
<? if (!sizeof($m)) { ?>
<tr><td align=center class=stdfilling colspan=2>
<? if ($mpage->IdNum == $r[Id]) { ?>
You currently have no testimonials.
<? } else { ?>
<?= $r[Fname] ?> currently has no testimonials
<? } ?>
</td></tr>
<? } ?>
<? foreach ($m as $n) { ?>
<tr><td align=center valign=top class=stdfilling width=100>
<a href="user.php?id=<?= $n[Start] ?>"><img border=0 src="userpics/<?= $mpage->PicPr($n[PicDefault], $n[Start]) ?>-b.jpg"></a>
<BR><small><a href="user.php?id=<?= $n[Start] ?>"><?= $n[Fname] ?> <?= substr($n[Lname],0,1) ?></a></small>
</td><td class=stdfilling>
<?= str_replace("\r\n", "<BR>", htmlentities($n[Txt])) ?>
</td></tr>
<? } ?>
</table>
<? }