Location: PHPKode > projects > H-tracker > members.php
<?
//
//  H-Tracker v0.2
//    http://h-tracker.org
//    Based on TorrentTrader (http://www.torrenttrader.org)
//
//
require_once("backend/functions.php");
dbconn(false);
loggedinonly();
if($CURUSER ["class"] < 2)
show_error_msg("Error", "Access Denied");
    stdhead("Users Management");


    $search = trim($search);
    $class = $_GET['class']; 

if ($class == '-' || !is_valid_id($class))
  $class = '';

if ($search != '' || $class)
{
        $where = "WHERE username LIKE " . sqlesc("%$search%") . " AND status='confirmed'";
if ($search)
          $q = "search=" . htmlspecialchars($search);
}else{
    $letter = trim($_GET["letter"]);
  if (strlen($letter) > 1)
    die;
    if ($letter == "" || strpos("abcdefghijklmnopqrstuvwxyz", $letter) === false)
    $letter = "a";
  $where = "WHERE username LIKE '$letter%' AND status='confirmed'";
  $q = "letter=$letter";
}

if ($class)
{
  $where .= " AND class=$class";
  $q .= ($q ? "&amp;" : "") . "class=$class";
} 
begin_frame("Users Management");   
    
    $res = mysql_query("SELECT COUNT(*) FROM users $where");
    $row = mysql_fetch_array($res);
    $count = $row[0];

    $perpage = 50;

    list($pagertop, $pagerbottom, $limit) = pager($perpage, $count, "?$q&");

print("<center><table align=center cellpadding=\"0\" cellspacing=\"0\" class=\"table_table\" width=\"100%\"><tr><td><form method=get action=?>\n");
print("Search: <input type=text size=30 name=search>\n");
print("<select name=class>\n");
print("<option value='-'>(any class)</option>\n");
for ($i = 1;;++$i)
{
    if ($c = get_user_class_name($i))
      print("<option value=$i" . ($class && $class == $i ? " selected" : "") . ">$c</option>\n");
    else
      break;
}
print("</select>\n");
print("<input type=submit value='Okay'>\n");
print("</form>\n");

