<?

header('Cache-Control: no-store, no-cache, must-revalidate');	// HTTP/1.1



//require_once"includers/start.php";
//require_once"includers/sid.php";
//require("config.php");
require( "../inc/conf.inc.php" );
require( "../inc/check.php" );
mysql_query( "update users set `ltime`='".time( )."', `lroom`='17' where id='{$id}' and ci='".$ci."';" );
echo "<title>-=Кланы=-</title>";
echo "<link rel=\"../shortcut icon\" href=\"../favicon.ico\">";
echo "<meta http-equiv=\"refresh\" content=\"{$avr}\">";
echo "<style type=\"text/css\">";
echo "body { margin: auto; max-width: 500px; font: 12px Arial; color: #808080; background-color: #000000; }";
echo "a:link,a:visited { text-decoration: none; color: b0c4db; }";
echo "div { background-color: #202020; border-style:solid; border-width: 1px; }";
echo "img { vertical-align: middle; }";
echo "</style>";
echo "</head>";
echo "<body>\n";



//$link = connect_db();
//list($row, $id, $ps, $fsize1, $fsize2) = check_login($link);
//require("version.php");

$mid = intval(check($mid));

if(empty($tyu))$tyu="left";
if(empty($title))$title="Кланы";
//include("obolochka.php");
echo "<div>Кланы</div>";
$mod = check($mod);
switch($mod) {

case "admin" :
echo $fsize1;
$q = @mysql_query("select * from `clans` where id='".$mid."';");
$arr = @mysql_fetch_array($q);
if ($row["level"]<10&&$arr['lider']!=$id){

echo "<div>Доступ закрыт!</div>";

}
else
{
echo "Управление кланом <b>".$arr['name']."</b><br />\n";
$q2 = mysql_query ("select count(id) as num from users where clanz='".$mid."';");
$bl2 = mysql_fetch_array($q2);
$num2 = $bl2["num"];
echo "<img src=\"fd.gif\" alt=\"[MODER]\"/>  <a href=\"clans.php?ci={$ci}&amp;id={$id}&amp;pass={$pass}&amp;url={$url}&amp;mid=".$mid."&amp;mod=zaiavka\">Заявки на вступление</a>(".$num2.")<br />\n";
echo "<img src=\"fd.gif\" alt=\"[MODER]\"/>  <a href=\"clans.php?ci={$ci}&amp;id={$id}&amp;pass={$pass}&amp;url={$url}&amp;mid=".$mid."&amp;mod=edit\">Изменить</a><br />\n";
echo "<img src=\"fd.gif\" alt=\"[MODER]\"/>  <a href=\"foto.php?ci={$ci}&amp;id={$id}&amp;pass={$pass}&amp;url={$url}&amp;mod=logoclan&amp;mid=$mid\">Добавить лого</a><br />\n";
echo "<img src=\"fd.gif\" alt=\"[MODER]\"/>  <a href=\"clans.php?ci={$ci}&amp;id={$id}&amp;pass={$pass}&amp;url={$url}&amp;mid=".$mid."&amp;mod=mnews\">Добавить Новость</a><br />\n";
echo "<img src=\"fd.gif\" alt=\"[MODER]\"/>  <a href=\"clans.php?ci={$ci}&amp;id={$id}&amp;pass={$pass}&amp;url={$url}&amp;mid=".$mid."&amp;mod=dnews\">Удалить Новость</a><br />\n";
echo "<img src=\"d.png\" alt=\"[DEL]\"/>  <a href=\"clans.php?ci={$ci}&amp;id={$id}&amp;pass={$pass}&amp;url={$url}&amp;mid=".$mid."&amp;mod=delclus\">Удалить клан</a><br />\n";



}

echo $fsize2;
break;

case "edit" :
echo $fsize1;
$q = @mysql_query("select * from `clans` where id='".$mid."';");
$arr = @mysql_fetch_array($q);
if ($row["level"]<10&&$arr['lider']!=$id){

echo "<div>Доступ закрыт!</div>";

}
else
{
$q = mysql_query( "select * from clans where id='$mid';" );
$sect = mysql_fetch_array( $q );
echo "<form action=\"?ci={$ci}&amp;id={$id}&amp;pass={$pass}&amp;url={$url}\" method=\"post\">";
echo "Переименовать клан:<br/>";
echo "<input type=\"text\" name=\"for\" maxlength=\"150\" value=\"{$sect['name']}\"/><br/>";
echo "Описание:<br/>";
echo "<input type=\"text\" name=\"opis\" maxlength=\"150\" value=\"{$sect['opis']}\"/><br/>";
echo "Тип клана:<br/><select name=\"vid\">
<option value=\"1\">Открытый</option>
<option value=\"2\">Закрытый</option>";
echo "</select><br />";
echo "<input type=\"hidden\" name=\"lider\" value=\"$lider\"/>";
echo "<input type=\"hidden\" name=\"mid\" value=\"$mid\"/>";
echo "<input type=\"hidden\" name=\"mod\" value=\"edit1\"/>";
echo "<input type=\"submit\" class=\"ibutton\" value=\"Изменить\" class=\"cp\"><br /><br />";

}
echo $fsize2;
break;
case "edit1" :
$q = @mysql_query("select * from `clans` where id='".$mid."';");
$arr = @mysql_fetch_array($q);
if ($row["level"]<10&&$arr['lider']!=$id){

echo "<div>Доступ закрыт!</div>";
break;
}
else
{
$for = htmlspecialchars($for);
$for = substr( $for, 0, 300 );
if (empty($for))
{   echo $fsize1;
echo "<div>Вы не заполнили название!</div>";
echo $fsize2;
break;
}
else
{
if ($row["translit"]==1) $for = trun_to_rus($for);
if ($row["translit"]==1) $opis = trun_to_rus($opis);
if(empty($lider)){
$lider1 = $arr['lider'];
}else{
$lider1 = $lider;
}

$add = "UPDATE `clans` SET name='".$for."', opis='".$opis."', lider='".$lider1."', vid='".$vid."' where id='".$mid."';";
if (mysql_query($add))
{   echo $fsize1;
echo "<div>Клан успешно изменен!</div>";

echo $fsize2;
break;
}
else
{   echo $fsize1;
$msg = "<div>Произошла ошибка...</div>";
echo $fsize2;
break;
}

}
}
break;

case 'delus':
$q = @mysql_query("select * from `clans` where id='".$mid."';");
$arr = @mysql_fetch_array($q);
if ($row["level"]<10&&$arr['lider']!=$id){

echo "<div>Доступ закрыт!</div>";
break;
}
else
{
$q = mysql_query("select * from clans where id='".$mid."';");
$data = mysql_fetch_array($q);
$name = $data['name'];
if (@mysql_query ("update users set clan='' where id='".$usid."';")){

echo $fsize1;
header("Location: ?wap=$wap&id=$id&ps=$ps&mid=".$mid."&mod=who");
echo $fsize2; }
}
break;

case 'mnews':
$q = @mysql_query("select * from `clans` where id='".$mid."';");
$arr = @mysql_fetch_array($q);
if ($row["level"]<10&&$arr['lider']!=$id){

echo "<div>Доступ закрыт!</div>";
break;
}
else
{
$content=trim(htmlspecialchars(stripslashes($content)));
$date=date("j.m.Y");
if(empty($content)) $error=$error."<u>Пустое содержание новости!</u><br/>";
if(empty($action)) {
echo $fsize1;
echo "Новость:<br/>";
echo $fsize2;

if ($wap=="1"){
echo $fsize1;
echo "<input name=\"content\"/><br/>";
echo "<anchor>Добавить<go href=\"?ci={$ci}&amp;id={$id}&amp;pass={$pass}&amp;url={$url}$takep&amp;mod=mnews&amp;mid=".$mid."\" method=\"post\">";
echo "<postfield name=\"action\" value=\"add\"/>";
echo "<postfield name=\"content\" value=\"$(content)\"/>";
echo "<postfield name=\"date\" value=\"$date\"/>";
echo "</go></anchor>";
echo $fsize2;
echo "<br/>";
}else{
echo "<form method=\"POST\" action=\"?ci={$ci}&amp;id={$id}&amp;pass={$pass}&amp;url={$url}$takep&amp;mod=mnews&amp;mid=".$mid."\" name=\"auth\">\n";
echo "<input name=\"content\"/><br/>";
echo "<input type=\"hidden\" name=\"action\" value=\"add\"/>";
echo "<input type=\"hidden\" name=\"date\" value=\"$date\"/>";
echo "<input type=\"submit\" class=\"ibutton\" value=\"Добавить\" name=\"enter\"><br/>\n";
}
} else {
if(empty($error)) {
if($content!=$last_news['content']) {
if ($row["level"]>=10 )
{
$content = eregi_replace( "[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]", "<a href=\"\\0\">\\0</a>", $content );
}
else
{
$content = eregi_replace( "[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]", "<a href=\"http://masteram.us\">v4ate.us</a>", $content );
}
require( "../sm/convert_to_smiles.php" );
$minpos = 500; $nm = 500;
for ($j=0;$j<=count($smiles)-1;$j++){
$tmpp = strpos($content,$smiles[$j]);
if (($tmpp < $minpos)&&($tmpp !== false)){
$minpos = $tmpp; $nm = $j;};};
if ($minpos !=500){
if ($row["translit"]!=1){
$st1 = substr($content,0,$minpos+strlen($smiles[$nm]));
$st2 = substr($content,$minpos+strlen($smiles[$nm]),strlen($content)-strlen($st1));
$st1_wosm = $st1;
$st1 = str_replace($smiles[$nm],$replaces[$nm],$st1);
if (strpos($replaces[$nm],"smilean/")!==false) $st1_woasm = $st1_wosm; else $st1_woasm = $st1;
$content_woasm = $st1.$st2;
$content_wosm = $st1_wosm.$st2;
$content = $st1_woasm.$st2;}
else{$st1 = substr($content,0,$minpos);
$st2 = substr($content,$minpos, strlen($smiles[$nm]));
$st3 = substr($content,$minpos+strlen($smiles[$nm]),strlen($content)-strlen($st1)-strlen($st2));
$st1 = trun_to_rus($st1);
$st2_wosm = $st2;
$st2 = $replaces[$nm];
if (strpos($replaces[$nm],"smilean/")!==false) $st2_woasm = $st2_wosm; else $st2_woasm = $st2;
$st3 = trun_to_rus($st3);
$content = $st1.$st2_woasm.$st3;
$content_wosm = $st1.$st2_wosm.$st3;
$content_woasm = $st1.$st2.$st3;}}
else if ($row["translit"]==1) $content = trun_to_rus($content);
unset($smiles);
unset($replaces);
if(mysql_query("insert into newsclan values(0,'".$us."','".$content."','".$date."','".$mid."');")) {
echo $fsize1;
echo "<b>Ваша новость успешно добавлена!</b><br/>";
echo $fsize2;
} else {
echo $fsize1;
echo "<b>Ошибка записи новости!</b><br/>";
echo $fsize2;
}
} else {
echo $fsize1;
echo "<b>Такая новость уже добавлена!</b><br/>";
echo $fsize2;
}
} else {
echo $fsize1;
echo $error;
echo $fsize2;
}
}
}
break;

case 'dnews':
$q = @mysql_query("select * from `clans` where id='".$mid."';");
$arr = @mysql_fetch_array($q);
if ($row["level"]<10&&$arr['lider']!=$id){

echo "<div>Доступ закрыт!</div>";
break;
}
else
{
$q = mysql_query("select id,content from newsclan where clan='".$mid."' order by id desc;");
if (mysql_affected_rows() == 0) {
echo $fsize1;
echo "Новостей нет!!!<br/>\n";
echo $fsize2;
} else {
if(empty($action)) {
while($arr=mysql_fetch_array($q)) {
echo $fsize1;
echo "<a href=\"?action=del&amp;ci={$ci}&amp;id={$id}&amp;pass={$pass}&amp;url={$url}$takep&amp;mod=dnews&amp;fid=".$arr['id']."&amp;mid=".$mid."$takep\">".$arr['id'].":</a> ".$arr['content']."<br/>";
echo $fsize2;
}
} else {
if(mysql_query("delete from newsclan where id='".$fid."' limit 1;")){
echo $fsize1;
echo "<b>Запись успешно удалена!</b><br/>";
echo $fsize2;
}
}
}
}
break;
////////////////////////////

case 'zaiavka':
$q = @mysql_query("select * from `clans` where id='".$mid."';");
$arr = @mysql_fetch_array($q);
if ($row["level"]<10&&$arr['lider']!=$id){

echo "<div>Доступ закрыт!</div>";

}
else
{
echo $fsize1;
if(empty($s)) $s=0;
$query = mysql_query("select * from clans where id='$mid';");
$num_of_rows=mysql_num_rows($query);
$total_mat_number=$num_of_rows;
$max = 20;
$total_ss=ceil($total_mat_number/$max);
$r = mysql_query ("select * from `users` where clanz='".$mid."' limit ".$s.",".$max.";");
$i = 1+$s;
echo "<b>Юзеры желающие вступить в Клан:</b><br /><br />\n";
while($arr = mysql_fetch_array($r)) {

echo ($i++).")  <b><a href=\"search.php?ci={$ci}&amp;id={$id}&amp;pass={$pass}&amp;url={$url}&amp;go=view$takep2&amp;nick=".$arr['id']."\">".$arr['login']."</a></b>";

$q1 = @mysql_query("select * from `clans` where id='".$mid."';");
$arr1 = @mysql_fetch_array($q1);
if ($row["level"]>10||$arr1['lider']==$id){
echo " <a href=\"?ci={$ci}&amp;id={$id}&amp;pass={$pass}&amp;url={$url}&amp;mod=zok$takep2&amp;usid=".$arr['id']."&amp;mid=$mid\">[Принять]</a></b><br/>";
}else{
echo "<br />\n";
}

}

for ($num=0; $num<$total_ss; $num++){
$s_number=$num*$max;
if ($s_number!=$s) {
echo "<a href=\"clans.php?go=golos&amp;ci={$ci}&amp;id={$id}&amp;pass={$pass}&amp;url={$url}&amp;s=$s_number&amp;mod=read\">".($num+1)."</a>|";
} else {
echo "".($num+1)."|";
}
}
echo $fsize2;
}
break;

case 'zok':
$q = @mysql_query("select * from `clans` where id='".$mid."';");
$arr = @mysql_fetch_array($q);
if ($row["level"]<10&&$arr['lider']!=$id){

echo "<div>Доступ закрыт!</div>";
break;
}
else
{
$q = mysql_query("select * from clans where id='".$mid."';");
$data = mysql_fetch_array($q);
$name = $data['name'];
if (@mysql_query ("update users set clan='".$mid."' where id='".$usid."';")&&@mysql_query ("update users set clanz='' where id='".$usid."';")){

echo $fsize1;
header("Location: ?wap=$wap&id=$id&ps=$ps&mid=".$mid."&mod=zaiavka");
echo $fsize2; }
}
break;
//////////////////////////////////

case 'who':
echo $fsize1;
if(empty($s)) $s=0;
$query = mysql_query("select * from clans where id='$mid';");
$num_of_rows=mysql_num_rows($query);
$total_mat_number=$num_of_rows;
$max = 20;
$total_ss=ceil($total_mat_number/$max);
$r = mysql_query ("select * from `users` where clan='".$mid."' limit ".$s.",".$max.";");
$i = 1+$s;
while($arr = mysql_fetch_array($r)) {

echo ($i++).")  <b><a href=\"search.php?ci={$ci}&amp;id={$id}&amp;pass={$pass}&amp;url={$url}&amp;go=view$takep2&amp;nick=".$arr['id']."\">".$arr['login']."</a></b>";

$q1 = @mysql_query("select * from `clans` where id='".$mid."';");
$arr1 = @mysql_fetch_array($q1);
if ($row["level"]>10||$arr1['lider']==$id){
echo " <a href=\"?ci={$ci}&amp;id={$id}&amp;pass={$pass}&amp;url={$url}&amp;mod=delus$takep2&amp;usid=".$arr['id']."&amp;mid=$mid\">[Выгнать]</a></b><br/>";
}else{
echo "<br />\n";
}

}

for ($num=0; $num<$total_ss; $num++){
$s_number=$num*$max;
if ($s_number!=$s) {
echo "<a href=\"clans.php?go=golos&amp;ci={$ci}&amp;id={$id}&amp;pass={$pass}&amp;url={$url}&amp;s=$s_number&amp;mod=read\">".($num+1)."</a>|";
} else {
echo "".($num+1)."|";
}
}
echo $fsize2;
break;

case 'outclan':

$q = mysql_query("select * from clans where id='".$mid."';");
$data = mysql_fetch_array($q);
$name = $data['name'];
if (@mysql_query ("update users set clan='' where id='".$id."';")){

echo $fsize1;
echo "<b>Вы покинули клан ".$name."!</b><br/>";
echo $fsize2; }
break;

case 'inclan':
$q = @mysql_query("select * from `users` where id='$id';");
$arr = @mysql_fetch_array($q);

if ($arr['clan']!=0){
echo $fsize1;
echo "<b>Вы не можете вступить в клан, так как уже состоите в другом клане!</b><br/>";
print $fsize2;
}else{
$q = mysql_query("select * from clans where id='".$mid."';");
$data = mysql_fetch_array($q);
$name = $data['name'];
if (@mysql_query ("update users set clan='".$mid."' where id='".$id."';")){

echo $fsize1;
echo "<b>Вы вcтупили в клан ".$name."!</b><br/>";
echo $fsize2; }

}

break;

case 'inclan2':
$q = @mysql_query("select * from `users` where id='$id';");
$arr = @mysql_fetch_array($q);

if ($arr['clan']!=0){
echo $fsize1;
echo "<b>Вы не можете вступить в клан, так как уже состоите в другом клане!</b><br/>";
print $fsize2;
}else{
$q = mysql_query("select * from clans where id='".$mid."';");
$data = mysql_fetch_array($q);
$name = $data['name'];
if (@mysql_query ("update users set clanz='".$mid."' where id='".$id."';")){

echo $fsize1;
echo "Заявка на вступление в клан <b>".$name."</b> принята!<br/>";
echo $fsize2;
}else{
echo "<b>Ошибка!</b>\n";
}

}

break;

case 'view':

$q = @mysql_query("select * from `clans` where id='".$mid."';");
$arr = @mysql_fetch_array($q);

$av = mysql_query ("select * from `users` where id='".$arr['lider']."'");
$avt = mysql_fetch_array($av);
echo $fsize1;

$q2 = mysql_query ("select count(id) as num from users where clan='".$mid."';");
$bl2 = mysql_fetch_array($q2);
$num2 = $bl2["num"];

echo "<u>Клан</u> <b>".$arr['name']."</b><br />\n";
$logot = $arr['logo'];
$vid = $arr['vid'];
if(@$logot!=""){
$logot = UrlEncode($logot);
echo "<img src=\"./logoclan/".$logot."\"/><br/>\n";
}
echo "<u>О клане:</u><br />".$arr['opis']."<br />\n";
echo "<u>Лидер клана:</u> <b><a href=\"../search.php?ci={$ci}&amp;id={$id}&amp;pass={$pass}&amp;url={$url}&amp;go=view$takep2&amp;nick=".$avt['login']."\">".$avt['login']."</a></b><br />\n";
echo "<u>Участников:</u> <b><a href=\"clans.php?ci={$ci}&amp;id={$id}&amp;pass={$pass}&amp;url={$url}&amp;mid=".$mid."&amp;mod=who\">$num2</a></b><br />\n";
$sten=mysql_fetch_array(mysql_query("SELECT COUNT(id) from stenaclan WHERE mid = '".$mid."'"));
$new = mysql_query ("select count(id) as num from newsclan where clan='".$mid."';");
$news = mysql_fetch_array($new);
$numn = $news["num"];
echo "<a href=\"clans.php?ci={$ci}&amp;id={$id}&amp;pass={$pass}&amp;url={$url}&amp;mid=".$mid."&amp;mod=news\">Новости Клана</a>(".$numn.")<br/>\n";
echo "<a href=\"clanstena.php?ci={$ci}&amp;id={$id}&amp;pass={$pass}&amp;url={$url}&amp;mid=".$mid."\">Стена сообщений</a>(".$sten[0].")<br/>\n";
if ($row['clan']!=$mid){

if ($arr['vid'] == 1){
echo "<br />$div2 Клан Открытый. Вступить может любой желающий!<br />\n";
echo "<a href=\"clans.php?ci={$ci}&amp;id={$id}&amp;pass={$pass}&amp;url={$url}&amp;mid=".$mid."&amp;mod=inclan\">Вступить</a>$div9<br />\n";
}else if ($arr['vid'] == 2){
echo "<br />$div2 Клан Закрытый. Вступление должен подтвердить Лидер клана!<br />\n";
echo "<a href=\"clans.php?ci={$ci}&amp;id={$id}&amp;pass={$pass}&amp;url={$url}&amp;mid=".$mid."&amp;mod=inclan2\">Вступить</a>$div9<br />\n";
}

}else{
echo "<br /><a href=\"clans.php?ci={$ci}&amp;id={$id}&amp;pass={$pass}&amp;url={$url}&amp;mid=".$mid."&amp;mod=outclan\">Покинуть клан</a><br />\n";
}
if ($row["level"]>10||$arr['lider']==$id){
echo "<br /><dl><dt></dt></dl><img src=\"fd.gif\" alt=\"[MODER]\"/>  <a href=\"clans.php?ci={$ci}&amp;id={$id}&amp;pass={$pass}&amp;url={$url}&amp;mid=".$mid."&amp;mod=admin&amp;usid=".$arr['avtor']."\">Управление</a><dl><dt></dt></dl><br />\n";
}
echo $fsize2;
break;

case 'news':
$new = mysql_query ("select count(id) as num from newsclan where clan='".$mid."';");
$news = mysql_fetch_array($new);
$num = $news["num"];
if(!isset($s))$s=0;
$mx=round(($num/5)+0.45);
if($s>$mx)$s=$mx;
if($s<=0)$s=1;
$ot=(($s-1)*5)+1;
$do=$s*5;
if($do>$num)$do=$num;
$o=$ot-1;
$n=$ot;
if($do==0)$n=$o;
echo $fsize1;
echo "Показывает $n-$do из $num<br/>\n";
echo $divide;
echo $fsize2;
$r = mysql_query ("select * from newsclan where clan='".$mid."' order by id desc limit $o,$do");
$re = mysql_query ("select id from newsclan where clan='".$mid."' order by id desc limit $o,$do");
for ($i=$ot;$i<=$do;$i++){
$arr = mysql_fetch_array($r);
$arr2 = mysql_fetch_array($re);
echo $fsize1;
echo "<b>".$arr['date']."</b><br/> ".$arr['content']."<br/>";
echo "<u>Разместил(а):</u><b> <a href=\"search.php?ci={$ci}&amp;id={$id}&amp;pass={$pass}&amp;url={$url}&amp;go=view$takep2&amp;nick=".$arr['login']."\">".$arr['login']."</a></b><br/>";
//$koms=mysql_fetch_array(mysql_query("SELECT COUNT(id) from newskom WHERE mid = '".$arr2['id']."'"));
//echo "<a href=\"newskom.php?$ses&amp;mid=".$arr2['id']."\">Коментарии</a>(".$koms[0].")<br/>\n";
echo $divide;
echo $fsize2;
}
$next=$s+1;
$prev=$s-1;
if ($num>$do) {
$ot=(($next-1)*5)+1;
$do=$next*5;
if($do>$num)$do=$num;
echo $fsize1;
echo "$div1<a href=\"?ci={$ci}&amp;id={$id}&amp;pass={$pass}&amp;url={$url}&amp;s=$next\">&gt;&gt;$ot-$do&gt;&gt;</a>$div9\n";
echo $fsize2;
}
if($s>1) {
$ot=(($prev-1)*5)+1;
$do=$prev*5;
echo $fsize1;
echo "$div1<a href=\"?ci={$ci}&amp;id={$id}&amp;pass={$pass}&amp;url={$url}&amp;s=$prev\">&lt;&lt;$ot-$do&lt;&lt;</a>$div9\n";
echo $fsize2;
}
break;
default:
echo $fsize1;
if(empty($s)) $s=0;
$query = mysql_query("select * from clans where id>0;");
$num_of_rows=mysql_num_rows($query);
$total_mat_number=$num_of_rows;
$max = 20;
$total_ss=ceil($total_mat_number/$max);
$r = mysql_query ("select * from `clans` order by users desc limit ".$s.",".$max.";");
$i = 1+$s;
while($arr = mysql_fetch_array($r)) {
$q2 = mysql_query ("select count(id) as num from users where clan='".$arr['id']."';");
$bl2 = mysql_fetch_array($q2);
$num2 = $bl2["num"];

$av = mysql_query ("select * from `users` where id='".$arr['avtor']."'");
$avt = mysql_fetch_array($av);
echo ($i++).") <a href=\"clans.php?ci={$ci}&amp;id={$id}&amp;pass={$pass}&amp;url={$url}&amp;mid=".$arr['id']."&amp;mod=view\">".$arr['name']."</a> [".$num2."]<br/>";
}
echo "<dl><dt></dt></dl>\n";
for ($num=0; $num<$total_ss; $num++){
$s_number=$num*$max;
if ($s_number!=$s) {
echo "<a href=\"clans.php?go=golos&amp;ci={$ci}&amp;id={$id}&amp;pass={$pass}&amp;url={$url}&amp;s=$s_number&amp;mod=read\">".($num+1)."</a>|";
} else{
echo "".($num+1)."|";
}
}
echo "<dl><dt></dt></dl>\n";
echo "<a href=\"clans.php?id={$id}&amp;pass={$pass}&amp;mod=add\">Создать клан</a><br />\n";
echo $fsize2;
break;


case 'add':
$q11 = mysql_query("select * from users where id='$id';");
$q22=mysql_num_rows($q11);
$q0 = mysql_query("select * from `clans`;");
$cl0 = @mysql_fetch_array($q0);
if ($cl0['lider']==$id)
{
echo "<b>У вас уже есть клан!</b><br />\n";
}else if ($row['posts']<$postclan){

echo "<b>Вы пока не можете создавать кланы!</b><br />\n";
}else{

if(empty($name)) 
{
echo "<b>Создать клан:</b><br /><br />\n";
echo "<form action=\"clans.php?ci={$ci}&amp;id={$id}&amp;pass={$pass}&amp;url={$url}&amp;mod=add\" method=\"post\"><br/>";
echo "Название:<br/><input name=\"name\" maxlength=\"50\"/><br/>\n";
echo "Описание:<br/><input type=\"text\" name=\"opis\" maxlength=\"1000\"/><br />\n";
echo "Тип клана:<br/><select name=\"vid\">
<option value=\"1\">Открытый</option>
<option value=\"2\">Закрытый</option>";
echo "</select><br /><br />";
echo "<input type=\"submit\" class=\"ibutton\" value=\"Добавить\"></form>";

}else{
$name = trim(addslashes(htmlspecialchars($name)));
$opis = trim(addslashes(htmlspecialchars($opis)));
$name = check($name);
$opis = check($opis);
if ($row["translit"]==1) $name = trun_to_rus($name);
if ($row["translit"]==1) $opis = trun_to_rus($opis);
if(@mysql_query("insert into `clans` values(0,'".$id."','$name','$opis',1,'','$vid');") ) {

$q2 = mysql_query("select * from `clans` where `name`='".$name."';");
$last_cl = @mysql_fetch_array($q2);
$idclan = $last_cl['id'];
mysql_query("update `users` set `clan`='".$idclan."' where `id`='".$id."';");
echo $fsize1; print "<b>Клан успешно создан!</b><br />";echo $fsize2;



} else {echo $fsize1; print $lang['error'];echo $fsize2; }

}
}
break;


case 'delclus':
$q = @mysql_query("select * from `clans` where id='".$mid."';");
$arr = @mysql_fetch_array($q);
if ($row["level"]<10&&$arr['lider']!=$id){

echo "<div>Доступ закрыт!</div>";

}
else
{
if(@mysql_query("delete from `clans` where `id`='$mid' limit 1;")&& @mysql_query("update `users` set `clan`='' where `clan`='".$mid."';"))
echo $fsize1; echo "<b>Запись успешно удалена!</b><br />\n"; echo $fsize2;
}
break;
}
echo $fsize1;
echo $divide;
echo "<br />\n";
if($mod!="view") {
if($mid) {
$q = @mysql_query("select * from `clans` where id='".$mid."';");
$arr = @mysql_fetch_array($q);
print "$div1<a href=\"clans.php?ci={$ci}&amp;id={$id}&amp;pass={$pass}&amp;url={$url}&amp;mod=view&amp;mid=$mid\"><b>".$arr['name']."</b></a>$div9";
}
}
if($mod) {
print "$div1<a href=\"clans.php?ci={$ci}&amp;id={$id}&amp;pass={$pass}&amp;url={$url}\">Кланы</a>$div9";
}


echo "<div><a href=\"../enter.php?ci={$ci}&amp;id={$id}&amp;pass={$pass}&amp;url={$url}\">Прихожая</a></div>";
echo $div2;
//info_compress();
echo $div9;
echo $fsize2;
echo "</div></body></html>";
mysql_close($link);
?>