BioTorrents.de’s version of Gazelle
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

friends.php 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <?php
  2. #declare(strict_types=1);
  3. /**
  4. * Main friends page
  5. *
  6. * This page lists a user's friends.
  7. * There's no real point in caching this page.
  8. * I doubt users load it that much.
  9. */
  10. $ENV = ENV::go();
  11. // Number of users per page
  12. define('FRIENDS_PER_PAGE', '20');
  13. include_once "$ENV->SERVER_ROOT/classes/paranoia.class.php";
  14. View::show_header('Friends');
  15. $UserID = $LoggedUser['ID'];
  16. list($Page, $Limit) = Format::page_limit(FRIENDS_PER_PAGE);
  17. // Main query
  18. $DB->prepared_query("
  19. SELECT
  20. SQL_CALC_FOUND_ROWS
  21. f.`FriendID`,
  22. f.`Comment`,
  23. m.`Username`,
  24. m.`Uploaded`,
  25. m.`Downloaded`,
  26. m.`PermissionID`,
  27. m.`Paranoia`,
  28. m.`LastAccess`,
  29. i.`Avatar`
  30. FROM `friends` AS f
  31. JOIN `users_main` AS m ON f.`FriendID` = m.`ID`
  32. JOIN `users_info` AS i ON f.`FriendID` = i.`UserID`
  33. WHERE f.`UserID` = '$UserID'
  34. ORDER BY `Username`
  35. LIMIT $Limit");
  36. $Friends = $DB->to_array(false, MYSQLI_BOTH, array(6, 'Paranoia'));
  37. // Number of results (for pagination)
  38. $DB->prepared_query('SELECT FOUND_ROWS()');
  39. list($Results) = $DB->next_record();
  40. // Start printing stuff?>
  41. <div>
  42. <div class="header">
  43. <h2>Friends List</h2>
  44. </div>
  45. <div class="linkbox">
  46. <?php
  47. // Pagination
  48. $Pages = Format::get_pages($Page, $Results, FRIENDS_PER_PAGE, 9);
  49. echo $Pages; ?>
  50. </div>
  51. <div class="box pad">
  52. <?php
  53. if ($Results === 0) {
  54. echo '<p>You have no friends! :(</p>';
  55. }
  56. // Start printing out friends
  57. foreach ($Friends as $Friend) {
  58. list($FriendID, $Comment, $Username, $Uploaded, $Downloaded, $Class, $Paranoia, $LastAccess, $Avatar) = $Friend; ?>
  59. <form class="manage_form" name="friends" action="friends.php" method="post">
  60. <input type="hidden" name="auth"
  61. value="<?=$LoggedUser['AuthKey']?>" />
  62. <table class="friends_table vertical_margin">
  63. <tr class="colhead">
  64. <td colspan="<?=(Users::has_avatars_enabled() ? 3 : 2)?>">
  65. <span class="float_left"><?=Users::format_username($FriendID, true, true, true, true)?>
  66. <?php if (check_paranoia('ratio', $Paranoia, $Class, $FriendID)) { ?>
  67. &nbsp;Ratio: <strong><?=Format::get_ratio_html($Uploaded, $Downloaded)?></strong>
  68. <?php
  69. }
  70. if (check_paranoia('uploaded', $Paranoia, $Class, $FriendID)) {
  71. ?>
  72. &nbsp;Up: <strong><?=Format::get_size($Uploaded)?></strong>
  73. <?php
  74. }
  75. if (check_paranoia('downloaded', $Paranoia, $Class, $FriendID)) {
  76. ?>
  77. &nbsp;Down: <strong><?=Format::get_size($Downloaded)?></strong>
  78. <?php
  79. } ?>
  80. </span>
  81. <?php if (check_paranoia('lastseen', $Paranoia, $Class, $FriendID)) { ?>
  82. <span class="float_right"><?=time_diff($LastAccess)?></span>
  83. <?php } ?>
  84. </td>
  85. </tr>
  86. <tr>
  87. <?php if (Users::has_avatars_enabled()) { ?>
  88. <td class="col_avatar avatar" valign="top">
  89. <?=Users::show_avatar($Avatar, $FriendID, $Username, $HeavyInfo['DisableAvatars'])?>
  90. </td>
  91. <?php } ?>
  92. <td valign="top">
  93. <input type="hidden" name="friendid"
  94. value="<?=$FriendID?>" />
  95. <textarea
  96. name = "comment"
  97. rows = "5"
  98. cols = "50"
  99. placeholder ="Your saved notes about this friend"
  100. ><?=$Comment?></textarea>
  101. </td>
  102. <td class="left" valign="top">
  103. <p>
  104. <input type="submit" name="action" value="Update" />
  105. <input type="submit" name="action" value="Remove friend" />
  106. </p>
  107. <p>
  108. <input type="submit" name="action" class="button-primary" value="Contact" />
  109. </p>
  110. </td>
  111. </tr>
  112. </table>
  113. </form>
  114. <?php
  115. } // while
  116. // close <div class="box pad">
  117. ?>
  118. </div>
  119. <div class="linkbox">
  120. <?= $Pages ?>
  121. </div>
  122. <?php // close <div>?>
  123. </div>
  124. <?php
  125. View::show_footer();