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

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