Gazelle/sections/friends/friends.php

136 lines
3.4 KiB
PHP
Raw Permalink Normal View History

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
2015-02-20 08:00:25 +00:00
View::show_header('Friends','comments');
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
$UserID = $LoggedUser['ID'];
2016-02-10 08:00:30 +00:00
$Select = "f.FriendID";
$Where = "f.UserID = '$UserID'";
2016-02-11 08:00:29 +00:00
$Join1 = "f.FriendID = m.ID";
$Join2 = "f.FriendID = i.UserID";
2016-02-10 08:00:30 +00:00
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
2016-02-10 08:00:30 +00:00
$Select,
2013-04-19 08:00:55 +00:00
f.Comment,
m.Username,
m.Uploaded,
m.Downloaded,
m.PermissionID,
m.Paranoia,
m.LastAccess,
i.Avatar
FROM friends AS f
2016-02-11 08:00:29 +00:00
JOIN users_main AS m ON $Join1
JOIN users_info AS i ON $Join2
2016-02-10 08:00:30 +00:00
WHERE $Where
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">
2013-08-28 23:08:41 +00:00
<h2>Friends List</h2>
2012-08-19 08:00:19 +00:00
</div>
2016-02-11 08:00:29 +00:00
<div class="linkbox">
2011-03-28 14:21:28 +00:00
<?
// 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
&nbsp;Ratio: <strong><?=Format::get_ratio_html($Uploaded, $Downloaded)?></strong>
2013-10-30 08:01:19 +00:00
<?
}
if (check_paranoia('uploaded', $Paranoia, $Class, $FriendID)) {
?>
2012-10-11 08:00:15 +00:00
&nbsp;Up: <strong><?=Format::get_size($Uploaded)?></strong>
2013-10-30 08:01:19 +00:00
<?
}
if (check_paranoia('downloaded', $Paranoia, $Class, $FriendID)) {
?>
2012-10-11 08:00:15 +00:00
&nbsp;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">
2013-08-28 23:08:41 +00:00
<?=Users::show_avatar($Avatar, $FriendID, $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">
2013-10-30 08:01:19 +00:00
<input type="hidden" name="friendid" value="<?=$FriendID?>" />
2011-03-28 14:21:28 +00:00
2013-10-30 08:01:19 +00:00
<textarea name="comment" rows="4" cols="65"><?=$Comment?></textarea>
</td>
<td class="left" valign="top">
<input type="submit" name="action" value="Update" /><br />
<input type="submit" name="action" value="Remove friend" /><br />
<input type="submit" name="action" value="Contact" /><br />
2011-03-28 14:21:28 +00:00
</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
?>