function globalSchemas($gid)
{
    if ($gid == 440 && !isset($GLOBALS['schemas_440'])) {
        $GLOBALS['schemas_440'] = array('schema' => localSchema(), 'prices' => localPriceList(), 'est' => local_global_whitelist());
    }
    if ($gid == 730 && !isset($GLOBALS['schemas_730'])) {
        $GLOBALS['schemas_730'] = schema_730();
    }
    if ($gid == 570 && !isset($GLOBALS['schemas_570'])) {
        $GLOBALS['schemas_570']['schema'] = schema_570();
    }
}
function userList($cursor, $input)
{
    $userList = array();
    foreach ($cursor as $document) {
        array_push($userList, $document['_id']);
    }
    $upToDateUserData = checkCurrentUserData($userList);
    //print_r_html($upToDateUserData);
    if ($upToDateUserData === 0) {
        echo "could not get updated data due to steam servers.<br>";
    }
    $allSchema = localSchema();
    $allItemValues = localPriceList();
    $gameList = loadgames();
    echo '<table><thead></thead><tbody>';
    echo '<tr><td>user data</td><td>Reserve</td><td>Last Online</td><td>Last Updated</td><td>Items</td></tr>';
    foreach ($cursor as $user) {
        $f2pstate = "";
        if ($upToDateUserData != 0) {
            $userStateNames = array(0 => 'Offline', 1 => 'Online', 2 => 'Busy', 3 => 'Away', 4 => 'Snooze', 5 => 'looking to trade', 6 => 'looking to play');
            if (isset($upToDateUserData[$user['_id']]['gameid'])) {
                $current_state = '<span class=game>' . getGameName($upToDateUserData[$user['_id']]['gameid'], $gameList) . '</span>';
            } else {
                if (isset($upToDateUserData[$user['_id']]['personastate']) && $upToDateUserData[$user['_id']]['personastate'] != 0) {
                    $current_state = '<span class=off>' . $userStateNames[$upToDateUserData[$user['_id']]['personastate']] . '</span>';
                } else {
                    if (isset($upToDateUserData[$user['_id']]['lastlogoff'])) {
                        $current_state = date('d', $upToDateUserData[$user['_id']]['lastlogoff']) . ' ' . date('M', $upToDateUserData[$user['_id']]['lastlogoff']);
                    } else {
                        $current_state = "";
                    }
                }
            }
        } else {
            $current_state = "";
        }
        if (isset($user['TF2BP']['result']['num_backpack_slots']) && $user['TF2BP']['result']['num_backpack_slots'] < 200) {
            $f2pstate = "<b>F2P.</b>";
        }
        $lastScanned = date('d', $user['recent']) . ' ' . date('M', $user['recent']);
        echo profileBlockArea($user, 440, $user['hrs']) . '<td><form action=""><input type="submit" name="' . $user['_id'] . '" value="' . ($_SERVER['PHP_SELF'] == '/dblist.php' ? 'un' : '') . 'reserve"/></form></td>' . '<td>' . $current_state . '</td><td>' . $lastScanned . '</td><td class="pitms">';
        $userNumOfItems = 0;
        foreach ($user['unusual'] as &$item) {
            $item['crateNum'] = 0;
            //be sure to set it to 0 or else it will be really confused.
            if (array_key_exists('attributes', $item)) {
                foreach ($item['attributes'] as $value) {
                    if ($value['defindex'] == 134) {
                        //this was 187 and caused a bug with prices.
                        $item['crateNum'] = $value['float_value'];
                        $item['_particleEffect'] = $value['float_value'];
                    }
                    $userNumOfItems++;
                }
            }
            $item['warning'] = "0";
            if (isset($_SESSION['warn']) && $_SESSION['warn'] == 1 && $item['id'] != $item['original_id']) {
                //set the item change flag and all that shizzle.
                $item['warning'] = ' Item ID is different than original ID.';
            }
            item_prepare($item);
            item_price($item);
            if ((!isset($input['defindex']) || in_array($item['defindex'], $input['defindex'])) && (!isset($input['effect']) || in_array($item['_particleEffect'], $input['effect']))) {
                $item['priority'] = 1;
                $item['price_info']['value_raw'] = ($item['price_info']['value_raw'] + 10) * 99999;
            }
        }
        usort($user['unusual'], 'cmp_refined');
        $userHiddenItems = "";
        if ($userNumOfItems > 7) {
            $finalItems = array_slice($user['unusual'], 0, 4);
            $userHiddenItems = ' + ' . ($userNumOfItems - 4) . ' more unusuals.';
        } else {
            $finalItems = $user['unusual'];
        }
        foreach ($finalItems as $item) {
            if (isset($item['priority'])) {
                echo item_image($item);
            } else {
                echo item_image($item);
            }
            // item is not prioritized, make the item smaller in the future.
        }
        echo $userHiddenItems . '</td></tr>';
    }
    echo '</table>';
}