function profile_link($user_id, $user_name, $user_status, $class = "profile-link") {
$result1 = dbquery("SELECT user_groups FROM ".DB_USERS." WHERE `user_id` = '".$user_id."'");
$usergroups = "";
while ($data1 = dbarray($result1)) {
$usergroups = $data1['user_groups'];
}
$newestgroup = "";
$usergroupspieces = explode(".", $usergroups);
if($usergroups)
$newestgroup = $usergroupspieces[1];
else
$newestgroup = "";
$result2 = dbquery("SELECT * FROM ".DB_PREFIX."html_names WHERE `htmlname_usergroup` = '".$newestgroup."'");
$html1 = "";
$html2 = "";
while ($data2 = dbarray($result2)) {
$html1 = html_entity_decode($data2['htmlname_html']);
$html2 = html_entity_decode($data2['htmlname_html2']);
}
global $locale, $settings;
$class = ($class ? " class='$class'" : "");
if ((in_array($user_status, array(0, 3, 7)) || checkrights("M")) && (iMEMBER || $settings['hide_userprofiles'] == "0")) {
$link = "<a href='".BASEDIR."profile.php?lookup=".$user_id."'".$class.">".$html1.$user_name.$html2."";
} elseif ($user_status == "5" || $user_status == "6") {
$link = $locale['user_anonymous'];
} else {
$link = $user_name;
}
return $link;
}