2013-05-28 08:01:02 +00:00
|
|
|
<?php
|
2011-03-28 14:21:28 +00:00
|
|
|
/************************************************************************
|
|
|
|
//------------// Main friends page //----------------------------------//
|
2013-02-22 08:00:24 +00:00
|
|
|
This page lists a user's friends.
|
2011-03-28 14:21:28 +00:00
|
|
|
|
2013-02-22 08:00:24 +00:00
|
|
|
There's no real point in caching this page. I doubt users load it that
|
2011-03-28 14:21:28 +00:00
|
|
|
much.
|
|
|
|
************************************************************************/
|
|
|
|
|
2013-02-22 08:00:24 +00:00
|
|
|
// Number of users per page
|
2011-03-28 14:21:28 +00:00
|
|
|
define('FRIENDS_PER_PAGE', '20');
|
2013-05-27 08:00:58 +00:00
|
|
|
include_once(SERVER_ROOT.'/classes/paranoia.class.php');
|
2011-03-28 14:21:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2012-10-11 08:00:15 +00:00
|
|
|
View::show_header('Friends');
|
2013-02-22 08:00:24 +00:00
|
|
|
|
2011-03-28 14:21:28 +00:00
|
|
|
|
|
|
|
$UserID = $LoggedUser['ID'];
|
|
|
|
|
|
|
|
|
2013-05-28 08:01:02 +00:00
|
|
|
list($Page, $Limit) = Format::page_limit(FRIENDS_PER_PAGE);
|
2011-03-28 14:21:28 +00:00
|
|
|
|
|
|
|
// Main query
|
2013-04-19 08:00:55 +00:00
|
|
|
$DB->query("
|
|
|
|
SELECT
|
|
|
|
SQL_CALC_FOUND_ROWS
|
|
|
|
f.FriendID,
|
|
|
|
f.Comment,
|
|
|
|
m.Username,
|
|
|
|
m.Uploaded,
|
|
|
|
m.Downloaded,
|
|
|
|
m.PermissionID,
|
|
|
|
m.Paranoia,
|
|
|
|
m.LastAccess,
|
|
|
|
i.Avatar
|
|
|
|
FROM friends AS f
|
2013-07-10 00:08:53 +00:00
|
|
|
JOIN users_main AS m ON f.FriendID = m.ID
|
|
|
|
JOIN users_info AS i ON f.FriendID = i.UserID
|
|
|
|
WHERE f.UserID = '$UserID'
|
2013-04-19 08:00:55 +00:00
|
|
|
ORDER BY Username
|
|
|
|
LIMIT $Limit");
|
2012-04-09 08:00:24 +00:00
|
|
|
$Friends = $DB->to_array(false, MYSQLI_BOTH, array(6, 'Paranoia'));
|
2011-03-28 14:21:28 +00:00
|
|
|
|
|
|
|
// Number of results (for pagination)
|
|
|
|
$DB->query('SELECT FOUND_ROWS()');
|
|
|
|
list($Results) = $DB->next_record();
|
|
|
|
|
|
|
|
// Start printing stuff
|
|
|
|
?>
|
|
|
|
<div class="thin">
|
2012-08-19 08:00:19 +00:00
|
|
|
<div class="header">
|
|
|
|
<h2>Friends list</h2>
|
|
|
|
</div>
|
2011-03-28 14:21:28 +00:00
|
|
|
<div class="linkbox">
|
|
|
|
<?
|
|
|
|
// Pagination
|
2013-04-17 08:00:58 +00:00
|
|
|
$Pages = Format::get_pages($Page, $Results, FRIENDS_PER_PAGE, 9);
|
2011-03-28 14:21:28 +00:00
|
|
|
echo $Pages;
|
|
|
|
?>
|
|
|
|
</div>
|
|
|
|
<div class="box pad">
|
|
|
|
<?
|
2013-04-17 08:00:58 +00:00
|
|
|
if ($Results == 0) {
|
2011-03-28 14:21:28 +00:00
|
|
|
echo '<p>You have no friends! :(</p>';
|
|
|
|
}
|
|
|
|
// Start printing out friends
|
2013-04-17 08:00:58 +00:00
|
|
|
foreach ($Friends as $Friend) {
|
2012-03-28 08:00:20 +00:00
|
|
|
list($FriendID, $Comment, $Username, $Uploaded, $Downloaded, $Class, $Paranoia, $LastAccess, $Avatar) = $Friend;
|
2011-03-28 14:21:28 +00:00
|
|
|
?>
|
2012-09-15 08:00:25 +00:00
|
|
|
<form class="manage_form" name="friends" action="friends.php" method="post">
|
2011-03-28 14:21:28 +00:00
|
|
|
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
|
2011-09-13 08:00:15 +00:00
|
|
|
<table class="friends_table vertical_margin">
|
2012-09-01 08:00:24 +00:00
|
|
|
<tr class="colhead">
|
2013-05-28 08:01:02 +00:00
|
|
|
<td colspan="<?=(Users::has_avatars_enabled() ? 3 : 2)?>">
|
2013-04-19 08:00:55 +00:00
|
|
|
<span style="float: left;"><?=Users::format_username($FriendID, true, true, true, true)?>
|
2013-04-17 08:00:58 +00:00
|
|
|
<? if (check_paranoia('ratio', $Paranoia, $Class, $FriendID)) { ?>
|
2012-10-11 08:00:15 +00:00
|
|
|
Ratio: <strong><?=Format::get_ratio_html($Uploaded, $Downloaded)?></strong>
|
2013-04-17 08:00:58 +00:00
|
|
|
<? }
|
|
|
|
if (check_paranoia('uploaded', $Paranoia, $Class, $FriendID)) { ?>
|
2012-10-11 08:00:15 +00:00
|
|
|
Up: <strong><?=Format::get_size($Uploaded)?></strong>
|
2013-04-17 08:00:58 +00:00
|
|
|
<? }
|
|
|
|
if (check_paranoia('downloaded', $Paranoia, $Class, $FriendID)) { ?>
|
2012-10-11 08:00:15 +00:00
|
|
|
Down: <strong><?=Format::get_size($Downloaded)?></strong>
|
2011-03-28 14:21:28 +00:00
|
|
|
<? } ?>
|
|
|
|
</span>
|
2013-04-17 08:00:58 +00:00
|
|
|
<? if (check_paranoia('lastseen', $Paranoia, $Class, $FriendID)) { ?>
|
2013-04-19 08:00:55 +00:00
|
|
|
<span style="float: right;"><?=time_diff($LastAccess)?></span>
|
2011-03-28 14:21:28 +00:00
|
|
|
<? } ?>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
2013-05-01 08:00:16 +00:00
|
|
|
<? if (Users::has_avatars_enabled()) { ?>
|
|
|
|
<td class="col_avatar avatar" valign="top">
|
|
|
|
<?=Users::show_avatar($Avatar, $Username, $HeavyInfo['DisableAvatars'])?>
|
2011-03-28 14:21:28 +00:00
|
|
|
</td>
|
2013-05-15 08:00:54 +00:00
|
|
|
<? } ?>
|
2011-03-28 14:21:28 +00:00
|
|
|
<td valign="top">
|
|
|
|
<input type="hidden" name="friendid" value="<?=$FriendID?>" />
|
|
|
|
|
2013-05-01 08:00:16 +00:00
|
|
|
<textarea name="comment" rows="4" cols="65"><?=$Comment?></textarea>
|
2011-03-28 14:21:28 +00:00
|
|
|
</td>
|
|
|
|
<td class="left" valign="top">
|
|
|
|
<input type="submit" name="action" value="Update" /><br />
|
2013-04-17 08:00:58 +00:00
|
|
|
<input type="submit" name="action" value="Remove friend" /><br />
|
2011-03-28 14:21:28 +00:00
|
|
|
<input type="submit" name="action" value="Contact" /><br />
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
</form>
|
|
|
|
<?
|
|
|
|
} // while
|
|
|
|
|
|
|
|
// close <div class="box pad">
|
|
|
|
?>
|
|
|
|
</div>
|
|
|
|
<div class="linkbox">
|
|
|
|
<?=$Pages?>
|
|
|
|
</div>
|
2013-04-17 08:00:58 +00:00
|
|
|
<? // close <div class="thin"> ?>
|
2011-03-28 14:21:28 +00:00
|
|
|
</div>
|
|
|
|
<?
|
2012-10-11 08:00:15 +00:00
|
|
|
View::show_footer();
|
2011-03-28 14:21:28 +00:00
|
|
|
?>
|