2011-03-28 14:21:28 +00:00
< ?
//******************************************************************************//
//--------------- Take unfill request ------------------------------------------//
authorize ();
$RequestID = $_POST [ 'id' ];
2013-04-21 08:00:52 +00:00
if ( ! is_number ( $RequestID )) {
2011-03-28 14:21:28 +00:00
error ( 0 );
}
2013-04-21 08:00:52 +00:00
$DB -> query ( "
SELECT
2011-03-28 14:21:28 +00:00
r . CategoryID ,
2013-02-19 08:00:30 +00:00
r . UserID ,
r . FillerID ,
2011-03-28 14:21:28 +00:00
r . Title ,
2012-02-05 08:00:20 +00:00
u . Uploaded ,
r . GroupID
2013-02-19 08:00:30 +00:00
FROM requests AS r
2013-07-10 00:08:53 +00:00
LEFT JOIN users_main AS u ON u . ID = FillerID
WHERE r . ID = $RequestID " );
2012-02-05 08:00:20 +00:00
list ( $CategoryID , $UserID , $FillerID , $Title , $Uploaded , $GroupID ) = $DB -> next_record ();
2011-03-28 14:21:28 +00:00
2013-07-11 08:00:55 +00:00
if ((( $LoggedUser [ 'ID' ] !== $UserID && $LoggedUser [ 'ID' ] !== $FillerID ) && ! check_perms ( 'site_moderate_requests' )) || $FillerID === '0' ) {
error ( 403 );
2011-03-28 14:21:28 +00:00
}
// Unfill
2013-04-21 08:00:52 +00:00
$DB -> query ( "
UPDATE requests
SET TorrentID = 0 ,
FillerID = 0 ,
TimeFilled = '0000-00-00 00:00:00' ,
Visible = 1
2013-07-10 00:08:53 +00:00
WHERE ID = $RequestID " );
2011-03-28 14:21:28 +00:00
$CategoryName = $Categories [ $CategoryID - 1 ];
2013-07-11 08:00:55 +00:00
if ( $CategoryName === 'Music' ) {
2013-05-13 08:00:33 +00:00
$ArtistForm = Requests :: get_artists ( $RequestID );
2012-10-11 08:00:15 +00:00
$ArtistName = Artists :: display_artists ( $ArtistForm , false , true );
2011-03-28 14:21:28 +00:00
$FullName = $ArtistName . $Title ;
} else {
$FullName = $Title ;
}
2013-05-13 08:00:33 +00:00
$RequestVotes = Requests :: get_votes_array ( $RequestID );
2011-03-28 14:21:28 +00:00
if ( $RequestVotes [ 'TotalBounty' ] > $Uploaded ) {
2011-11-06 08:00:31 +00:00
// If we can't take it all out of upload, zero that out and add whatever is left as download.
2013-07-10 00:08:53 +00:00
$DB -> query ( "
UPDATE users_main
SET Uploaded = 0
WHERE ID = $FillerID " );
$DB -> query ( '
UPDATE users_main
SET Downloaded = Downloaded + '.($RequestVotes[' TotalBounty ' ] - $Uploaded ) . "
WHERE ID = $FillerID " );
2011-03-28 14:21:28 +00:00
} else {
2013-07-10 00:08:53 +00:00
$DB -> query ( '
UPDATE users_main
SET Uploaded = Uploaded - '.$RequestVotes[' TotalBounty ' ] . "
WHERE ID = $FillerID " );
2011-03-28 14:21:28 +00:00
}
2013-06-03 08:00:52 +00:00
Misc :: send_pm ( $FillerID , 0 , 'A request you filled has been unfilled' , " The request \" [url=https:// " . SSL_SITE_URL . " /requests.php?action=view&id= $RequestID ] " . $FullName . " [/url] \" was unfilled by [url=https:// " . SSL_SITE_URL . '/user.php?id=' . $LoggedUser [ 'ID' ] . ']' . $LoggedUser [ 'Username' ] . '[/url] for the reason: ' . $_POST [ 'reason' ] . " \n \n If you feel like this request was unjustly unfilled, please [url=https:// " . SSL_SITE_URL . " /reports.php?action=report&type=request&id= $RequestID ]report the request[/url] and explain why this request should not have been unfilled. " );
2011-03-28 14:21:28 +00:00
2013-07-10 00:08:53 +00:00
$Cache -> delete_value ( " user_stats_ $FillerID " );
2011-03-28 14:21:28 +00:00
2013-07-11 08:00:55 +00:00
if ( $UserID !== $LoggedUser [ 'ID' ]) {
2013-04-21 08:00:52 +00:00
Misc :: send_pm ( $UserID , 0 , 'A request you created has been unfilled' , " The request \" [url=https:// " . SSL_SITE_URL . " /requests.php?action=view&id= $RequestID ] " . $FullName . " [/url] \" was unfilled by [url=https:// " . SSL_SITE_URL . '/user.php?id=' . $LoggedUser [ 'ID' ] . ']' . $LoggedUser [ 'Username' ] . " [/url] for the reason: " . $_POST [ 'reason' ]);
2011-03-28 14:21:28 +00:00
}
2013-04-21 08:00:52 +00:00
Misc :: write_log ( " Request $RequestID ( $FullName ), with a " . Format :: get_size ( $RequestVotes [ 'TotalBounty' ]) . ' bounty, was unfilled by user ' . $LoggedUser [ 'ID' ] . ' (' . $LoggedUser [ 'Username' ] . ') for the reason: ' . $_POST [ 'reason' ]);
2011-03-28 14:21:28 +00:00
2013-07-10 00:08:53 +00:00
$Cache -> delete_value ( " request_ $RequestID " );
$Cache -> delete_value ( " request_artists_ $RequestID " );
2012-02-05 08:00:20 +00:00
if ( $GroupID ) {
2013-07-10 00:08:53 +00:00
$Cache -> delete_value ( " requests_group_ $GroupID " );
2012-02-05 08:00:20 +00:00
}
2011-03-28 14:21:28 +00:00
2012-10-11 08:00:15 +00:00
Requests :: update_sphinx_requests ( $RequestID );
2011-03-28 14:21:28 +00:00
2013-04-21 08:00:52 +00:00
if ( ! empty ( $ArtistForm )) {
foreach ( $ArtistForm as $ArtistType ) {
foreach ( $ArtistType as $Artist ) {
2011-11-12 08:00:15 +00:00
$Cache -> delete_value ( 'artists_requests_' . $Artist [ 'id' ]);
}
}
}
2011-03-28 14:21:28 +00:00
2013-09-13 08:00:53 +00:00
$SphQL = new SphinxqlQuery ();
$SphQL -> raw_query ( " UPDATE requests, requests_delta SET torrentid = 0, fillerid = 0 WHERE id = $RequestID " , false );
2011-03-28 14:21:28 +00:00
2013-07-10 00:08:53 +00:00
header ( " Location: requests.php?action=view&id= $RequestID " );
2011-03-28 14:21:28 +00:00
?>