2011-03-28 14:21:28 +00:00
< ?
//******************************************************************************//
//--------------- Take edit ----------------------------------------------------//
2013-02-07 08:00:47 +00:00
// This pages handles the backend of the 'edit torrent' function. It checks //
// the data, and if it all validates, it edits the values in the database //
// that correspond to the torrent in question. //
2011-03-28 14:21:28 +00:00
//******************************************************************************//
enforce_login ();
authorize ();
2013-05-27 08:00:58 +00:00
require ( SERVER_ROOT . '/classes/validate.class.php' );
2012-07-11 08:00:16 +00:00
2011-03-28 14:21:28 +00:00
$Validate = new VALIDATE ;
//******************************************************************************//
//--------------- Set $Properties array ----------------------------------------//
2013-02-07 08:00:47 +00:00
// This is used if the form doesn't validate, and when the time comes to enter //
// it into the database. //
2011-03-28 14:21:28 +00:00
//******************************************************************************//
$Properties = array ();
$TypeID = ( int ) $_POST [ 'type' ];
$Type = $Categories [ $TypeID - 1 ];
$TorrentID = ( int ) $_POST [ 'torrentid' ];
$Properties [ 'Remastered' ] = ( isset ( $_POST [ 'remaster' ])) ? 1 : 0 ;
2013-04-30 18:18:07 +00:00
if ( $Properties [ 'Remastered' ]) {
2011-03-28 14:21:28 +00:00
$Properties [ 'UnknownRelease' ] = ( isset ( $_POST [ 'unknown' ])) ? 1 : 0 ;
$Properties [ 'RemasterYear' ] = $_POST [ 'remaster_year' ];
$Properties [ 'RemasterTitle' ] = $_POST [ 'remaster_title' ];
$Properties [ 'RemasterRecordLabel' ] = $_POST [ 'remaster_record_label' ];
$Properties [ 'RemasterCatalogueNumber' ] = $_POST [ 'remaster_catalogue_number' ];
}
2013-04-30 18:18:07 +00:00
if ( ! $Properties [ 'Remastered' ]) {
2011-03-28 14:21:28 +00:00
$Properties [ 'UnknownRelease' ] = 0 ;
$Properties [ 'RemasterYear' ] = '' ;
$Properties [ 'RemasterTitle' ] = '' ;
$Properties [ 'RemasterRecordLabel' ] = '' ;
$Properties [ 'RemasterCatalogueNumber' ] = '' ;
}
$Properties [ 'Scene' ] = ( isset ( $_POST [ 'scene' ])) ? 1 : 0 ;
$Properties [ 'HasLog' ] = ( isset ( $_POST [ 'flac_log' ])) ? 1 : 0 ;
$Properties [ 'HasCue' ] = ( isset ( $_POST [ 'flac_cue' ])) ? 1 : 0 ;
$Properties [ 'BadTags' ] = ( isset ( $_POST [ 'bad_tags' ])) ? 1 : 0 ;
$Properties [ 'BadFolders' ] = ( isset ( $_POST [ 'bad_folders' ])) ? 1 : 0 ;
$Properties [ 'BadFiles' ] = ( isset ( $_POST [ 'bad_files' ])) ? 1 : 0 ;
2011-08-09 21:03:28 +00:00
$Properties [ 'CassetteApproved' ] = ( isset ( $_POST [ 'cassette_approved' ])) ? 1 : 0 ;
$Properties [ 'LossymasterApproved' ] = ( isset ( $_POST [ 'lossymaster_approved' ])) ? 1 : 0 ;
2012-05-31 08:00:14 +00:00
$Properties [ 'LossywebApproved' ] = ( isset ( $_POST [ 'lossyweb_approved' ])) ? 1 : 0 ;
2012-03-08 08:00:24 +00:00
$Properties [ 'LibraryUpload' ] = ( isset ( $_POST [ 'library_upload' ])) ? 1 : 0 ;
$Properties [ 'LibraryPoints' ] = ( isset ( $_POST [ 'library_points' ])) ? $_POST [ 'library_points' ] : 0 ;
2011-03-28 14:21:28 +00:00
$Properties [ 'Format' ] = $_POST [ 'format' ];
$Properties [ 'Media' ] = $_POST [ 'media' ];
$Properties [ 'Bitrate' ] = $_POST [ 'bitrate' ];
$Properties [ 'Encoding' ] = $_POST [ 'bitrate' ];
$Properties [ 'Trumpable' ] = ( isset ( $_POST [ 'make_trumpable' ])) ? 1 : 0 ;
$Properties [ 'TorrentDescription' ] = $_POST [ 'release_desc' ];
$Properties [ 'Name' ] = $_POST [ 'title' ];
2013-04-30 18:18:07 +00:00
if ( $_POST [ 'album_desc' ]) {
2011-03-28 14:21:28 +00:00
$Properties [ 'GroupDescription' ] = $_POST [ 'album_desc' ];
}
2013-04-30 18:18:07 +00:00
if ( check_perms ( 'torrents_freeleech' )) {
2011-04-13 15:36:33 +00:00
$Free = ( int ) $_POST [ 'freeleech' ];
2013-07-04 08:00:56 +00:00
if ( ! in_array ( $Free , array ( 0 , 1 , 2 ))) {
2011-04-13 15:36:33 +00:00
error ( 404 );
}
$Properties [ 'FreeLeech' ] = $Free ;
2011-07-10 08:00:06 +00:00
2013-04-30 18:18:07 +00:00
if ( $Free == 0 ) {
2011-07-10 08:00:06 +00:00
$FreeType = 0 ;
} else {
$FreeType = ( int ) $_POST [ 'freeleechtype' ];
2013-07-04 08:00:56 +00:00
if ( ! in_array ( $Free , array ( 0 , 1 , 2 , 3 ))) {
2011-07-10 08:00:06 +00:00
error ( 404 );
}
}
$Properties [ 'FreeLeechType' ] = $FreeType ;
2011-03-28 14:21:28 +00:00
}
//******************************************************************************//
//--------------- Validate data in edit form -----------------------------------//
2013-07-04 08:00:56 +00:00
$DB -> query ( "
SELECT UserID , Remastered , RemasterYear , FreeTorrent
FROM torrents
WHERE ID = $TorrentID " );
2013-07-10 00:08:53 +00:00
if ( ! $DB -> has_results ()) {
2012-06-03 08:00:14 +00:00
error ( 404 );
}
2011-07-10 08:00:06 +00:00
list ( $UserID , $Remastered , $RemasterYear , $CurFreeLeech ) = $DB -> next_record ( MYSQLI_BOTH , false );
2011-03-28 14:21:28 +00:00
2013-04-30 18:18:07 +00:00
if ( $LoggedUser [ 'ID' ] != $UserID && ! check_perms ( 'torrents_edit' )) {
2011-03-28 14:21:28 +00:00
error ( 403 );
}
2013-04-30 18:18:07 +00:00
if ( $Remastered == '1' && ! $RemasterYear && ! check_perms ( 'edit_unknowns' )) {
2011-03-28 14:21:28 +00:00
error ( 403 );
}
2013-04-30 18:18:07 +00:00
if ( $Properties [ 'UnknownRelease' ] && ! ( $Remastered == '1' && ! $RemasterYear ) && ! check_perms ( 'edit_unknowns' )) {
2011-03-28 14:21:28 +00:00
//It's Unknown now, and it wasn't before
2013-04-30 18:18:07 +00:00
if ( $LoggedUser [ 'ID' ] != $UserID ) {
2011-03-28 14:21:28 +00:00
//Hax
die ();
}
}
2013-07-10 00:08:53 +00:00
$Validate -> SetFields ( 'type' , '1' , 'number' , 'Not a valid type.' , array ( 'maxlength' => count ( $Categories ), 'minlength' => 1 ));
2011-03-28 14:21:28 +00:00
switch ( $Type ) {
case 'Music' :
2013-04-30 18:18:07 +00:00
if ( ! empty ( $Properties [ 'Remastered' ]) && ! $Properties [ 'UnknownRelease' ]) {
2011-03-28 14:21:28 +00:00
$Validate -> SetFields ( 'remaster_year' , '1' , 'number' , 'Year of remaster/re-issue must be entered.' );
} else {
$Validate -> SetFields ( 'remaster_year' , '0' , 'number' , 'Invalid remaster year.' );
}
if ( ! empty ( $Properties [ 'Remastered' ]) && ! $Properties [ 'UnknownRelease' ] && $Properties [ 'RemasterYear' ] < 1982 && $Properties [ 'Media' ] == 'CD' ) {
2013-07-10 00:08:53 +00:00
error ( 'You have selected a year for an album that predates the medium you say it was created on.' );
2011-03-28 14:21:28 +00:00
header ( " Location: torrents.php?action=edit&id= $TorrentID " );
die ();
}
2013-02-16 08:00:57 +00:00
2013-07-10 00:08:53 +00:00
$Validate -> SetFields ( 'remaster_title' , '0' , 'string' , 'Remaster title must be between 2 and 80 characters.' , array ( 'maxlength' => 80 , 'minlength' => 2 ));
2011-03-28 14:21:28 +00:00
if ( $Properties [ 'RemasterTitle' ] == 'Original Release' ) {
error ( '"Original Release" is not a valid remaster title.' );
header ( " Location: torrents.php?action=edit&id= $TorrentID " );
die ();
}
2013-02-16 08:00:57 +00:00
2013-07-10 00:08:53 +00:00
$Validate -> SetFields ( 'remaster_record_label' , '0' , 'string' , 'Remaster record label must be between 2 and 80 characters.' , array ( 'maxlength' => 80 , 'minlength' => 2 ));
2013-02-16 08:00:57 +00:00
2013-07-10 00:08:53 +00:00
$Validate -> SetFields ( 'remaster_catalogue_number' , '0' , 'string' , 'Remaster catalogue number must be between 2 and 80 characters.' , array ( 'maxlength' => 80 , 'minlength' => 2 ));
2013-02-16 08:00:57 +00:00
2013-07-10 00:08:53 +00:00
$Validate -> SetFields ( 'format' , '1' , 'inarray' , 'Not a valid format.' , array ( 'inarray' => $Formats ));
2013-02-16 08:00:57 +00:00
2013-07-10 00:08:53 +00:00
$Validate -> SetFields ( 'bitrate' , '1' , 'inarray' , 'You must choose a bitrate.' , array ( 'inarray' => $Bitrates ));
2013-02-16 08:00:57 +00:00
2011-03-28 14:21:28 +00:00
// Handle 'other' bitrates
2013-04-30 18:18:07 +00:00
if ( $Properties [ 'Encoding' ] == 'Other' ) {
2013-07-10 00:08:53 +00:00
$Validate -> SetFields ( 'other_bitrate' , '1' , 'text' , 'You must enter the other bitrate (max length: 9 characters).' , array ( 'maxlength' => 9 ));
2011-03-28 14:21:28 +00:00
$enc = trim ( $_POST [ 'other_bitrate' ]);
2013-04-30 18:18:07 +00:00
if ( isset ( $_POST [ 'vbr' ])) {
2013-07-10 00:08:53 +00:00
$enc .= ' (VBR)' ;
2013-04-30 18:18:07 +00:00
}
2013-02-16 08:00:57 +00:00
2011-03-28 14:21:28 +00:00
$Properties [ 'Encoding' ] = $enc ;
$Properties [ 'Bitrate' ] = $enc ;
} else {
2013-07-10 00:08:53 +00:00
$Validate -> SetFields ( 'bitrate' , '1' , 'inarray' , 'You must choose a bitrate.' , array ( 'inarray' => $Bitrates ));
2011-03-28 14:21:28 +00:00
}
2013-02-16 08:00:57 +00:00
2013-07-10 00:08:53 +00:00
$Validate -> SetFields ( 'media' , '1' , 'inarray' , 'Not a valid media.' , array ( 'inarray' => $Media ));
2013-02-16 08:00:57 +00:00
2013-07-10 00:08:53 +00:00
$Validate -> SetFields ( 'release_desc' , '0' , 'string' , 'Invalid release description.' , array ( 'maxlength' => 1000000 , 'minlength' => 0 ));
2013-02-16 08:00:57 +00:00
2011-03-28 14:21:28 +00:00
break ;
2013-02-16 08:00:57 +00:00
2011-03-28 14:21:28 +00:00
case 'Audiobooks' :
case 'Comedy' :
2013-07-10 00:08:53 +00:00
/* $Validate -> SetFields ( 'title' , '1' , 'string' , 'Title must be between 2 and 300 characters.' , array ( 'maxlength' => 300 , 'minlength' => 2 ));
2011-04-17 11:05:01 +00:00
^ this is commented out because there is no title field on these pages */
2013-07-10 00:08:53 +00:00
$Validate -> SetFields ( 'year' , '1' , 'number' , 'The year of the release must be entered.' );
2013-02-16 08:00:57 +00:00
2013-07-10 00:08:53 +00:00
$Validate -> SetFields ( 'format' , '1' , 'inarray' , 'Not a valid format.' , array ( 'inarray' => $Formats ));
2013-02-16 08:00:57 +00:00
2013-07-10 00:08:53 +00:00
$Validate -> SetFields ( 'bitrate' , '1' , 'inarray' , 'You must choose a bitrate.' , array ( 'inarray' => $Bitrates ));
2013-02-16 08:00:57 +00:00
2011-03-28 14:21:28 +00:00
// Handle 'other' bitrates
2013-04-30 18:18:07 +00:00
if ( $Properties [ 'Encoding' ] == 'Other' ) {
2013-07-10 00:08:53 +00:00
$Validate -> SetFields ( 'other_bitrate' , '1' , 'text' , 'You must enter the other bitrate (max length: 9 characters).' , array ( 'maxlength' => 9 ));
2011-03-28 14:21:28 +00:00
$enc = trim ( $_POST [ 'other_bitrate' ]);
2013-04-30 18:18:07 +00:00
if ( isset ( $_POST [ 'vbr' ])) {
2013-07-10 00:08:53 +00:00
$enc .= ' (VBR)' ;
2013-04-30 18:18:07 +00:00
}
2013-02-16 08:00:57 +00:00
2011-03-28 14:21:28 +00:00
$Properties [ 'Encoding' ] = $enc ;
$Properties [ 'Bitrate' ] = $enc ;
} else {
2013-07-10 00:08:53 +00:00
$Validate -> SetFields ( 'bitrate' , '1' , 'inarray' , 'You must choose a bitrate.' , array ( 'inarray' => $Bitrates ));
2011-03-28 14:21:28 +00:00
}
2013-02-16 08:00:57 +00:00
2013-07-10 00:08:53 +00:00
$Validate -> SetFields ( 'release_desc' , '0' , 'string' , 'The release description has a minimum length of 10 characters.' , array ( 'maxlength' => 1000000 , 'minlength' => 10 ));
2013-02-16 08:00:57 +00:00
2011-03-28 14:21:28 +00:00
break ;
2013-02-16 08:00:57 +00:00
2011-03-28 14:21:28 +00:00
case 'Applications' :
case 'Comics' :
case 'E-Books' :
case 'E-Learning Videos' :
2013-07-10 00:08:53 +00:00
/* $Validate -> SetFields ( 'title' , '1' , 'string' , 'Title must be between 2 and 300 characters.' , array ( 'maxlength' => 300 , 'minlength' => 2 ));
2011-03-28 14:21:28 +00:00
^ this is commented out because there is no title field on these pages */
break ;
}
$Err = $Validate -> ValidateForm ( $_POST ); // Validate the form
2013-04-30 18:18:07 +00:00
if ( $Properties [ 'Remastered' ] && ! $Properties [ 'RemasterYear' ]) {
2011-03-28 14:21:28 +00:00
//Unknown Edit!
2013-04-30 18:18:07 +00:00
if ( $LoggedUser [ 'ID' ] == $UserID || check_perms ( 'edit_unknowns' )) {
2011-03-28 14:21:28 +00:00
//Fine!
} else {
2013-07-10 00:08:53 +00:00
$Err = " You may not edit someone else's upload to unknown release. " ;
2011-03-28 14:21:28 +00:00
}
}
2012-12-21 08:00:21 +00:00
// Strip out Amazon's padding
2011-11-22 08:00:17 +00:00
$AmazonReg = '/(http:\/\/ecx.images-amazon.com\/images\/.+)(\._.*_\.jpg)/i' ;
$Matches = array ();
if ( preg_match ( $RegX , $Properties [ 'Image' ], $Matches )) {
$Properties [ 'Image' ] = $Matches [ 1 ] . '.jpg' ;
}
2013-02-25 21:16:55 +00:00
ImageTools :: blacklisted ( $Properties [ 'Image' ]);
2011-11-22 08:00:17 +00:00
2013-04-30 18:18:07 +00:00
if ( $Err ) { // Show the upload form, with the data the user entered
if ( check_perms ( 'site_debug' )) {
2011-03-28 14:21:28 +00:00
die ( $Err );
}
error ( $Err );
}
//******************************************************************************//
//--------------- Make variables ready for database input ----------------------//
// Shorten and escape $Properties for database input
$T = array ();
foreach ( $Properties as $Key => $Value ) {
2013-04-30 18:18:07 +00:00
$T [ $Key ] = " ' " . db_string ( trim ( $Value )) . " ' " ;
if ( ! $T [ $Key ]) {
2013-10-15 08:01:05 +00:00
$T [ $Key ] = null ;
2011-03-28 14:21:28 +00:00
}
}
//******************************************************************************//
//--------------- Start database stuff -----------------------------------------//
$DBTorVals = array ();
2013-07-04 08:00:56 +00:00
$DB -> query ( "
SELECT Media , Format , Encoding , RemasterYear , Remastered , RemasterTItle , RemasterRecordLabel , RemasterCatalogueNumber , Scene , Description
FROM torrents
WHERE ID = $TorrentID " );
2011-03-28 14:21:28 +00:00
$DBTorVals = $DB -> to_array ( false , MYSQLI_ASSOC );
$DBTorVals = $DBTorVals [ 0 ];
2013-07-04 08:00:56 +00:00
$LogDetails = '' ;
2011-03-28 14:21:28 +00:00
foreach ( $DBTorVals as $Key => $Value ) {
2013-07-04 08:00:56 +00:00
$Value = " ' $Value ' " ;
2011-03-28 14:21:28 +00:00
if ( $Value != $T [ $Key ]) {
if ( ! isset ( $T [ $Key ])) {
continue ;
}
if (( empty ( $Value ) && empty ( $T [ $Key ])) || ( $Value == " '0' " && $T [ $Key ] == " '' " )) {
continue ;
}
2013-07-04 08:00:56 +00:00
if ( $LogDetails == '' ) {
$LogDetails = " $Key : $Value -> " . $T [ $Key ];
2011-03-28 14:21:28 +00:00
} else {
2013-07-04 08:00:56 +00:00
$LogDetails = " $LogDetails , $Key : $Value -> " . $T [ $Key ];
2011-03-28 14:21:28 +00:00
}
}
}
// Update info for the torrent
$SQL = "
2013-07-04 08:00:56 +00:00
UPDATE torrents
SET
Media = $T [ Media ],
Format = $T [ Format ],
Encoding = $T [ Encoding ],
RemasterYear = $T [ RemasterYear ],
Remastered = $T [ Remastered ],
RemasterTitle = $T [ RemasterTitle ],
RemasterRecordLabel = $T [ RemasterRecordLabel ],
RemasterCatalogueNumber = $T [ RemasterCatalogueNumber ],
2013-08-28 23:08:41 +00:00
Scene = $T [ Scene ], " ;
2011-03-28 14:21:28 +00:00
2013-04-30 18:18:07 +00:00
if ( check_perms ( 'torrents_freeleech' )) {
2013-07-04 08:00:56 +00:00
$SQL .= " FreeTorrent = $T[FreeLeech] , " ;
$SQL .= " FreeLeechType = $T[FreeLeechType] , " ;
2011-03-28 14:21:28 +00:00
}
2013-04-30 18:18:07 +00:00
if ( check_perms ( 'users_mod' )) {
if ( $T [ Format ] != " 'FLAC' " ) {
2011-03-28 14:21:28 +00:00
$SQL .= "
2013-07-04 08:00:56 +00:00
HasLog = '0' ,
HasCue = '0' , " ;
2011-03-28 14:21:28 +00:00
} else {
$SQL .= "
2013-07-04 08:00:56 +00:00
HasLog = $T [ HasLog ],
HasCue = $T [ HasCue ], " ;
2011-03-28 14:21:28 +00:00
}
2013-07-04 08:00:56 +00:00
$DB -> query ( "
SELECT TorrentID
FROM torrents_bad_tags
WHERE TorrentID = '$TorrentID' " );
2011-03-28 14:21:28 +00:00
list ( $btID ) = $DB -> next_record ();
if ( ! $btID && $Properties [ 'BadTags' ]) {
2013-07-04 08:00:56 +00:00
$DB -> query ( "
INSERT INTO torrents_bad_tags
VALUES ( $TorrentID , $LoggedUser [ ID ], '".sqltime()."' ) " );
2011-03-28 14:21:28 +00:00
}
if ( $btID && ! $Properties [ 'BadTags' ]) {
2013-07-04 08:00:56 +00:00
$DB -> query ( "
DELETE FROM torrents_bad_tags
WHERE TorrentID = '$TorrentID' " );
2011-03-28 14:21:28 +00:00
}
2013-07-04 08:00:56 +00:00
$DB -> query ( "
SELECT TorrentID
FROM torrents_bad_folders
WHERE TorrentID = '$TorrentID' " );
2011-03-28 14:21:28 +00:00
list ( $bfID ) = $DB -> next_record ();
if ( ! $bfID && $Properties [ 'BadFolders' ]) {
2013-07-04 08:00:56 +00:00
$DB -> query ( "
INSERT INTO torrents_bad_folders
VALUES ( $TorrentID , $LoggedUser [ ID ], '".sqltime()."' ) " );
2011-03-28 14:21:28 +00:00
}
if ( $bfID && ! $Properties [ 'BadFolders' ]) {
2013-07-04 08:00:56 +00:00
$DB -> query ( "
DELETE FROM torrents_bad_folders
WHERE TorrentID = '$TorrentID' " );
2011-03-28 14:21:28 +00:00
}
2013-07-04 08:00:56 +00:00
$DB -> query ( "
SELECT TorrentID
FROM torrents_bad_files
WHERE TorrentID = '$TorrentID' " );
2011-03-28 14:21:28 +00:00
list ( $bfiID ) = $DB -> next_record ();
if ( ! $bfiID && $Properties [ 'BadFiles' ]) {
2013-07-04 08:00:56 +00:00
$DB -> query ( "
INSERT INTO torrents_bad_files
VALUES ( $TorrentID , $LoggedUser [ ID ], '".sqltime()."' ) " );
2011-03-28 14:21:28 +00:00
}
if ( $bfiID && ! $Properties [ 'BadFiles' ]) {
2013-07-04 08:00:56 +00:00
$DB -> query ( "
DELETE FROM torrents_bad_files
WHERE TorrentID = '$TorrentID' " );
2011-03-28 14:21:28 +00:00
}
2011-08-09 21:03:28 +00:00
2013-07-04 08:00:56 +00:00
$DB -> query ( "
SELECT TorrentID
FROM library_contest
WHERE TorrentID = '$TorrentID' " );
2012-03-08 08:00:24 +00:00
list ( $lbID ) = $DB -> next_record ();
if ( ! $lbID && $Properties [ 'LibraryUpload' ] && $Properties [ 'LibraryPoints' ] > 0 ) {
2013-07-04 08:00:56 +00:00
$DB -> query ( "
SELECT UserID
FROM torrents
WHERE ID = $TorrentID " );
2012-03-08 08:00:24 +00:00
list ( $UploaderID ) = $DB -> next_record ();
2013-07-04 08:00:56 +00:00
$DB -> query ( "
INSERT INTO library_contest
VALUES ( $UploaderID , $TorrentID , $Properties [ LibraryPoints ]) " );
2012-03-08 08:00:24 +00:00
}
if ( $lbID && ! $Properties [ 'LibraryUpload' ]) {
2013-07-04 08:00:56 +00:00
$DB -> query ( "
DELETE FROM library_contest
WHERE TorrentID = '$TorrentID' " );
2012-03-08 08:00:24 +00:00
}
2013-07-04 08:00:56 +00:00
$DB -> query ( "
SELECT TorrentID
FROM torrents_cassette_approved
WHERE TorrentID = '$TorrentID' " );
2011-08-09 21:03:28 +00:00
list ( $caID ) = $DB -> next_record ();
if ( ! $caID && $Properties [ 'CassetteApproved' ]) {
2013-07-04 08:00:56 +00:00
$DB -> query ( "
INSERT INTO torrents_cassette_approved
VALUES ( $TorrentID , $LoggedUser [ ID ], '".sqltime()."' ) " );
2011-08-09 21:03:28 +00:00
}
if ( $caID && ! $Properties [ 'CassetteApproved' ]) {
2013-07-04 08:00:56 +00:00
$DB -> query ( "
DELETE FROM torrents_cassette_approved
WHERE TorrentID = '$TorrentID' " );
2011-08-09 21:03:28 +00:00
}
2013-02-16 08:00:57 +00:00
2013-07-04 08:00:56 +00:00
$DB -> query ( "
SELECT TorrentID
FROM torrents_lossymaster_approved
WHERE TorrentID = '$TorrentID' " );
2011-08-09 21:03:28 +00:00
list ( $lmaID ) = $DB -> next_record ();
if ( ! $lmaID && $Properties [ 'LossymasterApproved' ]) {
2013-07-04 08:00:56 +00:00
$DB -> query ( "
INSERT INTO torrents_lossymaster_approved
VALUES ( $TorrentID , $LoggedUser [ ID ], '".sqltime()."' ) " );
2011-08-09 21:03:28 +00:00
}
if ( $lmaID && ! $Properties [ 'LossymasterApproved' ]) {
2013-07-04 08:00:56 +00:00
$DB -> query ( "
DELETE FROM torrents_lossymaster_approved
WHERE TorrentID = '$TorrentID' " );
2011-08-09 21:03:28 +00:00
}
2012-05-31 08:00:14 +00:00
2013-07-04 08:00:56 +00:00
$DB -> query ( "
SELECT TorrentID
FROM torrents_lossyweb_approved
WHERE TorrentID = '$TorrentID' " );
2012-05-31 08:00:14 +00:00
list ( $lwID ) = $DB -> next_record ();
if ( ! $lwID && $Properties [ 'LossywebApproved' ]) {
2013-07-04 08:00:56 +00:00
$DB -> query ( "
INSERT INTO torrents_lossyweb_approved
VALUES ( $TorrentID , $LoggedUser [ ID ], '".sqltime()."' ) " );
2012-05-31 08:00:14 +00:00
}
if ( $lwID && ! $Properties [ 'LossywebApproved' ]) {
2013-07-04 08:00:56 +00:00
$DB -> query ( "
DELETE FROM torrents_lossyweb_approved
WHERE TorrentID = '$TorrentID' " );
2012-05-31 08:00:14 +00:00
}
2011-03-28 14:21:28 +00:00
}
$SQL .= "
2013-08-28 23:08:41 +00:00
Description = $T [ TorrentDescription ]
2013-07-04 08:00:56 +00:00
WHERE ID = $TorrentID " ;
2011-03-28 14:21:28 +00:00
$DB -> query ( $SQL );
2011-04-13 15:36:33 +00:00
2013-04-30 18:18:07 +00:00
if ( check_perms ( 'torrents_freeleech' ) && $Properties [ 'FreeLeech' ] != $CurFreeLeech ) {
2012-10-11 08:00:15 +00:00
Torrents :: freeleech_torrents ( $TorrentID , $Properties [ 'FreeLeech' ], $Properties [ 'FreeLeechType' ]);
2011-03-28 14:21:28 +00:00
}
2013-07-04 08:00:56 +00:00
$DB -> query ( "
SELECT GroupID , Time
FROM torrents
WHERE ID = '$TorrentID' " );
2011-03-28 14:21:28 +00:00
list ( $GroupID , $Time ) = $DB -> next_record ();
// Competition
2013-07-04 08:00:56 +00:00
if ( strtotime ( $Time ) > 1241352173 ) {
2013-04-30 18:18:07 +00:00
if ( $_POST [ 'log_score' ] == '100' ) {
2013-07-04 08:00:56 +00:00
$DB -> query ( "
INSERT IGNORE into users_points ( GroupID , UserID , Points )
VALUES ( '$GroupID' , '$UserID' , '1' ) " );
2011-03-28 14:21:28 +00:00
}
}
// End competiton
2013-07-04 08:00:56 +00:00
$DB -> query ( "
SELECT LogScore
FROM torrents
WHERE ID = $TorrentID " );
2011-03-28 14:21:28 +00:00
list ( $LogScore ) = $DB -> next_record ();
if ( $Properties [ 'Trumpable' ] == 1 && $LogScore == 100 ) {
2013-07-04 08:00:56 +00:00
$DB -> query ( "
UPDATE torrents
SET LogScore = 99
WHERE ID = $TorrentID " );
2011-03-28 14:21:28 +00:00
$Results = array ();
2013-07-04 08:00:56 +00:00
$Results [] = 'The original uploader has chosen to allow this log to be deducted one point for using EAC v0.95., -1 point [1]' ;
2011-03-28 14:21:28 +00:00
$Details = db_string ( serialize ( $Results ));
2013-07-04 08:00:56 +00:00
$DB -> query ( "
UPDATE torrents_logs_new
SET Score = 99 , Details = '$Details'
WHERE TorrentID = $TorrentID " );
2011-03-28 14:21:28 +00:00
}
2013-07-04 08:00:56 +00:00
$DB -> query ( "
SELECT Enabled
FROM users_main
WHERE ID = $UserID " );
2011-08-12 21:42:06 +00:00
list ( $Enabled ) = $DB -> next_record ();
if ( $Properties [ 'Trumpable' ] == 0 && $LogScore == 99 && $Enabled == 1 && strtotime ( $Time ) < 1284422400 ) {
2013-07-04 08:00:56 +00:00
$DB -> query ( "
SELECT Log
FROM torrents_logs_new
WHERE TorrentID = $TorrentID " );
2011-08-12 21:42:06 +00:00
list ( $Log ) = $DB -> next_record ();
2013-07-04 08:00:56 +00:00
if ( strpos ( $Log , 'EAC extraction' ) === 0 ) {
$DB -> query ( "
UPDATE torrents
SET LogScore = 100
WHERE ID = $TorrentID " );
$DB -> query ( "
UPDATE torrents_logs_new
SET Score = 100 , Details = ''
WHERE TorrentID = $TorrentID " );
2011-08-12 21:42:06 +00:00
}
2011-03-28 14:21:28 +00:00
}
2013-07-04 08:00:56 +00:00
$DB -> query ( "
SELECT Name
FROM torrents_group
WHERE ID = $GroupID " );
2012-07-25 08:00:15 +00:00
list ( $Name ) = $DB -> next_record ( MYSQLI_NUM , false );
2011-03-28 14:21:28 +00:00
2013-07-04 08:00:56 +00:00
Misc :: write_log ( " Torrent $TorrentID ( $Name ) in group $GroupID was edited by " . $LoggedUser [ 'Username' ] . " ( $LogDetails ) " ); // TODO: this is probably broken
2012-10-11 08:00:15 +00:00
Torrents :: write_group_log ( $GroupID , $TorrentID , $LoggedUser [ 'ID' ], $LogDetails , 0 );
2013-07-04 08:00:56 +00:00
$Cache -> delete_value ( " torrents_details_ $GroupID " );
$Cache -> delete_value ( " torrent_download_ $TorrentID " );
2011-03-28 14:21:28 +00:00
2012-10-11 08:00:15 +00:00
Torrents :: update_hash ( $GroupID );
2011-03-28 14:21:28 +00:00
// All done!
header ( " Location: torrents.php?id= $GroupID " );
?>