All pastes #894897 Raw Edit

Mine

public text v1 · immutable
·published 2008-02-07 11:52 UTC
rendered paste body
<?
require_once("incl/func/main.php");

check_login();

function invite_tree($id) {
	global $CURUSER, $PICTURE_DIR;
	
	$res = sql_query("SELECT user_id, username, status, warned, uploaded, downloaded, invitees FROM users WHERE invited_by = $id AND status = 'enabled' OR status = 'parked' ORDER BY username") or sqlerr(__FILE__, __LINE__);
	$users = count($res);
	
	print("<ul>\n");
	
	while ($arr = mysql_fetch_assoc($res)) {
		
		if ($arr["downloaded"] > 0) {
			
			$ratio = number_format($arr["uploaded"] / $arr["downloaded"], 3);
			$ratio = "<span style=\"color: ".get_ratio_color($ratio)."\">$ratio</span>";
			
		} elseif ($arr["uploaded"])
			$ratio = "Inf.";
		else
			$ratio = "---";
		
		print("<li><strong><a href=\"userdetails.php?id=$arr[user_id]\">$arr[username]</a></strong> ".($CURUSER["class"] >= UC_GLOBAL_MODERATOR ? "($ratio)".get_user_icons($arr) : "")."</li>\n");
		
		if ($arr["invitees"] <> 0)
			invite_tree($arr["user_id"]);
	}
	
	print("</ul>\n");
}

$id = 0 + $_GET["id"];

if (is_valid_id($id) && $CURUSER["class"] >= UC_GLOBAL_MODERATOR) {
	
	$ret = sql_query("SELECT username, donor, invitees FROM users WHERE user_id = $id") or sqlerr(__FILE__, __LINE__);
	$row = mysql_fetch_assoc($ret);
	
	if ($row)
		$user = "<a href=\"userdetails.php?id=$id\">$row[username]</a>".($row["donor"] == "yes" ? "<img class=\"noborder\" src=\"$PICTURE_DIR/starbig.gif\" alt=\"Donor\" title=\"Donor\" style=\"margin-left: 1pt\">" : "");
}

if (!$user) {
	
	$id = $CURUSER["user_id"];
	$row = $CURUSER;
}

if ($row["invitees"] < 1)
	stderr("No invitees", "It appears that ".($row == $CURUSER ? "you have" : "the user you are trying to view the invite tree of has")." not yet invited any users.");

stdhead("Invite tree");

print("<h1>".($user ? "Invite tree of $user" : "My invite tree")."</h1>\n");
print("<div class=\"border\">\n");

invite_tree($id);

print("</div>\n");

stdfoot();
?>