forked from sicalpath/tjupt
-
Notifications
You must be signed in to change notification settings - Fork 2
/
getusername.php
46 lines (42 loc) · 2.65 KB
/
getusername.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
function getusername($id, $big = false, $link = true, $bold = true, $target = false, $bracket = false, $withtitle = false, $link_ext = "", $underline = false)
{
static $usernameArray = array();
global $lang_functions;
$id = 0 + $id;
if (func_num_args() == 1 && $usernameArray[$id]) { //One argument=is default display of username. Get it directly from static array if available
return $usernameArray[$id];
}
$arr = get_user_row($id);
if ($arr) {
if ($big) {
$donorpic = "starbig";
$leechwarnpic = "leechwarnedbig";
$warnedpic = "warnedbig";
$disabledpic = "disabledbig";
$style = "style='margin-left: 4pt'";
} else {
$donorpic = "star";
$leechwarnpic = "leechwarned";
$warnedpic = "warned";
$disabledpic = "disabled";
$style = "style='margin-left: 2pt'";
}
$pics = $arr["donor"] == "yes" ? "<img class=\"" . $donorpic . "\" src=\"pic/trans.gif\" alt=\"Donor\" " . $style . " />" : "";
if ($arr["enabled"] == "yes")
$pics .= ($arr["leechwarn"] == "yes" ? "<img class=\"" . $leechwarnpic . "\" src=\"pic/trans.gif\" alt=\"Leechwarned\" " . $style . " />" : "") . ($arr["warned"] == "yes" ? "<img class=\"" . $warnedpic . "\" src=\"pic/trans.gif\" alt=\"Warned\" " . $style . " />" : "");
else
$pics .= "<img class=\"" . $disabledpic . "\" src=\"pic/trans.gif\" alt=\"Disabled\" " . $style . " />\n";
$username = ($underline == true ? "<u>" . $arr['username'] . "</u>" : $arr['username']);
$username = ($bold == true ? "<b>" . $username . "</b>" : $username);
$username = ($link == true ? "<a " . $link_ext . " target=_blank href=\"userdetails.php?id=$id\" " . ($target == true ? " target=\"_blank\"" : "") . " class='" . get_user_class_name($arr['class'], true) . "_Name'>" . $username . "</a>" : $username) . $pics . ($withtitle == true ? " (" . ($arr['title'] == "" ? get_user_class_name($arr['class'], false, true, true) : "<span class='" . get_user_class_name($arr['class'], true) . "_Name'><b>" . htmlspecialchars($arr['title'])) . "</b></span>)" : "");
$username = "<span class=\"nowrap\">" . ($bracket == true ? "(" . $username . ")" : $username) . "</span>";
} else {
$username = "<i>" . $lang_functions['text_orphaned'] . "</i>";
$username = "<span class=\"nowrap\">" . ($bracket == true ? "(" . $username . ")" : $username) . "</span>";
}
if (func_num_args() == 1) { //One argument=is default display of username, save it in static array
$usernameArray[$id] = $username;
}
return $username;
}