<?

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

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";
$cm = mysql_query ("select count(id) as num from stenaclan WHERE 1;");
$cmc = mysql_fetch_array($cm);
$news = $cmc["num"];


if(empty($tyu))$tyu="left";
if(empty($title))$title="Стена сообщений";
//include("obolochka.php");
echo $fsize1;
echo "$div1<b>Стена сообщений</b>$div9\n";
echo $fsize2;
$new = mysql_query ("select count(id) as num from stenaclan WHERE mid='$mid';");
$mod = check($mod);
switch($mod) {
default:
$news = mysql_fetch_array($new);
$num = $news["num"];
if(!isset($s))$s=0;
$mx=round(($num/10)+0.45);
if($s>$mx)$s=$mx;
if($s==0)$s=1;
$ot=(($s-1)*10)+1;
$do=$s*10;
if($do>$num)$do=$num;
$o=$ot-1;
$n=$ot;
if($do==0)$n=$o;
echo $fsize1;
echo "$div4 Показывает $n-$do из $num$div9\n";
echo $divide;
echo $fsize2;
$r = mysql_query ("select * from `stenaclan` WHERE mid='$mid' order by id desc limit $o,$do");
for ($i=$ot;$i<=$do;$i++){
$arr = mysql_fetch_array($r);
echo $fsize1;
$qw = @mysql_query("select * from `clans` where id='".$mid."';");
$www = @mysql_fetch_array($qw);
if ($row["level"]>=10&&$www['lider']==$id){
echo "<a href=\"clanstena.php?ci={$ci}&amp;id={$id}&amp;pass={$pass}&amp;url={$url}&amp;mod=del&amp;mid=$mid&amp;fid=".$arr['id']."\">[X]</a> ";
}
echo "<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>(".$arr['date'].")&gt; ".$arr['content']."<br/>";

echo $divide;
echo $fsize2;
}
$next=$s+1;
$prev=$s-1;
if ($num>$do) {
$ot=(($next-1)*10)+1;
$do=$next*10;
if($do>$num)$do=$num;
echo $fsize1;
echo "$div1<a href=\"clanstena.php?ci={$ci}&amp;id={$id}&amp;pass={$pass}&amp;url={$url}&amp;s=$next&amp;mid=$mid\">&gt;&gt;$ot-$do&gt;&gt;</a>$div9\n";
echo $fsize2;
}
if($s>1) {
$ot=(($prev-1)*10)+1;
$do=$prev*10;
echo $fsize1;
echo "$div1<a href=\"clanstena.php?ci={$ci}&amp;id={$id}&amp;pass={$pass}&amp;url={$url}&amp;s=$prev&amp;mid=$mid\">&lt;&lt;$ot-$do&lt;&lt;</a>$div9\n";
echo $fsize2;
}
echo $fsize1;
echo $divide;
if($row['clan']==$mid){
echo "<br /> $div1<a href=\"clanstena.php?ci={$ci}&amp;id={$id}&amp;pass={$pass}&amp;url={$url}&amp;mod=add&amp;mid=$mid\">Написать</a>$div9\n";
}else{
echo "<br /> $div1 Оставлять сообщения могут только участники клана! $div9\n";
}
echo $fsize2;

break;

case 'del':
$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
        {
if(mysql_query("delete from stenaclan where id='".$fid."' limit 1;")){
echo $fsize1;
echo "<b>Запись успешно удалена!</b><br/>";
header("Location: ?wap=$wap&id=$id&ps=$ps&mid=".$mid."");

echo $fsize2;
}
}
break;

case 'add':
$content=trim(htmlspecialchars(stripslashes($content)));
$date=date("d/m,H:i");
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=\"clanstena.php?ci={$ci}&amp;id={$id}&amp;pass={$pass}&amp;url={$url}&amp;mod=add&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=\"clanstena.php?ci={$ci}&amp;id={$id}&amp;pass={$pass}&amp;url={$url}&amp;mod=add&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/><br />\n";
}
} else {
if(empty($error)) {
if($content!=$last_news['content']) {
$content = check($content);
if ($row["level"]>=10 )
                {
                    $content = eregi_replace( "[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]", "<a href=\"\\0\">\\0</a>", $content );
                }
                else
                {
                    $content = eregi_replace( "[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]", "".$anti."", $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 stenaclan values(0,'".$mid."','".$row['login']."','".$content."','".$date."');")) {
echo $fsize1;
//header("Location: ?wap=$wap&id=$id&ps=$ps&mid=".$mid."");
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;
}
}
echo $fsize1;
echo "$div1<a href=\"clanstena.php?ci={$ci}&amp;id={$id}&amp;pass={$pass}&amp;url={$url}&amp;mid=$mid\">Стена сообщений</a>$div9\n";
echo $fsize2;
break;

}
echo $fsize1;

echo "$div1<br><a href=\"clans.php?ci={$ci}&amp;id={$id}&amp;pass={$pass}&amp;url={$url}&amp;mid=".$mid."&amp;mod=view\">В Клан</a>$div9";
echo "$div1<br><a href=\"../enter.php?ci={$ci}&amp;id={$id}&amp;pass={$pass}&amp;url={$url}\">Прихожая</a>$div9<br />";
echo $div2;
//info_compress();
echo $div9;
echo $fsize2;
if ($wap=="1")echo "</p></card></wml>";
else echo "</div></body></html>";
mysql_close($link);
?>