123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- <?php
- #declare(strict_types=1);
-
- /**
- * Main friends page
- *
- * This page lists a user's friends.
- * There's no real point in caching this page.
- * I doubt users load it that much.
- */
-
- $ENV = ENV::go();
-
- // Number of users per page
- define('FRIENDS_PER_PAGE', '20');
- include_once "$ENV->SERVER_ROOT/classes/paranoia.class.php";
-
- View::show_header('Friends');
-
- $UserID = $LoggedUser['ID'];
- list($Page, $Limit) = Format::page_limit(FRIENDS_PER_PAGE);
-
- // Main query
- $DB->prepared_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
- JOIN `users_main` AS m ON f.`FriendID` = m.`ID`
- JOIN `users_info` AS i ON f.`FriendID` = i.`UserID`
- WHERE f.`UserID` = '$UserID'
- ORDER BY `Username`
- LIMIT $Limit");
- $Friends = $DB->to_array(false, MYSQLI_BOTH, array(6, 'Paranoia'));
-
- // Number of results (for pagination)
- $DB->prepared_query('SELECT FOUND_ROWS()');
- list($Results) = $DB->next_record();
-
- // Start printing stuff?>
-
- <div>
- <div class="header">
- <h2>Friends List</h2>
- </div>
-
- <div class="linkbox">
- <?php
- // Pagination
- $Pages = Format::get_pages($Page, $Results, FRIENDS_PER_PAGE, 9);
- echo $Pages; ?>
- </div>
-
- <div class="box pad">
- <?php
- if ($Results === 0) {
- echo '<p>You have no friends! :(</p>';
- }
-
- // Start printing out friends
- foreach ($Friends as $Friend) {
- list($FriendID, $Comment, $Username, $Uploaded, $Downloaded, $Class, $Paranoia, $LastAccess, $Avatar) = $Friend; ?>
- <form class="manage_form" name="friends" action="friends.php" method="post">
- <input type="hidden" name="auth"
- value="<?=$LoggedUser['AuthKey']?>" />
- <table class="friends_table vertical_margin">
- <tr class="colhead">
- <td colspan="<?=(Users::has_avatars_enabled() ? 3 : 2)?>">
- <span class="float_left"><?=Users::format_username($FriendID, true, true, true, true)?>
- <?php if (check_paranoia('ratio', $Paranoia, $Class, $FriendID)) { ?>
- Ratio: <strong><?=Format::get_ratio_html($Uploaded, $Downloaded)?></strong>
- <?php
- }
-
- if (check_paranoia('uploaded', $Paranoia, $Class, $FriendID)) {
- ?>
- Up: <strong><?=Format::get_size($Uploaded)?></strong>
- <?php
- }
-
- if (check_paranoia('downloaded', $Paranoia, $Class, $FriendID)) {
- ?>
- Down: <strong><?=Format::get_size($Downloaded)?></strong>
- <?php
- } ?>
- </span>
- <?php if (check_paranoia('lastseen', $Paranoia, $Class, $FriendID)) { ?>
- <span class="float_right"><?=time_diff($LastAccess)?></span>
- <?php } ?>
- </td>
- </tr>
- <tr>
- <?php if (Users::has_avatars_enabled()) { ?>
- <td class="col_avatar avatar" valign="top">
- <?=Users::show_avatar($Avatar, $FriendID, $Username, $HeavyInfo['DisableAvatars'])?>
- </td>
- <?php } ?>
- <td valign="top">
- <input type="hidden" name="friendid"
- value="<?=$FriendID?>" />
-
- <textarea
- name = "comment"
- rows = "5"
- cols = "50"
- placeholder ="Your saved notes about this friend"
- ><?=$Comment?></textarea>
- </td>
- <td class="left" valign="top">
- <p>
- <input type="submit" name="action" value="Update" />
- <input type="submit" name="action" value="Remove friend" />
- </p>
-
- <p>
- <input type="submit" name="action" class="button-primary" value="Contact" />
- </p>
-
- </td>
- </tr>
- </table>
- </form>
- <?php
- } // while
-
- // close <div class="box pad">
- ?>
- </div>
- <div class="linkbox">
- <?= $Pages ?>
- </div>
- <?php // close <div>?>
- </div>
- <?php
- View::show_footer();
|