示例#1
0
    $DB->query("\n\t\tDELETE FROM users_sessions\n\t\tWHERE UserID = '{$UserID}'");
}
if (empty($UpdateSet) && empty($EditSummary)) {
    if (!$Reason) {
        if (str_replace("\r", '', $Cur['AdminComment']) != str_replace("\r", '', $AdminComment) && check_perms('users_disable_any')) {
            $UpdateSet[] = "AdminComment = '{$AdminComment}'";
        } else {
            header("Location: user.php?id={$UserID}");
            die;
        }
    } else {
        $EditSummary[] = 'notes added';
    }
}
if (count($TrackerUserUpdates) > 1) {
    Tracker::update_tracker('update_user', $TrackerUserUpdates);
}
if ($DeleteKeys) {
    $Cache->delete_value("user_info_{$UserID}");
    $Cache->delete_value("user_info_heavy_{$UserID}");
} else {
    $Cache->begin_transaction("user_info_{$UserID}");
    $Cache->update_row(false, $LightUpdates);
    $Cache->commit_transaction(0);
    $Cache->begin_transaction("user_info_heavy_{$UserID}");
    $Cache->update_row(false, $HeavyUpdates);
    $Cache->commit_transaction(0);
}
$Summary = '';
// Create edit summary
if ($EditSummary) {
示例#2
0
文件: index.php 项目: bigsony/Gazelle
 $UserIDs = $DB->collect('ID');
 if (count($UserIDs) > 0) {
     $DB->query("\n\t\t\tUPDATE users_info AS i\n\t\t\t\tJOIN users_main AS m ON m.ID = i.UserID\n\t\t\tSET\tm.can_leech = '0',\n\t\t\t\ti.AdminComment = CONCAT('{$sqltime} - Leeching ability disabled by ratio watch system - required ratio: ', m.RequiredRatio, '\n\n', i.AdminComment)\n\t\t\tWHERE m.ID IN(" . implode(',', $UserIDs) . ')');
     $DB->query("\n\t\t\tDELETE FROM users_torrent_history\n\t\t\tWHERE UserID IN (" . implode(',', $UserIDs) . ')');
 }
 foreach ($UserIDs as $UserID) {
     $Cache->begin_transaction("user_info_heavy_{$UserID}");
     $Cache->update_row(false, array('RatioWatchDownload' => 0, 'CanLeech' => 0));
     $Cache->commit_transaction(0);
     Misc::send_pm($UserID, 0, 'Your downloading privileges have been disabled', "As you did not raise your ratio in time, your downloading privileges have been revoked. You will not be able to download any torrents until your ratio is above your new required ratio.");
     echo "Ratio watch disabled: {$UserID}\n";
 }
 $DB->set_query_id($UserQuery);
 $Passkeys = $DB->collect('torrent_pass');
 foreach ($Passkeys as $Passkey) {
     Tracker::update_tracker('update_user', array('passkey' => $Passkey, 'can_leech' => '0'));
 }
 //------------- Disable inactive user accounts --------------------------//
 sleep(5);
 // Send email
 $DB->query("\n\t\tSELECT um.Username, um.Email\n\t\tFROM users_info AS ui\n\t\t\tJOIN users_main AS um ON um.ID = ui.UserID\n\t\t\tLEFT JOIN users_levels AS ul ON ul.UserID = um.ID AND ul.PermissionID = '" . CELEB . "'\n\t\tWHERE um.PermissionID IN ('" . USER . "', '" . MEMBER . "')\n\t\t\tAND um.LastAccess < '" . time_minus(3600 * 24 * 110, true) . "'\n\t\t\tAND um.LastAccess > '" . time_minus(3600 * 24 * 111, true) . "'\n\t\t\tAND um.LastAccess != '0000-00-00 00:00:00'\n\t\t\tAND ui.Donor = '0'\n\t\t\tAND um.Enabled != '2'\n\t\t\tAND ul.UserID IS NULL\n\t\tGROUP BY um.ID");
 while (list($Username, $Email) = $DB->next_record()) {
     $Body = "Hi {$Username},\n\nIt has been almost 4 months since you used your account at " . site_url() . ". This is an automated email to inform you that your account will be disabled in 10 days if you do not sign in.";
     Misc::send_email($Email, 'Your ' . SITE_NAME . ' account is about to be disabled', $Body, 'noreply');
 }
 $DB->query("\n\t\tSELECT um.ID\n\t\tFROM users_info AS ui\n\t\t\tJOIN users_main AS um ON um.ID = ui.UserID\n\t\t\tLEFT JOIN users_levels AS ul ON ul.UserID = um.ID AND ul.PermissionID = '" . CELEB . "'\n\t\tWHERE um.PermissionID IN ('" . USER . "', '" . MEMBER . "')\n\t\t\tAND um.LastAccess < '" . time_minus(3600 * 24 * 30 * 4) . "'\n\t\t\tAND um.LastAccess != '0000-00-00 00:00:00'\n\t\t\tAND ui.Donor = '0'\n\t\t\tAND um.Enabled != '2'\n\t\t\tAND ul.UserID IS NULL\n\t\tGROUP BY um.ID");
 if ($DB->has_results()) {
     Tools::disable_users($DB->collect('ID'), 'Disabled for inactivity.', 3);
 }
 //------------- Disable unconfirmed users ------------------------------//
 sleep(10);
示例#3
0
    /**
     * Will freeleech / neutral leech / normalise a set of torrents
     *
     * @param array $TorrentIDs An array of torrent IDs to iterate over
     * @param int $FreeNeutral 0 = normal, 1 = fl, 2 = nl
     * @param int $FreeLeechType 0 = Unknown, 1 = Staff picks, 2 = Perma-FL (Toolbox, etc.), 3 = Vanity House
     */
    public static function freeleech_torrents($TorrentIDs, $FreeNeutral = 1, $FreeLeechType = 0)
    {
        if (!is_array($TorrentIDs)) {
            $TorrentIDs = array($TorrentIDs);
        }
        $QueryID = G::$DB->get_query_id();
        G::$DB->query("\n\t\t\tUPDATE torrents\n\t\t\tSET FreeTorrent = '{$FreeNeutral}', FreeLeechType = '{$FreeLeechType}'\n\t\t\tWHERE ID IN (" . implode(', ', $TorrentIDs) . ')');
        G::$DB->query('
			SELECT ID, GroupID, info_hash
			FROM torrents
			WHERE ID IN (' . implode(', ', $TorrentIDs) . ')
			ORDER BY GroupID ASC');
        $Torrents = G::$DB->to_array(false, MYSQLI_NUM, false);
        $GroupIDs = G::$DB->collect('GroupID');
        G::$DB->set_query_id($QueryID);
        foreach ($Torrents as $Torrent) {
            list($TorrentID, $GroupID, $InfoHash) = $Torrent;
            Tracker::update_tracker('update_torrent', array('info_hash' => rawurlencode($InfoHash), 'freetorrent' => $FreeNeutral));
            G::$Cache->delete_value("torrent_download_{$TorrentID}");
            Misc::write_log(G::$LoggedUser['Username'] . " marked torrent {$TorrentID} freeleech type {$FreeLeechType}!");
            Torrents::write_group_log($GroupID, $TorrentID, G::$LoggedUser['ID'], "marked as freeleech type {$FreeLeechType}!", 0);
        }
        foreach ($GroupIDs as $GroupID) {
            Torrents::update_hash($GroupID);
        }
    }
示例#4
0
    Tracker::update_tracker('remove_whitelist', array('peer_id' => $PeerID));
} else {
    //Edit & Create, Shared Validation
    if (empty($_POST['client']) || empty($_POST['peer_id'])) {
        print_r($_POST);
        die;
    }
    $Client = db_string($_POST['client']);
    $PeerID = db_string($_POST['peer_id']);
    if ($_POST['submit'] == 'Edit') {
        //Edit
        if (empty($_POST['id']) || !is_number($_POST['id'])) {
            error('3');
        } else {
            $DB->query('
				SELECT peer_id
				FROM xbt_client_whitelist
				WHERE id = ' . $_POST['id']);
            list($OldPeerID) = $DB->next_record();
            $DB->query("\n\t\t\t\tUPDATE xbt_client_whitelist\n\t\t\t\tSET\n\t\t\t\t\tvstring = '{$Client}',\n\t\t\t\t\tpeer_id = '{$PeerID}'\n\t\t\t\tWHERE ID = " . $_POST['id']);
            Tracker::update_tracker('edit_whitelist', array('old_peer_id' => $OldPeerID, 'new_peer_id' => $PeerID));
        }
    } else {
        //Create
        $DB->query("\n\t\t\tINSERT INTO xbt_client_whitelist\n\t\t\t\t(vstring, peer_id)\n\t\t\tVALUES\n\t\t\t\t('{$Client}', '{$PeerID}')");
        Tracker::update_tracker('add_whitelist', array('peer_id' => $PeerID));
    }
}
$Cache->delete_value('whitelisted_clients');
// Go back
header('Location: tools.php?action=whitelist');
示例#5
0
    /**
     * Disable an array of users.
     *
     * @param array $UserIDs (You can also send it one ID as an int, because f**k types)
     * @param BanReason 0 - Unknown, 1 - Manual, 2 - Ratio, 3 - Inactive, 4 - Unused.
     */
    public static function disable_users($UserIDs, $AdminComment, $BanReason = 1)
    {
        $QueryID = G::$DB->get_query_id();
        if (!is_array($UserIDs)) {
            $UserIDs = array($UserIDs);
        }
        G::$DB->query("\n\t\t\tUPDATE users_info AS i\n\t\t\t\tJOIN users_main AS m ON m.ID = i.UserID\n\t\t\tSET m.Enabled = '2',\n\t\t\t\tm.can_leech = '0',\n\t\t\t\ti.AdminComment = CONCAT('" . sqltime() . " - " . ($AdminComment ? $AdminComment : 'Disabled by system') . "\n\n', i.AdminComment),\n\t\t\t\ti.BanDate = '" . sqltime() . "',\n\t\t\t\ti.BanReason = '{$BanReason}',\n\t\t\t\ti.RatioWatchDownload = " . ($BanReason == 2 ? 'm.Downloaded' : "'0'") . "\n\t\t\tWHERE m.ID IN(" . implode(',', $UserIDs) . ') ');
        G::$Cache->decrement('stats_user_count', G::$DB->affected_rows());
        foreach ($UserIDs as $UserID) {
            G::$Cache->delete_value("enabled_{$UserID}");
            G::$Cache->delete_value("user_info_{$UserID}");
            G::$Cache->delete_value("user_info_heavy_{$UserID}");
            G::$Cache->delete_value("user_stats_{$UserID}");
            G::$DB->query("\n\t\t\t\tSELECT SessionID\n\t\t\t\tFROM users_sessions\n\t\t\t\tWHERE UserID = '{$UserID}'\n\t\t\t\t\tAND Active = 1");
            while (list($SessionID) = G::$DB->next_record()) {
                G::$Cache->delete_value("session_{$UserID}" . "_{$SessionID}");
            }
            G::$Cache->delete_value("users_sessions_{$UserID}");
            G::$DB->query("\n\t\t\t\tDELETE FROM users_sessions\n\t\t\t\tWHERE UserID = '{$UserID}'");
        }
        // Remove the users from the tracker.
        G::$DB->query('
			SELECT torrent_pass
			FROM users_main
			WHERE ID in (' . implode(', ', $UserIDs) . ')');
        $PassKeys = G::$DB->collect('torrent_pass');
        $Concat = '';
        foreach ($PassKeys as $PassKey) {
            if (strlen($Concat) > 3950) {
                // Ocelot's read buffer is 4 KiB and anything exceeding it is truncated
                Tracker::update_tracker('remove_users', array('passkeys' => $Concat));
                $Concat = $PassKey;
            } else {
                $Concat .= $PassKey;
            }
        }
        Tracker::update_tracker('remove_users', array('passkeys' => $Concat));
        G::$DB->set_query_id($QueryID);
    }
示例#6
0
        $UInfo = Users::user_heavy_info($UserID);
        if ($UInfo['CanLeech'] != '1') {
            error('You may not use tokens while leech disabled.');
        }
        $FLTokens = $UInfo['FLTokens'];
    }
    // First make sure this isn't already FL, and if it is, do nothing
    if (!Torrents::has_token($TorrentID)) {
        if ($FLTokens <= 0) {
            error('You do not have any freeleech tokens left. Please use the regular DL link.');
        }
        if ($Size >= 1073741824) {
            error('This torrent is too large. Please use the regular DL link.');
        }
        // Let the tracker know about this
        if (!Tracker::update_tracker('add_token', array('info_hash' => rawurlencode($InfoHash), 'userid' => $UserID))) {
            error('Sorry! An error occurred while trying to register your token. Most often, this is due to the tracker being down or under heavy load. Please try again later.');
        }
        if (!Torrents::has_token($TorrentID)) {
            $DB->query("\n\t\t\t\tINSERT INTO users_freeleeches (UserID, TorrentID, Time)\n\t\t\t\tVALUES ({$UserID}, {$TorrentID}, NOW())\n\t\t\t\tON DUPLICATE KEY UPDATE\n\t\t\t\t\tTime = VALUES(Time),\n\t\t\t\t\tExpired = FALSE,\n\t\t\t\t\tUses = Uses + 1");
            $DB->query("\n\t\t\t\tUPDATE users_main\n\t\t\t\tSET FLTokens = FLTokens - 1\n\t\t\t\tWHERE ID = {$UserID}");
            // Fix for downloadthemall messing with the cached token count
            $UInfo = Users::user_heavy_info($UserID);
            $FLTokens = $UInfo['FLTokens'];
            $Cache->begin_transaction("user_info_heavy_{$UserID}");
            $Cache->update_row(false, array('FLTokens' => $FLTokens - 1));
            $Cache->commit_transaction(0);
            $Cache->delete_value("users_tokens_{$UserID}");
        }
    }
}
示例#7
0
	$UserInfo = Users::user_heavy_info($UserID);
	$OldPassKey = db_string($UserInfo['torrent_pass']);
	$NewPassKey = db_string(Users::make_secret());
	$ChangerIP = db_string($LoggedUser['IP']);
	$SQL .= ",m.torrent_pass = '******'";
	$DB->query("
		INSERT INTO users_history_passkeys
			(UserID, OldPassKey, NewPassKey, ChangerIP, ChangeTime)
		VALUES
			('$UserID', '$OldPassKey', '$NewPassKey', '$ChangerIP', '".sqltime()."')");
	$Cache->begin_transaction("user_info_heavy_$UserID");
	$Cache->update_row(false, array('torrent_pass' => $NewPassKey));
	$Cache->commit_transaction(0);
	$Cache->delete_value("user_$OldPassKey");

	Tracker::update_tracker('change_passkey', array('oldpasskey' => $OldPassKey, 'newpasskey' => $NewPassKey));
}

$SQL .= "WHERE m.ID = '".db_string($UserID)."'";
$DB->query($SQL);

if ($ResetPassword) {
	
	logout_all_sessions();
}

header("Location: user.php?action=edit&userid=$UserID");

?>
示例#8
0
 $Username = trim($_POST['Username']);
 $Email = trim($_POST['Email']);
 $Password = $_POST['Password'];
 //Make sure all the fields are filled in
 //Don't allow a username of "0" or "1" because of PHP's type juggling
 if (!empty($Username) && !empty($Email) && !empty($Password) && $Username != '0' && $Username != '1') {
     //Create hashes...
     $Secret = Users::make_secret();
     $torrent_pass = Users::make_secret();
     //Create the account
     $DB->query("\n\t\t\tINSERT INTO users_main\n\t\t\t\t(Username, Email, PassHash, torrent_pass, Enabled, PermissionID)\n\t\t\tVALUES\n\t\t\t\t('" . db_string($Username) . "', '" . db_string($Email) . "', '" . db_string(Users::make_crypt_hash($Password)) . "', '" . db_string($torrent_pass) . "', '1', '" . USER . "')");
     //Increment site user count
     $Cache->increment('stats_user_count');
     //Grab the userID
     $UserID = $DB->inserted_id();
     Tracker::update_tracker('add_user', array('id' => $UserID, 'passkey' => $torrent_pass));
     //Default stylesheet
     $DB->query("\n\t\t\tSELECT ID\n\t\t\tFROM stylesheets");
     list($StyleID) = $DB->next_record();
     //Auth key
     $AuthKey = Users::make_secret();
     //Give them a row in users_info
     $DB->query("\n\t\t\tINSERT INTO users_info\n\t\t\t\t(UserID, StyleID, AuthKey, JoinDate)\n\t\t\tVALUES\n\t\t\t\t('" . db_string($UserID) . "', '" . db_string($StyleID) . "', '" . db_string($AuthKey) . "', '" . sqltime() . "')");
     // Give the notification settings
     $DB->query("INSERT INTO users_notifications_settings (UserID) VALUES ('{$UserID}')");
     //Redirect to users profile
     header("Location: user.php?id={$UserID}");
     //What to do if we don't have a username, email, or password
 } elseif (empty($Username)) {
     //Give the Error -- We do not have a username
     error('Please supply a username');
示例#9
0
            $Tag = Misc::get_alias_tag($Tag);
            $DB->query("\n\t\t\t\tINSERT INTO tags\n\t\t\t\t\t(Name, UserID)\n\t\t\t\tVALUES\n\t\t\t\t\t('{$Tag}', {$LoggedUser['ID']})\n\t\t\t\tON DUPLICATE KEY UPDATE\n\t\t\t\t\tUses = Uses + 1;\n\t\t\t");
            $TagID = $DB->inserted_id();
            $DB->query("\n\t\t\t\tINSERT INTO torrents_tags\n\t\t\t\t\t(TagID, GroupID, UserID, PositiveVotes)\n\t\t\t\tVALUES\n\t\t\t\t\t({$TagID}, {$GroupID}, {$LoggedUser['ID']}, 10)\n\t\t\t\tON DUPLICATE KEY UPDATE\n\t\t\t\t\tPositiveVotes = PositiveVotes + 1;\n\t\t\t");
        }
    }
}
// Use this section to control freeleeches
$T['FreeLeech'] = 0;
$T['FreeLeechType'] = 0;
$LogScore = $HasLog == 1 ? $LogScoreAverage : 0;
// Torrent
$DB->query("\n\tINSERT INTO torrents\n\t\t(GroupID, UserID, Media, Format, Encoding,\n\t\tRemastered, RemasterYear, RemasterTitle, RemasterRecordLabel, RemasterCatalogueNumber,\n\t\tScene, HasLog, HasCue, info_hash, FileCount, FileList, FilePath,\n\t\tSize, Time, Description, LogScore, FreeTorrent, FreeLeechType)\n\tVALUES\n\t\t({$GroupID}, {$LoggedUser['ID']}, {$T['Media']}, {$T['Format']}, {$T['Encoding']},\n\t\t{$T['Remastered']}, {$T['RemasterYear']}, {$T['RemasterTitle']}, {$T['RemasterRecordLabel']}, {$T['RemasterCatalogueNumber']},\n\t\t{$T['Scene']}, '{$HasLog}', '{$HasCue}', '" . db_string($InfoHash) . "', {$NumFiles}, '{$FileString}', '{$FilePath}',\n\t\t{$TotalSize}, '" . sqltime() . "', {$T['TorrentDescription']}, {$LogScore}, '{$T['FreeLeech']}', '{$T['FreeLeechType']}')");
$Cache->increment('stats_torrent_count');
$TorrentID = $DB->inserted_id();
Tracker::update_tracker('add_torrent', array('id' => $TorrentID, 'info_hash' => rawurlencode($InfoHash), 'freetorrent' => $T['FreeLeech']));
$Debug->set_flag('upload: ocelot updated');
// Prevent deletion of this torrent until the rest of the upload process is done
// (expire the key after 10 minutes to prevent locking it for too long in case there's a fatal error below)
$Cache->cache_value("torrent_{$TorrentID}_lock", true, 600);
//******************************************************************************//
//--------------- Write torrent file -------------------------------------------//
$DB->query("\n\tINSERT INTO torrents_files (TorrentID, File)\n\tVALUES ({$TorrentID}, '{$TorEnc}')");
Misc::write_log("Torrent {$TorrentID} ({$LogName}) (" . number_format($TotalSize / (1024 * 1024), 2) . ' MB) was uploaded by ' . $LoggedUser['Username']);
Torrents::write_group_log($GroupID, $TorrentID, $LoggedUser['ID'], 'uploaded (' . number_format($TotalSize / (1024 * 1024), 2) . ' MB)', 0);
Torrents::update_hash($GroupID);
$Debug->set_flag('upload: sphinx updated');
if ($Type == 'Music') {
    include SERVER_ROOT . '/sections/upload/insert_extra_torrents.php';
}
//******************************************************************************//
示例#10
0
        }
        $UpdateSet[] = "Enabled = '1'";
        $LightUpdates['Enabled'] = 1;
    }
    $EditSummary[] = $EnableStr;
    $Cache->replace_value("enabled_{$UserID}", $EnableUser, 0);
}
if ($ResetPasskey == 1 && check_perms('users_edit_reset_keys')) {
    $Passkey = db_string(Users::make_secret());
    $UpdateSet[] = "torrent_pass = '******'";
    $EditSummary[] = 'passkey reset';
    $HeavyUpdates['torrent_pass'] = $Passkey;
    $Cache->delete_value('user_' . $Cur['torrent_pass']);
    //MUST come after the case for updating can_leech.
    $DB->query("\n\t\tINSERT INTO users_history_passkeys\n\t\t\t(UserID, OldPassKey, NewPassKey, ChangerIP, ChangeTime)\n\t\tVALUES\n\t\t\t('{$UserID}', '" . $Cur['torrent_pass'] . "', '{$Passkey}', '0.0.0.0', '" . sqltime() . "')");
    Tracker::update_tracker('change_passkey', array('oldpasskey' => $Cur['torrent_pass'], 'newpasskey' => $Passkey));
}
if ($ResetAuthkey == 1 && check_perms('users_edit_reset_keys')) {
    $Authkey = db_string(Users::make_secret());
    $UpdateSet[] = "AuthKey = '{$Authkey}'";
    $EditSummary[] = 'authkey reset';
    $HeavyUpdates['AuthKey'] = $Authkey;
}
if ($SendHackedMail && check_perms('users_disable_any')) {
    $EditSummary[] = "hacked account email sent to {$HackedEmail}";
    Misc::send_email($HackedEmail, 'Your ' . SITE_NAME . ' account', 'Your ' . SITE_NAME . ' account appears to have been compromised. As a security measure, we have disabled your account. To resolve this, please visit us on IRC.

This is the information to connect to our server:
IRC Server: ' . BOT_SERVER . '
Port: ' . BOT_PORT . ' (' . BOT_PORT_SSL . ' for SSL)