for ($i = 97; $i < 123; ++$i)
{
    $l = chr($i);
    $L = chr($i - 32);
    if ($l == $letter)
    print("<font color=red>$L</font>\n");
    else
    print("<a href=?letter=$l><b>$L</b></a>\n");
}
print("</td></tr></center></table>\n");


    echo $pagertop;
    ?>
    <CENTER><table align=center cellpadding="0" cellspacing="0" class="tablebg" width="100%">
    <tr>
    <td class=table_head align=center>Username</td>
    <td class=table_head align=center>Class</td>
    <td class=table_head align=center>Ratio</td>
    <td class=table_head align=center width='12'>Gender</td>
    <td class=table_head align=center>Country</td>
    <td class=table_head align=center>Download</td> 
    <td class=table_head align=center>Upload</td>
    </tr>
    <?
    
    $rqq = "SELECT * FROM users $where ORDER BY username $limit";
    $resqq = mysql_query($rqq);
    while ($row = mysql_fetch_array($resqq)){
if ($row['country'] > 0)
{
$cres = mysql_query("SELECT name,flagpic FROM countries WHERE id=$row[country]");
if (mysql_num_rows($cres) == 1)
{
$carr = mysql_fetch_assoc($cres);
$country = "<div style='padding: 0px' align=center><img src='".$site_config["SITEURL"]."/images/flags/".htmlspecialchars($carr["flagpic"])."' alt=".sqlesc($carr["name"])."></div>";
}
}
else
$country = "---";
$uploaded = $row["uploaded"];
$downloaded = $row["downloaded"];
if ($row["downloaded"] > 0)
{
$ratio = number_format($row["uploaded"] / $row["downloaded"], 2);
if (($row["uploaded"] / $row["downloaded"]) > 10)
$ratio = "10+";
}
else
if ($row["uploaded"] > 0)
$ratio = "Inf.";
else
$ratio = "----";
        echo "
        <tr>
        <td class=row1 align=center><a href=account-details.php?id=$row[id]>$row[username]</a>" .($row["donated"] > 0 ? "&nbsp;<img src=/images/users/money.png border=0 alt='Donor'>" : "")."</td>
        <td class=row2 align=center>".get_user_class_name($row['class'])."</td>
        <td class=row1 align=center><font color=" . get_ratio_color($ratio) . ">$ratio</font></td>
        <td class=row2 align=center><img src=".get_user_gender_image($row['gender'])."></td>  
        <td class=row1 align=center>$country</td>
        <td class=row2 align=center>" . mksize($row["downloaded"]) . "</td>
        <td class=row1 align=center>" . mksize($row["uploaded"]) . "</td>
        </tr>\n";
    }

    echo "</table></CENTER>\n";

    print($pagerbottom); 
    
    $registered = number_format(get_row_count("users"));
    $male = number_format(get_row_count("users", "WHERE gender = 'Male'"));
    $female = number_format(get_row_count("users", "WHERE gender = 'Female'"));
    $notselect = number_format(get_row_count("users", "WHERE gender = ''"));
    $administrators = number_format(get_row_count("users", "WHERE class=7"));
    $Administrators2 = mysql_query("SELECT level, Color FROM groups WHERE group_id =7") or die(mysql_error());
    while($UClass7=mysql_fetch_array($Administrators2)){
    $Administrators = " <font color=\"$UClass7[Color]\"><b>Administrators</b></font>";}  
    $supermoderators = number_format(get_row_count("users", "WHERE class=6"));
    $Supermoderators2 = mysql_query("SELECT level, Color FROM groups WHERE group_id =6") or die(mysql_error());
    while($UClass6=mysql_fetch_array($Supermoderators2)){
    $Supermoderators = " <font color=\"$UClass6[Color]\"><b>Super Moderators</b></font>";}   
    $moderators = number_format(get_row_count("users", "WHERE class=5"));
    $Moderators2 = mysql_query("SELECT level, Color FROM groups WHERE group_id =5") or die(mysql_error());
    while($UClass5=mysql_fetch_array($Moderators2)){
    $Moderators = " <font color=\"$UClass5[Color]\"><b>Moderators</b></font>";}  
    $uploaders = number_format(get_row_count("users", "WHERE class=4"));
    $Uploaders2 = mysql_query("SELECT level, Color FROM groups WHERE group_id =4") or die(mysql_error());
    while($UClass4=mysql_fetch_array($Uploaders2)){
    $Uploaders = " <font color=\"$UClass4[Color]\"><b>Uploaders</b></font>";}
    $vips = number_format(get_row_count("users", "WHERE class=3"));
    $Vips2 = mysql_query("SELECT level, Color FROM groups WHERE group_id =3") or die(mysql_error());
    while($UClass3=mysql_fetch_array($Vips2)){
    $Vips = " <font color=\"$UClass3[Color]\"><b>V.I.P`s</b></font>";}
    $powerusers = number_format(get_row_count("users", "WHERE class=2"));
    $Powerusers2 = mysql_query("SELECT level, Color FROM groups WHERE group_id =2") or die(mysql_error());
    while($UClass2=mysql_fetch_array($Powerusers2)){
    $Powerusers = " <font color=\"$UClass2[Color]\"><b>Power Users</b></font>";}
    $members = number_format(get_row_count("users", "WHERE class = 1"));                                                         
echo"<table width=\"100%\" class=\"tablebg\" cellspacing=\"0\" cellpadding=\"2\"><td align=\"center\">

<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"10\">
    <tr><td width=\"50%\" align=\"center\"><table class=\"tablebg\" cellspacing=\"0\" cellpadding=\"5\">
        <tr>
    <td class=row2 align=center>$Administrators</td>
    <td class=row1 align=center width=20%>$administrators</td>
    <td class=row2 align=center>$Vips</td>
    <td class=row1 align=center width=20%>$vips</td>
    </tr>";
        echo "
        <tr>
        <td class=row2 align=center>$Supermoderators</td>
        <td class=row1 align=center>$supermoderators</td>
        <td class=row2 align=center>$Powerusers</td>
        <td class=row1 align=center>$powerusers</td>  
        </tr>\n";
                echo "
        <tr>
        <td class=row2 align=center>$Moderators</td>
        <td class=row1 align=center>$moderators</td>
        <td class=row2 align=center>Members</td>
        <td class=row1 align=center>$members</td>  
        </tr>\n";
                echo "
        <tr>
        <td class=row2 align=center>$Uploaders</td>
        <td class=row1 align=center>$uploaders</td>
        <td class=row2 align=center>Total</td>
        <td class=row1 align=center>$registered</td>  
        </tr>
        <tr>
        <td class=rowEnd colspan=4 align=center><img src=\"images/users/male.png\" title=\"Male\" alt=\"Male\">&nbsp;$male&nbsp;&nbsp;&nbsp;&nbsp;<img src=\"images/users/female.png\" title=\"Female\" alt=\"Female\">&nbsp;$female&nbsp;&nbsp;&nbsp;&nbsp;<img src=\"images/users/na.png\" alt=\"Gender Not Selectet\">&nbsp;$notselect</td></tr>
</table></td>
</table>
</td></tr></table>";
    end_frame();
    stdfoot();
      
?>
Return current item: H-tracker