Example #1
0
	if ($Enabled==2) {
		
		logout();
	}

	// Up/Down stats
	$UserStats = $Cache->get_value('user_stats_'.$LoggedUser['ID']);
	if(!is_array($UserStats)) {
		$DB->query("SELECT Uploaded AS BytesUploaded, Downloaded AS BytesDownloaded, RequiredRatio FROM users_main WHERE ID='$LoggedUser[ID]'");
		$UserStats = $DB->next_record(MYSQLI_ASSOC);
		$Cache->cache_value('user_stats_'.$LoggedUser['ID'], $UserStats, 3600);
	}

	// Get info such as username
	$LightInfo = user_info($LoggedUser['ID']);
	$HeavyInfo = user_heavy_info($LoggedUser['ID']);

	// Get user permissions
	$Permissions = get_permissions($LightInfo['PermissionID']);

	// Create LoggedUser array
	$LoggedUser = array_merge($HeavyInfo, $LightInfo, $Permissions, $UserStats);

	$LoggedUser['RSS_Auth']=md5($LoggedUser['ID'].RSS_HASH.$LoggedUser['torrent_pass']);

	//$LoggedUser['RatioWatch'] as a bool to disable things for users on Ratio Watch
	$LoggedUser['RatioWatch'] = (
		$LoggedUser['RatioWatchEnds'] != '0000-00-00 00:00:00' &&
		time() < strtotime($LoggedUser['RatioWatchEnds']) &&
		($LoggedUser['BytesDownloaded']*$LoggedUser['RequiredRatio'])>$LoggedUser['BytesUploaded']
	);
Example #2
0
function update_site_options($UserID, $NewOptions)
{
    if (!is_number($UserID)) {
        error(0);
    }
    if (empty($NewOptions)) {
        return false;
    }
    global $DB, $Cache, $LoggedUser;
    // Get SiteOptions
    $DB->query("SELECT SiteOptions FROM users_info WHERE UserID = {$UserID}");
    list($SiteOptions) = $DB->next_record(MYSQLI_NUM, false);
    $SiteOptions = unserialize($SiteOptions);
    // Get HeavyInfo
    $HeavyInfo = user_heavy_info($UserID);
    // Insert new/replace old options
    $SiteOptions = array_merge($SiteOptions, $NewOptions);
    $HeavyInfo = array_merge($HeavyInfo, $NewOptions);
    // Update DB
    $DB->query("UPDATE users_info SET SiteOptions = '" . db_string(serialize($SiteOptions)) . "' WHERE UserID = {$UserID}");
    // Update cache
    $Cache->cache_value('user_info_heavy_' . $UserID, $HeavyInfo, 0);
    // Update $LoggedUser if the options are changed for the current
    if ($LoggedUser['ID'] == $UserID) {
        $LoggedUser = array_merge($LoggedUser, $NewOptions);
        $LoggedUser['ID'] = $UserID;
        // We don't want to allow userid switching
    }
}