Oppaitime'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 2.9KB

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