Gazelle/sections/reportsv2/ajax_take_pm.php

74 lines
1.9 KiB
PHP
Raw Normal View History

2011-03-28 14:21:28 +00:00
<?
/*
* This is the AJAX backend for the SendNow() function.
*/
authorize();
2013-05-04 08:00:48 +00:00
if (!check_perms('admin_reports')) {
2011-03-28 14:21:28 +00:00
die();
}
$Recipient = $_POST['pm_type'];
$TorrentID = $_POST['torrentid'];
2013-05-04 08:00:48 +00:00
if (isset($_POST['uploader_pm']) && $_POST['uploader_pm'] != '') {
2011-03-28 14:21:28 +00:00
$Message = $_POST['uploader_pm'];
} else {
//No message given
die();
}
2013-05-04 08:00:48 +00:00
if (!is_number($_POST['categoryid']) || !is_number($TorrentID)) {
2013-11-01 08:01:02 +00:00
echo 'Hax on category ID!';
2011-03-28 14:21:28 +00:00
die();
} else {
$CategoryID = $_POST['categoryid'];
}
if (array_key_exists($_POST['type'], $Types[$CategoryID])) {
$ReportType = $Types[$CategoryID][$_POST['type']];
2013-09-15 08:00:53 +00:00
} elseif (array_key_exists($_POST['type'], $Types['master'])) {
2011-03-28 14:21:28 +00:00
$ReportType = $Types['master'][$_POST['type']];
} else {
//There was a type but it wasn't an option!
2013-11-01 08:01:02 +00:00
echo 'Hax on section type';
2011-03-28 14:21:28 +00:00
die();
}
2013-05-04 08:00:48 +00:00
if (!isset($_POST['from_delete'])) {
2011-03-28 14:21:28 +00:00
$Report = true;
2013-09-15 08:00:53 +00:00
} elseif (!is_number($_POST['from_delete'])) {
2013-11-01 08:01:02 +00:00
echo 'Hax occurred in from_delete';
2011-03-28 14:21:28 +00:00
}
2013-05-04 08:00:48 +00:00
if ($Recipient == 'Uploader') {
2011-03-28 14:21:28 +00:00
$ToID = $_POST['uploaderid'];
2013-05-04 08:00:48 +00:00
if ($Report) {
2014-02-27 08:00:30 +00:00
$Message = "You uploaded [url=".site_url()."torrents.php?torrentid=$TorrentID]the above torrent[/url]. It has been reported for the reason: ".$ReportType['title']."\n\n$Message";
2011-03-28 14:21:28 +00:00
} else {
2014-02-27 08:00:30 +00:00
$Message = "I am PMing you as you are the uploader of [url=".site_url()."torrents.php?torrentid=$TorrentID]the above torrent[/url].\n\n$Message";
2011-03-28 14:21:28 +00:00
}
2013-09-15 08:00:53 +00:00
} elseif ($Recipient == 'Reporter') {
2011-03-28 14:21:28 +00:00
$ToID = $_POST['reporterid'];
2014-02-27 08:00:30 +00:00
$Message = "You reported [url=".site_url()."torrents.php?torrentid=$TorrentID]the above torrent[/url] for the reason ".$ReportType['title'].":\n[quote]".$_POST['report_reason']."[/quote]\n$Message";
2011-03-28 14:21:28 +00:00
} else {
$Err = "Something went horribly wrong";
}
$Subject = $_POST['raw_name'];
2013-05-04 08:00:48 +00:00
if (!is_number($ToID)) {
2013-11-01 08:01:02 +00:00
$Err = "Haxx occurring, non-number present";
2011-03-28 14:21:28 +00:00
}
2013-05-04 08:00:48 +00:00
if ($ToID == $LoggedUser['ID']) {
2011-03-28 14:21:28 +00:00
$Err = "That's you!";
}
2013-05-04 08:00:48 +00:00
if (isset($Err)) {
2011-03-28 14:21:28 +00:00
echo $Err;
} else {
2013-03-10 08:00:41 +00:00
Misc::send_pm($ToID, $LoggedUser['ID'], $Subject, $Message);
2011-03-28 14:21:28 +00:00
}