2011-03-28 14:21:28 +00:00
< ?
/*
2013-02-22 08:00:24 +00:00
* This is the backend of the AJAXy reports resolve ( When you press the shiny submit button ) .
2011-03-28 14:21:28 +00:00
* This page shouldn ' t output anything except in error , if you do want output , it will be put
* straight into the table where the report used to be . Currently output is only given when
* a collision occurs or a POST attack is detected .
*/
2013-05-04 08:00:48 +00:00
if ( ! check_perms ( 'admin_reports' )) {
2011-03-28 14:21:28 +00:00
error ( 403 );
}
authorize ();
//Don't escape: Log message, Admin message
$Escaped = db_array ( $_POST , array ( 'log_message' , 'admin_message' , 'raw_name' ));
//If we're here from the delete torrent page instead of the reports page.
2013-05-04 08:00:48 +00:00
if ( ! isset ( $Escaped [ 'from_delete' ])) {
2011-03-28 14:21:28 +00:00
$Report = true ;
2013-05-04 08:00:48 +00:00
} elseif ( ! is_number ( $Escaped [ 'from_delete' ])) {
2011-03-28 14:21:28 +00:00
echo 'Hax occured in from_delete' ;
} else {
$Report = false ;
}
$PMMessage = $_POST [ 'uploader_pm' ];
2013-05-04 08:00:48 +00:00
if ( is_number ( $Escaped [ 'reportid' ])) {
2011-03-28 14:21:28 +00:00
$ReportID = $Escaped [ 'reportid' ];
} else {
echo 'Hax occured in the reportid' ;
die ();
}
2013-05-04 08:00:48 +00:00
if ( $Escaped [ 'pm_type' ] != 'Uploader' ) {
2011-03-28 14:21:28 +00:00
$Escaped [ 'uploader_pm' ] = '' ;
}
$UploaderID = ( int ) $Escaped [ 'uploaderid' ];
2013-05-04 08:00:48 +00:00
if ( ! is_number ( $UploaderID )) {
2011-03-28 14:21:28 +00:00
echo 'Hax occuring on the uploaderid' ;
die ();
}
$Warning = ( int ) $Escaped [ 'warning' ];
2013-05-04 08:00:48 +00:00
if ( ! is_number ( $Warning )) {
2011-03-28 14:21:28 +00:00
echo 'Hax occuring on the warning' ;
die ();
}
$CategoryID = $Escaped [ 'categoryid' ];
2013-05-04 08:00:48 +00:00
if ( ! isset ( $CategoryID )) {
2011-03-28 14:21:28 +00:00
echo 'Hax occuring on the categoryid' ;
die ();
}
$TorrentID = $Escaped [ 'torrentid' ];
$RawName = $Escaped [ 'raw_name' ];
2013-05-04 08:00:48 +00:00
if (( $Escaped [ 'resolve_type' ] == " manual " || $Escaped [ 'resolve_type' ] == " dismiss " ) && $Report ) {
if ( $Escaped [ 'comment' ]) {
2011-03-28 14:21:28 +00:00
$Comment = $Escaped [ 'comment' ];
} else {
2013-05-04 08:00:48 +00:00
if ( $Escaped [ 'resolve_type' ] == " manual " ) {
2011-03-28 14:21:28 +00:00
$Comment = " Report was resolved manually " ;
2013-05-04 08:00:48 +00:00
} elseif ( $Escaped [ 'resolve_type' ] == " dismiss " ) {
2011-03-28 14:21:28 +00:00
$Comment = " Report was dismissed as invalid " ;
}
}
2013-02-22 08:00:24 +00:00
2013-05-04 08:00:48 +00:00
$DB -> query ( "
UPDATE reportsv2
SET
Status = 'Resolved' ,
LastChangeTime = '".sqltime()."' ,
ModComment = '".$Comment."' ,
ResolverID = '".$LoggedUser[' ID ']."'
WHERE ID = '".$ReportID."'
AND Status <> 'Resolved' " );
2013-02-22 08:00:24 +00:00
2013-05-04 08:00:48 +00:00
if ( $DB -> affected_rows () > 0 ) {
2011-03-28 14:21:28 +00:00
$Cache -> delete_value ( 'num_torrent_reportsv2' );
$Cache -> delete_value ( 'reports_torrent_' . $TorrentID );
} else {
//Someone beat us to it. Inform the staffer.
?>
2012-09-01 08:00:24 +00:00
< table class = " layout " cellpadding = " 5 " >
2011-03-28 14:21:28 +00:00
< tr >
< td >
< a href = " reportsv2.php?view=report&id=<?= $ReportID ?> " > Somebody has already resolved this report </ a >
< input type = " button " value = " Clear " onclick = " ClearReport(<?= $ReportID ?>); " />
</ td >
</ tr >
</ table >
< ?
}
die ();
}
2013-05-04 08:00:48 +00:00
if ( ! isset ( $Escaped [ 'resolve_type' ])) {
2011-03-28 14:21:28 +00:00
echo 'No resolve type' ;
die ();
2013-05-04 08:00:48 +00:00
} elseif ( array_key_exists ( $_POST [ 'resolve_type' ], $Types [ $CategoryID ])) {
2011-03-28 14:21:28 +00:00
$ResolveType = $Types [ $CategoryID ][ $_POST [ 'resolve_type' ]];
2013-05-04 08:00:48 +00:00
} elseif ( array_key_exists ( $_POST [ 'resolve_type' ], $Types [ 'master' ])) {
2011-03-28 14:21:28 +00:00
$ResolveType = $Types [ 'master' ][ $_POST [ 'resolve_type' ]];
} else {
//There was a type but it wasn't an option!
echo 'HAX (Invalid Resolve Type)' ;
die ();
}
$DB -> query ( " SELECT ID FROM torrents WHERE ID = " . $TorrentID );
$TorrentExists = ( $DB -> record_count () > 0 );
2013-05-04 08:00:48 +00:00
if ( ! $TorrentExists ) {
$DB -> query ( "
UPDATE reportsv2
2011-03-28 14:21:28 +00:00
SET Status = 'Resolved' ,
2013-05-04 08:00:48 +00:00
LastChangeTime = '".sqltime()."' ,
ResolverID = '".$LoggedUser[' ID ']."' ,
ModComment = 'Report already dealt with (Torrent deleted)'
WHERE ID = " . $ReportID );
2011-03-28 14:21:28 +00:00
$Cache -> decrement ( 'num_torrent_reportsv2' );
}
2013-05-04 08:00:48 +00:00
if ( $Report ) {
2011-03-28 14:21:28 +00:00
//Resolve with a parallel check
2013-05-04 08:00:48 +00:00
$DB -> query ( "
UPDATE reportsv2
2011-03-28 14:21:28 +00:00
SET Status = 'Resolved' ,
LastChangeTime = '".sqltime()."' ,
ResolverID = '".$LoggedUser[' ID ']."'
WHERE ID = " . $ReportID . "
AND Status <> 'Resolved' " );
}
//See if it we managed to resolve
2013-05-04 08:00:48 +00:00
if ( $DB -> affected_rows () > 0 || ! $Report ) {
2011-03-28 14:21:28 +00:00
//We did, lets do all our shit
2013-05-04 08:00:48 +00:00
if ( $Report ) {
$Cache -> decrement ( 'num_torrent_reportsv2' );
}
2011-03-28 14:21:28 +00:00
2013-02-22 08:00:24 +00:00
2013-05-04 08:00:48 +00:00
if ( isset ( $Escaped [ 'upload' ])) {
2011-03-28 14:21:28 +00:00
$Upload = true ;
} else {
$Upload = false ;
}
2013-05-04 08:00:48 +00:00
if ( $_POST [ 'resolve_type' ] == " tags_lots " ) {
2011-03-28 14:21:28 +00:00
$DB -> query ( " INSERT IGNORE INTO torrents_bad_tags (TorrentID, UserID, TimeAdded) VALUES ( " . $TorrentID . " , " . $LoggedUser [ 'ID' ] . " , ' " . sqltime () . " ') " );
$DB -> query ( " SELECT GroupID FROM torrents WHERE ID = " . $TorrentID );
list ( $GroupID ) = $DB -> next_record ();
$Cache -> delete_value ( 'torrents_details_' . $GroupID );
$SendPM = true ;
}
2013-05-04 08:00:48 +00:00
if ( $_POST [ 'resolve_type' ] == " folders_bad " ) {
2011-03-28 14:21:28 +00:00
$DB -> query ( " INSERT IGNORE INTO torrents_bad_folders (TorrentID, UserID, TimeAdded) VALUES ( " . $TorrentID . " , " . $LoggedUser [ 'ID' ] . " , ' " . sqltime () . " ') " );
$DB -> query ( " SELECT GroupID FROM torrents WHERE ID = " . $TorrentID );
list ( $GroupID ) = $DB -> next_record ();
$Cache -> delete_value ( 'torrents_details_' . $GroupID );
$SendPM = true ;
}
2013-05-04 08:00:48 +00:00
if ( $_POST [ 'resolve_type' ] == " filename " ) {
2011-03-28 14:21:28 +00:00
$DB -> query ( " INSERT IGNORE INTO torrents_bad_files (TorrentID, UserID, TimeAdded) VALUES ( " . $TorrentID . " , " . $LoggedUser [ 'ID' ] . " , ' " . sqltime () . " ') " );
$DB -> query ( " SELECT GroupID FROM torrents WHERE ID = " . $TorrentID );
list ( $GroupID ) = $DB -> next_record ();
$Cache -> delete_value ( 'torrents_details_' . $GroupID );
$SendPM = true ;
}
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
//Log and delete
2013-05-04 08:00:48 +00:00
if ( isset ( $Escaped [ 'delete' ]) && check_perms ( 'users_mod' )) {
2011-03-28 14:21:28 +00:00
$DB -> query ( " SELECT Username FROM users_main WHERE ID = " . $UploaderID );
list ( $UpUsername ) = $DB -> next_record ();
$Log = " Torrent " . $TorrentID . " ( " . $RawName . " ) uploaded by " . $UpUsername . " was deleted by " . $LoggedUser [ 'Username' ];
$Log .= ( $Escaped [ 'resolve_type' ] == 'custom' ? " " : " for the reason: " . $ResolveType [ 'title' ] . " . " );
2013-05-04 08:00:48 +00:00
if ( isset ( $Escaped [ 'log_message' ]) && $Escaped [ 'log_message' ] != " " ) {
2011-03-28 14:21:28 +00:00
$Log .= " ( " . $Escaped [ 'log_message' ] . " ) " ;
}
2012-08-03 08:00:17 +00:00
$DB -> query ( " SELECT GroupID, hex(info_hash) FROM torrents WHERE ID = " . $TorrentID );
list ( $GroupID , $InfoHash ) = $DB -> next_record ();
2012-10-11 08:00:15 +00:00
Torrents :: delete_torrent ( $TorrentID , 0 , $ResolveType [ 'reason' ]);
2013-02-22 08:00:24 +00:00
2012-08-03 08:00:17 +00:00
//$InfoHash = unpack("H*", $InfoHash);
$Log .= " ( " . strtoupper ( $InfoHash ) . " ) " ;
2012-10-11 08:00:15 +00:00
Misc :: write_log ( $Log );
2012-01-26 08:00:25 +00:00
$Log = " deleted torrent for the reason: " . $ResolveType [ 'title' ] . " . ( " . $Escaped [ 'log_message' ] . " ) " ;
2012-10-11 08:00:15 +00:00
Torrents :: write_group_log ( $GroupID , $TorrentID , $LoggedUser [ 'ID' ], $Log , 0 );
2011-03-28 14:21:28 +00:00
} else {
$Log = " No log message (Torrent wasn't deleted) " ;
}
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
//Warnings / remove upload
2013-05-04 08:00:48 +00:00
if ( $Upload ) {
2011-03-28 14:21:28 +00:00
$Cache -> begin_transaction ( 'user_info_heavy_' . $UploaderID );
$Cache -> update_row ( false , array ( 'DisableUpload' => '1' ));
$Cache -> commit_transaction ( 0 );
2013-02-22 08:00:24 +00:00
2013-05-04 08:00:48 +00:00
$DB -> query ( "
UPDATE users_info
SET DisableUpload = '1'
2011-03-28 14:21:28 +00:00
WHERE UserID = " . $UploaderID );
}
2013-02-22 08:00:24 +00:00
2013-05-04 08:00:48 +00:00
if ( $Warning > 0 ) {
$WarnLength = $Warning * ( 7 * 24 * 60 * 60 );
2011-10-13 08:00:12 +00:00
$Reason = " Uploader of torrent ( " . $TorrentID . " ) " . $RawName . " which was resolved with the preset: " . $ResolveType [ 'title' ] . " . " ;
2013-05-04 08:00:48 +00:00
if ( $Escaped [ 'admin_message' ]) {
2011-03-28 14:21:28 +00:00
$Reason .= " ( " . $Escaped [ 'admin_message' ] . " ). " ;
}
2013-05-04 08:00:48 +00:00
if ( $Upload ) {
2011-03-28 14:21:28 +00:00
$Reason .= " (Upload privileges Removed). " ;
}
2012-10-11 08:00:15 +00:00
Tools :: warn_user ( $UploaderID , $WarnLength , $Reason );
2011-03-28 14:21:28 +00:00
} else {
//This is a bitch for people that don't warn but do other things, it makes me sad.
2013-04-19 08:00:55 +00:00
$AdminComment = '' ;
2013-05-04 08:00:48 +00:00
if ( $Upload ) {
2011-03-28 14:21:28 +00:00
//They removed upload
$AdminComment .= " Upload privileges removed by " . $LoggedUser [ 'Username' ];
$AdminComment .= " \n Reason: Uploader of torrent ( " . $TorrentID . " ) " . db_string ( $RawName ) . " which was resolved with the preset: " . $ResolveType [ 'title' ] . " . (Report ID: $ReportID ) " ;
}
2013-05-04 08:00:48 +00:00
if ( $Escaped [ 'admin_message' ]) {
2011-03-28 14:21:28 +00:00
//They did nothing of note, but still want to mark it (Or upload and mark)
$AdminComment .= " ( " . $Escaped [ 'admin_message' ] . " ) " ;
}
2013-05-04 08:00:48 +00:00
if ( $AdminComment ) {
2011-03-28 14:21:28 +00:00
$AdminComment = date ( " Y-m-d " ) . ' - ' . $AdminComment . " \n \n " ;
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
$DB -> query ( " UPDATE users_info SET
AdminComment = CONCAT ( '".db_string($AdminComment)."' , AdminComment )
WHERE UserID = '".db_string($UploaderID)."' " );
}
}
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
//PM
2013-05-04 08:00:48 +00:00
if ( $Escaped [ 'uploader_pm' ] || $Warning > 0 || isset ( $Escaped [ 'delete' ]) || $SendPM ) {
if ( isset ( $Escaped [ 'delete' ])) {
2013-04-19 08:00:55 +00:00
$PM = '[url=https://' . SSL_SITE_URL . " /torrents.php?torrentid= " . $TorrentID . " ]Your above torrent[/url] was reported and has been deleted. \n \n " ;
2011-03-28 14:21:28 +00:00
} else {
2013-04-19 08:00:55 +00:00
$PM = '[url=https://' . SSL_SITE_URL . " /torrents.php?torrentid= " . $TorrentID . " ]Your above torrent[/url] was reported but not deleted. \n \n " ;
2011-03-28 14:21:28 +00:00
}
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
$Preset = $ResolveType [ 'resolve_options' ][ 'pm' ];
2013-02-22 08:00:24 +00:00
2013-05-04 08:00:48 +00:00
if ( $Preset != '' ) {
2011-03-28 14:21:28 +00:00
$PM .= " Reason: " . $Preset ;
}
2013-02-22 08:00:24 +00:00
2013-05-04 08:00:48 +00:00
if ( $Warning > 0 ) {
2013-04-19 08:00:55 +00:00
$PM .= " \n This has resulted in a [url=https:// " . SSL_SITE_URL . " /wiki.php?action=article&id=218] " . $Warning . " week warning.[/url] \n " ;
2011-03-28 14:21:28 +00:00
}
2013-02-22 08:00:24 +00:00
2013-05-04 08:00:48 +00:00
if ( $Upload ) {
2011-03-28 14:21:28 +00:00
$PM .= " This has " . ( $Warning > 0 ? 'also ' : '' ) . " resulted in you losing your upload privileges. " ;
}
2013-05-04 08:00:48 +00:00
if ( $Log ) {
2011-03-28 14:21:28 +00:00
$PM = $PM . " \n Log Message: " . $Log . " \n " ;
}
2013-02-22 08:00:24 +00:00
2013-05-04 08:00:48 +00:00
if ( $Escaped [ 'uploader_pm' ]) {
2013-02-22 08:00:24 +00:00
$PM .= " \n Message from " . $LoggedUser [ 'Username' ] . " : " . $PMMessage ;
2011-03-28 14:21:28 +00:00
}
2013-02-22 08:00:24 +00:00
2012-01-19 08:00:18 +00:00
$PM .= " \n \n Report was handled by [user] " . $LoggedUser [ 'Username' ] . " [/user]. " ;
2013-02-22 08:00:24 +00:00
2013-03-10 08:00:41 +00:00
Misc :: send_pm ( $UploaderID , 0 , $Escaped [ 'raw_name' ], $PM );
2011-03-28 14:21:28 +00:00
}
$Cache -> delete_value ( 'reports_torrent_' . $TorrentID );
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
//Now we've done everything, update the DB with values
2013-05-04 08:00:48 +00:00
if ( $Report ) {
2011-03-28 14:21:28 +00:00
$DB -> query ( " UPDATE reportsv2 SET
Type = '".$Escaped[' resolve_type ']."' ,
LogMessage = '".db_string($Log)."' ,
ModComment = '".$Escaped[' comment ']."'
WHERE ID = " . $ReportID );
}
} else {
//Someone beat us to it. Inform the staffer.
?>
2012-09-01 08:00:24 +00:00
< table class = " layout " cellpadding = " 5 " >
2011-03-28 14:21:28 +00:00
< tr >
< td >
< a href = " reportsv2.php?view=report&id=<?= $ReportID ?> " > Somebody has already resolved this report </ a >
< input type = " button " value = " Clear " onclick = " ClearReport(<?= $ReportID ?>); " />
</ td >
</ tr >
</ table >
< ?
}
?>