if ( !isset( $self ) ) {
$valid = @mysql_fetch_row( @sql_query( "SELECT COUNT(*) FROM peers WHERE torrent=$torrentid AND passkey=" . sqlesc( $passkey ) ) );
if ( $valid[0] >= 2 && $seeder == 'no' )
err( "Connection limit exceeded! You may only leech from one location at a time." );
if ( $valid[0] >= 3 && $seeder == 'yes' )
err( "Connection limit exceeded!" );
$rz = mysql_query( "SELECT id, tlimitseeds, tlimitleeches, tlimitall, uploaded, downloaded, class, downloadpos, parked, enabled FROM users WHERE passkey=" . sqlesc( $passkey ) . "" ) or err( "Tracker error 2" );
$user_q = sql_query("SELECT id, tlimitseeds, tlimitleeches, tlimitall, uploaded, downloaded, class, downloadpos, parked, enabled FROM users WHERE passkey=" . sqlesc( $passkey ) . "") or err("User SQL error. Contact staff.");
if (mysql_num_rows($user_q) > 1) err("Please reset your passkey and re-download all torrent files.. Passkey collision.");
$user = mysql_fetch_assoc($user_q);
// ///////////////////////////////////////////////////////// Stop and register users who cheat w. passkey
$pklength = strlen( $passkey );
if ( mysql_num_rows( $rz ) < 1 || $pklength != 32 ) { // If there was no user found with that passkey, or if passkey is not 32 chars long
if ( $pklength != 32 )
$reason = "Passkey incorrect lenght ($pklength).";
else
if ( mysql_num_rows( $rz ) < 1 )
$reason = "No user found.";
// Insert into passkeyerr table.
$err = sql_query( "INSERT INTO passkeyerr (added, lastchange, ip, firstpasskey, lastpasskey, firstreason, lastreason, times) VALUES('" . get_date_time() . "', '" . get_date_time() . "', '$ip', " . sqlesc( $passkey ) . ", " . sqlesc( $passkey ) . ", '$reason', '$reason', '1')" );
// If the ip is already regged there, update the post instead, and add + 1 to offences.
if ( !$err ) {
if ( mysql_errno() == 1062 )
mysql_query( "UPDATE passkeyerr SET lastchange = '" . get_date_time() . "', lastpasskey = " . sqlesc( $passkey ) . ", lastreason = '$reason', times = times + 1 WHERE ip = '$ip'" ) or
err( "AC3 - 2 Error. Contact staff." );
else
err( "AC3 Error. Contact staff." );
}
// Send an error message to users client, with reason and warning.
err( "Invalid passkey. $reason You might now be IP-banned for misbehaving." );
}
else if ($user["enabled"] != "yes")
err("Your account has been banned! Delete this torrent from your client. Stop hammering!");
if ( $MEMBERSONLY && mysql_num_rows( $rz ) == 0 )
err( "Unknown passkey. Please redownload the torrent !" );
$az = mysql_fetch_assoc( $rz );