<?
function avatar_comm($id,$size = 50)
{
	if (is_file(H."sys/comm/avatar/$size/$id.jpg"))
	{
		echo '<img class="avatar" src="/sys/comm/avatar/' . $size . '/' . $id . '.jpg?r='.rand(0,9000).'" alt="Avatar"  width="' . $size . '" />';
	}
	else
	{
		echo '<img class="avatar" src="/style/user/avatar.gif" width="' . $size . '" alt="No Avatar" />';
	}
}

function get_comm($id)
{
	$commid = intval($id);
	$comm = mysql_fetch_array(mysql_query("SELECT * FROM `comm` WHERE `id` = '$commid'"));
	return $comm;
}
function comm_name($id,$image = 0)
{
	$commid = intval($id);
	$comm = mysql_fetch_array(mysql_query("SELECT * FROM `comm` WHERE `id` = '$commid'"));
	$img = '<img width="12" height="12" src="/style/icons/comm_open.gif" alt="open"/>';
	if($comm['close']==1)$img = '<img width="12" height="12" src="/style/icons/comm_close.png" alt="close"/>';
	$name = ''.$img.'<a href="/comm/'.$commid.'/">'.my_esc($comm['name']).'</a>';
	if($image==1)$name = '<a href="/comm/'.$commid.'/">'.my_esc($comm['name']).'</a>';
	return $name;
}
function comm_user_group($level)
{
	$userlevel = intval($level);
	$st = NULL;
	if($level==1)$st = '<font size="2">(Модератор)</font>';
	if($level==2)$st = '<font size="2">(Администратор)</font>';
	if($level==3)$st = '<font size="2">(Создатель)</font>';
	return $st;
}
function comm_files($path,$comm)
{
	$path=preg_replace("#(/){1,}#","/",$path);
	$path=preg_replace("#(^(/){1,})|((/){1,}$)#","",$path);
	$path_arr=explode('/',$path);
	$rudir=NULL;
		for ($i=0;$i<count($path_arr);$i++)
		{
			$of='/';
			for ($z=0;$z<=$i;$z++)$of.=$path_arr[$z].'/';
			$dir_id=mysql_fetch_assoc(mysql_query("SELECT * FROM `comm_obmen` WHERE `id` = '$path_arr[$i]' LIMIT 1"));
			$dirname=$dir_id['name'];
			$rudir.=' <a href="/comm/obmen/'.$comm.'/'.$dir_id['id'].'/">'.text(htmlspecialchars($dirname)).'</a> &gt; ';

		}
return preg_replace("# &gt; $#","",$rudir);
}
?>