rendered paste body<?
require_once("incl/func/main.php");
check_login();
$id = 0 + $_GET["id"];
if (is_valid_id($id) && $CURUSER["class"] >= UC_GLOBAL_MODERATOR) {
$ret = sql_query("SELECT username, donor, warned, status, invitees FROM users WHERE user_id = $id") or sqlerr(__FILE__, __LINE__);
$arr = mysql_fetch_assoc($ret);
if ($arr)
$user = "<a href=\"userdetails.php?id=$id\">$arr[username]</a>".get_user_icons($arr, true);
}
if (!$user) {
$id = $CURUSER["user_id"];
$arr = $CURUSER;
}
if ($CURUSER["class"] < UC_GLOBAL_MODERATOR)
$num = 3;
else
$num = 10;
if ($arr["invitees"] < 1)
stderr("No invitees", "It appears that ".($arr == $CURUSER ? "you have" : "the user you are trying to view the invite tree of has")." not yet invited any users.");
for ($i = 1; $i <= $num; $i++) {
$fields[] = "u{$i}.username as user{$i}_username, u{$i}.downloaded AS user{$i}_downloaded, u{$i}.uploaded AS user{$i}_uploaded, u{$i}.user_id AS user{$i}_user_id, u{$i}.donor AS user{$i}_donor, u{$i}.warned AS user{$i}_warned, u{$i}.status AS user{$i}_status";
$where[] = "LEFT JOIN users AS u{$i} ON u{$i}.invited_by = u".($i - 1).".user_id";
$order[] = "user{$i}_username ASC";
}
stdhead("Invite Tree");
print("<h1 class=\"center\">".($user ? "Invite tree of $user" : "My invite tree")."</h1>\n");
print("<div class=\"border\">\n");
print("<ul>\n");
$res = sql_query("SELECT ".implode(", ", $fields)." FROM users AS u0 ".implode(" ",$where)." WHERE u0.user_id = $id AND (u1.status = 'enabled' OR u1.status = 'parked') ORDER BY ".implode(", ", $order)) or sqlerr(__FILE__, __LINE__);
while ($arr = mysql_fetch_assoc($res)) {
if ($prev["user1_username"] <> $arr["user1_username"]) {
if ($arr["user1_downloaded"] > 0) {
$ratio = number_format($arr["user1_uploaded"] / $arr["user1_downloaded"], 3);
$ratio = "<span style=\"color: ".get_ratio_color($ratio)."\">$ratio</span>";
} elseif ($arr["user1_uploaded"])
$ratio = "Inf.";
else
$ratio = "---";
$pics = ($arr["user1_donor"] == "yes" ? "<img class=\"noborder\" src=\"$PICTURE_DIR/star.gif\" alt=\"Donor\" title=\"Donor\" style=\"margin-left: 1pt\" />" : "");
$pics .= ($arr["user1_status"] == "parked" ? "<img class=\"noborder\" src=\"$PICTURE_DIR/parked.gif\" alt=\"Parked\" title=\"Parked\" style=\"margin-left: 1pt\" />" : "");
$pics .= ($arr["user1_warned"] <> "no" ? "<img class=\"noborder\" src=\"$PICTURE_DIR/warned.gif\" alt=\"Warned\" title=\"Warned\" style=\"margin-left: 1pt\" />" : "");
$pics .= ($arr["user1_status"] == "disabled" ? "<img class=\"noborder\" src=\"$PICTURE_DIR/disabled.gif\" alt=\"Disabled\" title=\"Disabled\" style=\"margin-left: 1pt\" />" : "");
if ($CURUSER["class"] >= UC_FORUM_MODERATOR)
$extra = $pics." ($ratio)";
if (isset($prev))
print("</ul><ul>\n");
print("<li><a href=\"userdetails.php?id=$arr[user1_user_id]\"><strong>$arr[user1_username]</strong></a>$extra</li>\n");
}
for ($i = 2; $i <= $num; $i++) {
$levstr = "user{$i}_";
$prevlevstr = "user".($i - 1)."_";
if (($levstr <> $prevlevstr) && ($arr[$levstr."username"] <> NULL)) {
print("<ul>\n");
$set++;
}
if ($arr[$levstr."downloaded"] > 0) {
$ratio = number_format($arr[$levstr."uploaded"] / $arr[$levstr."downloaded"], 3);
$ratio = "<span style=\"color: ".get_ratio_color($ratio)."\">$ratio</span>";
} elseif ($arr[$levstr."uploaded"])
$ratio = "Inf.";
else
$ratio = "---";
$pics = ($arr[$levstr."donor"] == "yes" ? "<img class=\"noborder\" src=\"$PICTURE_DIR/star.gif\" alt=\"Donor\" title=\"Donor\" style=\"margin-left: 1pt\" />" : "");
$pics .= ($arr[$levstr."status"] == "parked" ? "<img class=\"noborder\" src=\"$PICTURE_DIR/parked.gif\" alt=\"Parked\" title=\"Parked\" style=\"margin-left: 1pt\" />" : "");
$pics .= ($arr[$levstr."warned"] <> "no" ? "<img class=\"noborder\" src=\"$PICTURE_DIR/warned.gif\" alt=\"Warned\" title=\"Warned\" style=\"margin-left: 1pt\" />" : "");
$pics .= ($arr[$levstr."status"] == "disabled" ? "<img class=\"noborder\" src=\"$PICTURE_DIR/disabled.gif\" alt=\"Disabled\" title=\"Disabled\" style=\"margin-left: 1pt\" />" : "");
if ($CURUSER["class"] >= UC_FORUM_MODERATOR)
$extra = $pics." ($ratio)";
if (($arr[$levstr."username"] <> NULL) && ($arr[$prevlevstr."username"] <> $prev[$prevlevstr."username"]))
print("<li>$spacer<a href=\"userdetails.php?id=".$arr[$levstr."user_id"]."\"><strong>".$arr[$levstr."username"]."</strong></a>$extra</li>\n");
elseif (($arr[$levstr."username"] <> NULL) && ($arr[$levstr."username"] <> $prev[$levstr."username"]))
print("<li>$spacer<a href=\"userdetails.php?id=".$arr[$levstr."user_id"]."\"><strong>".$arr[$levstr."username"]."</strong></a>$extra</li>\n");
if (($i == $num) && isset($set)) {
for ($j = 0; $j < $set; $j++)
print("</ul>\n");
unset($set);
}
$prev[$levstr."username"] = $arr[$levstr."username"];
}
$prev["user1_username"] = $arr["user1_username"];
}
print("</ul>\n");
print("</div>\n");
stdfoot();
?>