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.

capture_user.php 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <?php
  2. #declare(strict_types=1);
  3. if (isset($_POST['target']) && isset($_POST['amount'])) {
  4. $TargetID = abs(intval($_POST['target']));
  5. $Amount = abs(intval($_POST['amount']));
  6. $UserID = $LoggedUser['ID'];
  7. $DB->query("
  8. SELECT u.BonusPoints, p.Level
  9. FROM users_main AS u
  10. LEFT JOIN permissions AS p ON u.PermissionID=p.ID
  11. WHERE u.ID = $UserID");
  12. if ($DB->has_results()) {
  13. list($Points, $PLevel) = $DB->next_record();
  14. if ($Points < $Amount) {
  15. error('Not enough points!');
  16. }
  17. if ($UserID == $TargetID) {
  18. error("You can't capture yourself!");
  19. }
  20. if ($PLevel < 200) {
  21. error('Insufficient class');
  22. }
  23. $DB->query("SELECT COUNT(*) FROM slaves WHERE OwnerID = $UserID");
  24. if ($DB->next_record()[0] >= 6) {
  25. error('You own too many users already');
  26. }
  27. // Logic for capture success
  28. $DB->query("
  29. SELECT u.Uploaded,
  30. u.Downloaded,
  31. u.BonusPoints,
  32. COUNT(t.UserID)
  33. FROM users_main AS u
  34. LEFT JOIN torrents AS t ON u.ID=t.UserID
  35. WHERE u.ID = $TargetID");
  36. if (!$DB->has_results()) {
  37. error('User does not exist');
  38. }
  39. list($Upload, $Download, $Points, $Uploads) = $DB->next_record();
  40. $AdjLevel = intval(((($Uploads**0.35)*1.5)+1) * max(($Upload+($Points*1000000)-$Download)/(1024**3), 1) * 1000);
  41. if ($Amount <= $AdjLevel) {
  42. error('You need to spend more points to have any chance of catching this user!');
  43. }
  44. $Captured = (rand(0, $Amount) >= $AdjLevel);
  45. $DB->query("
  46. UPDATE users_main
  47. SET BonusPoints = BonusPoints - $Amount
  48. WHERE ID = $UserID");
  49. $Cache->delete_value('user_info_heavy_'.$UserID);
  50. if ($Captured) {
  51. $DB->query("
  52. INSERT INTO slaves
  53. (UserID, OwnerID)
  54. Values($TargetID, $UserID)");
  55. }
  56. }
  57. View::show_header('Store'); ?>
  58. <div>
  59. <h2>Capture <?=($Captured?'Successful':'Failed')?>
  60. </h2>
  61. <div class="box">
  62. <p>
  63. <?=($Captured?'You successfully captured your target':'Your target eluded capture')?>
  64. </p>
  65. <p>
  66. <a href="/store.php">Back to Store</a>
  67. | <a href="/user.php?id=<?=$TargetID?>">Back to Profile</a>
  68. </p>
  69. </div>
  70. </div>
  71. <?php View::show_footer();
  72. } else {
  73. View::show_header('Store'); ?>
  74. <div>
  75. <div class="box text-align: center;">
  76. <form action="store.php" method="POST">
  77. <input type="hidden" name="item" value="capture_user">
  78. <strong>
  79. Enter the name of the user you want to capture and the <?=BONUS_POINTS?> you want to spend
  80. </strong>
  81. <br />
  82. <input type="text" name="target_name" placeholder="Username">
  83. <input type="text" name="amount"
  84. placeholder="<?=BONUS_POINTS?>">
  85. <input type="submit">
  86. </form>
  87. <p>
  88. <a href="/store.php">Back to Store</a>
  89. </p>
  90. </div>
  91. </div>
  92. <?php
  93. View::show_footer();
  94. }