Location: PHPKode > projects > top serious project > bco/view_userlist.php
<?php

include('include.php');

if (!$logged_in) {
    header("Location: $GLOBALS[base_url]" . "login.php?back=view_userlist.php");
    exit;
}

switch ($_GET['order']) {
case "asc":
    $order = "asc";
    break;
                                                                                                                             
case "desc":
    $order = "desc";
    break;
                                                                                                                             
default:
    $order = "asc";
    break;
}

switch ($_GET['sort']) {
case "id":
    $sortby = "id";
    break;

case "username":
    $sortby = "username";
    break;

case "location":
    $sortby = "location";
    break;

case "aim":
    $sortby = "aim";
    break;

default:
    $sortby = "id";
    break;
}
                                                                                                                             
if ((isset($_GET['start'])) && (is_numeric($_GET['start']))) {
    $start = $_GET['start'];
} else {
    $start = 0;
}
                                                                                                                             
$max_users_per_page = 50;

$query  = "select id, username, location, aim_name, colors from users";
$query .= " order by $sortby $order limit $max_users_per_page offset $start";

if (!$user_result = pg_query($query)) {
    bco_error("Query failed at line: " . __LINE__ . "<br />$query");
}

$query  = "select max(id) from users";

if (!$number_of_users = pg_fetch_result(pg_query($query),0 )) {
    bco_error("Query failed at line: " . __LINE__ . "<br />$query");
}

if ($number_of_users < 50) {
    $page_numbers = "";
} else {
    $page_numbers = bco_makepagenumbers("view_userlist.php?sortby=$sortby", $number_of_users, $max_users_per_page, $start, $order);
}

// Get the default color scehem from the table.
// If you don't need this, comment from this line until the comment with the number 667 in it.
$query  = 'SELECT config_value '
        . ' FROM bco_config '
        . ' WHERE config_name = \'default_colors\'';

if (!$color_result = pg_query($query)) {
    bco_error("Query failed at line: " . __LINE__ . "<br />$query");
}

$colors = pg_fetch_result($color_result, 0);
// 667

bco_html_header("Userlist");

bco_index_menu("Userlist - $number_of_users users");

echo "\n<br />";
echo "\n<table width=\"100%\" cellpadding=\"2\" cellspacing=\"0\" class=\"replytbl\">";
echo "\n    <tr>";
echo "\n        <td align=\"left\" width=\"2%\" class=\"header\">&nbsp;</td>";
echo "\n        <td align=\"left\" width=\"18%\" class=\"header\"><span class=\"smallfont\">username</span></td>";
echo "\n        <td align=\"left\" width=\"30%\" class=\"header\"><span class=\"smallfont\">location</span></td>";
echo "\n        <td align=\"left\" width=\"20%\" class=\"header\"><span class=\"smallfont\">aim</span></td>";
// If you commented out the color scheme stuff above, comment the following line out as well
echo "\n        <td align=\"left\" width=\"30%\" class=\"header\"><span class=\"smallfont\">color scheme</span></td>";
echo "\n    </tr>\n";

while (($row = pg_fetch_assoc($user_result)) && ($count++ < $number_of_users)) {

    if ($row['id'] == $user_array['myuserid']) {
        $row_class  = " class=\"mypost\"";
        $link_class = "mypost";
    } elseif ($count%2 == 0) {
        $row_class  = " class=\"tr2\"";
        $link_class = "tr2";
    } else {
        $row_class  = " class=\"tr1\"";
        $link_class = "tr1";
    }

    $id         = $row['id'];
    $username   = ereg_replace(" ", "&nbsp;", $row['username']);
    $location   = trim(strip_tags($row['location']));
    $aim        = "<a href=\"aim:goaim?screenname=" . urlencode($row['aim_name']) . "\" class=\"$link_class\">"
                  .  "$row[aim_name]</a>";

// Comment the following if statement to remove the color stuff if you're not using it.
    if ($colors == $row['colors']) {
        $color_scheme = "-- (Default scheme) --";
    } else {
        list($bgcolor,$tr1color,$tr2color,$formcolor,$mypostcolor,$fontface,$fontsize) = split(",", $row['colors']);
        $color_scheme = "<a href=\"" . $GLOBALS['base_url'] . "change_colors.php?background=$bgcolor&tr1color=$tr1color"
            . "&tr2color=$tr2color&formcolor=$formcolor&mypostcolor=$mypostcolor"
            . "&fontface=$fontface&fontsize=$fontsize&submit=preview\" class=\"$link_class\">"
            . "View scheme $username is using</a>";
    }
// End of color shit

    echo "\n    <tr>";
    echo "\n        <td align=\"left\" valign=\"top\"$row_class>$row[id]</td>";
    echo "\n        <td align=\"left\" valign=\"top\" nowrap=\"nowrap\"$row_class>";
    echo "<a href=\"view_profile.php?id=$id\" class=\"$link_class\">$username</a></td>";
    echo "\n        <td align=\"left\" valign=\"top\"$row_class>$location</td>";
    echo "\n        <td align=\"left\" valign=\"top\"$row_class>$aim</td>";
    // If you're not using the color scheme stuff, comment the following line out
    echo "\n        <td align=\"left\" valign=\"top\" nowrap=\"nowrap\"$row_class>$color_scheme</td>";
    echo "\n    </tr>\n";
}

echo "\n</table>";
echo "$page_numbers";

bco_html_footer();

?>
Return current item: top serious project