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.

takemasspm.php 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. #declare(strict_types=1);
  3. //******************************************************************************//
  4. //--------------- Take mass PM -------------------------------------------------//
  5. // This pages handles the backend of the 'Send Mass PM' function. It checks //
  6. // the data, and if it all validates, it sends a PM to everyone who snatched //
  7. // the torrent. //
  8. //******************************************************************************//
  9. authorize();
  10. enforce_login();
  11. require_once SERVER_ROOT.'/classes/validate.class.php';
  12. $Validate = new Validate;
  13. $TorrentID = (int)$_POST['torrentid'];
  14. $GroupID = (int)$_POST['groupid'];
  15. $Subject = $_POST['subject'];
  16. $Message = $_POST['message'];
  17. //******************************************************************************//
  18. //--------------- Validate data in edit form -----------------------------------//
  19. // FIXME: Still need a better perm name
  20. if (!check_perms('site_moderate_requests')) {
  21. error(403);
  22. }
  23. $Validate->SetFields('torrentid', '1', 'number', 'Invalid torrent ID.', array('maxlength' => 1000000000, 'minlength' => 1)); // we shouldn't have torrent IDs higher than a billion
  24. $Validate->SetFields('groupid', '1', 'number', 'Invalid group ID.', array('maxlength' => 1000000000, 'minlength' => 1)); // we shouldn't have group IDs higher than a billion either
  25. $Validate->SetFields('subject', '0', 'string', 'Invalid subject.', array('maxlength' => 1000, 'minlength' => 1));
  26. $Validate->SetFields('message', '0', 'string', 'Invalid message.', array('maxlength' => 10000, 'minlength' => 1));
  27. $Err = $Validate->ValidateForm($_POST); // Validate the form
  28. if ($Err) {
  29. error($Err);
  30. header('Location: '.$_SERVER['HTTP_REFERER']);
  31. error();
  32. }
  33. //******************************************************************************//
  34. //--------------- Send PMs to users --------------------------------------------//
  35. $DB->query("
  36. SELECT uid
  37. FROM xbt_snatched
  38. WHERE fid = $TorrentID");
  39. if ($DB->has_results()) {
  40. // Save this because send_pm uses $DB to run its own query... Oops...
  41. $Snatchers = $DB->to_array();
  42. foreach ($Snatchers as $UserID) {
  43. Misc::send_pm($UserID[0], 0, $Subject, $Message);
  44. }
  45. }
  46. Misc::write_log($LoggedUser['Username']." sent mass notice to snatchers of torrent $TorrentID in group $GroupID");
  47. header("Location: torrents.php?id=$GroupID");