Файл: chats/forum/index.php
Строк: 341
<?php
//////////////////////////////////////////
// CHAT POWERED : http://sim-sim.h2m.ru//
// ICQ : 378036650 //
// Email : olegarhi75@mail.ru //
// WEB SITE Version 1.0 www.waufon.ru //
////////////////////////////////////////
function trun_to_rus( $str )
{
$str = strtolower( $str );
$str = str_replace( "ch", "ч", $str );
$str = str_replace( "sc", "щ", $str );
$str = str_replace( "‘‘", "ъ", $str );
$str = str_replace( "ye", "э", $str );
$str = str_replace( "yu", "ю", $str );
$str = str_replace( "ya", "я", $str );
$str = str_replace( "yi", "ы", $str );
$str = str_replace( "yo", "ё", $str );
$str = str_replace( "sh", "ш", $str );
$str = strtr( $str, array( "a" => "а", "b" => "б", "v" => "в", "g" => "г", "d" => "д", "e" => "е", "j" => "ж", "z" => "з", "i" => "и", "y" => "й", "k" => "к", "l" => "л", "m" => "м", "n" => "н", "o" => "о", "p" => "п", "r" => "р", "s" => "с", "t" => "т", "u" => "у", "f" => "ф", "h" => "х", "c" => "ц", "w" => "ш", "x" => "ы", "'" => "ь" ) );
return $str;
}
require( "../inc/conf.inc.php" );
require( "../inc/check.php" );
$f = intval( $f );
$t = intval( $t );
$p = intval( $p );
$m = intval( $m );
switch ( $mod )
{
case "s1" :
$q = mysql_query( "select name from `forum_sections` where `id`='".$f."' ;" );
$sect = mysql_fetch_array( $q );
echo "<title>Темы</title>rn<style type="text/css">rnbody { font-size: {$fs}; color: {$tcol}; background-color: {$bcol} }rna:link,a:visited { text-decoration: underline; color: {$lcol} }rndiv { background-color: {$rcol} }rn</style>rn</head>rn<body>rn<div align="center"><b>{$sect['name']}</b></div>";
echo "<a href="index.php?id={$id}&pass={$pass}&f={$f}&mod=s2">Новая тема</a>";
$max = $row['num_msgs'];
if ( $p < 0 )
{
$p = 0;
}
$page = $p * $max;
$q1 = mysql_query( "SELECT * from `forum_topic` WHERE section = '{$f}' order by time desc limit {$page},{$max};" );
$k = mysql_num_rows( $q1 );
echo "<div>";
if ( $k == 0 )
{
echo "Здесь тем пока нет :)";
}
while ( $topic = @mysql_fetch_array( @$q1 ) )
{
$time = $topic['time'];
$t = $topic['id'];
$close = $topic['close'];
$q3 = mysql_query( "select id from forum_message where topic = '{$t}'" );
$num = mysql_num_rows( $q3 );
print date( "d.m-H:i", $time )." <b>";
echo "{$topic['login']}<br/><a href="index.php?id={$id}&pass={$pass}&f={$f}&t={$t}&mod=s4">{$topic['name']}</a></b>({$num})";
if ( $close == 1 )
{
echo " <b>[#]</b>";
}
echo "<br/><br/>";
}
echo "</div>";
if ( $max <= $k )
{
++$p;
echo "<a href="index.php?id={$id}&pass={$pass}&f={$f}&p={$p}&mod=s1&p={$p}">Дальше...</a><br/>";
}
echo "<a href="index.php?id={$id}&pass={$pass}&f={$f}&mod=s1&ref={$ref}">В начало</a><br/>";
break;
case "s2" :
$q = mysql_query( "select name from `forum_sections` where `id`='".$f."' ;" );
$sect = mysql_fetch_array( $q );
echo "<title>Форумы</title>rn<style type="text/css">rnbody { font-size: {$fs}; color: {$tcol}; background-color: {$bcol} }rna:link,a:visited { text-decoration: underline; color: {$lcol} }rndiv { background-color: {$rcol} }rn.cp t{ border-style:solid; border-width: 0px; color: {$lcol} ; background-color: {$bcol}; text-align: left }rn</style>rn</head>rn<body>rn<div align="center"><b>Новая тема в «{$sect['name']}»</b></div>";
echo "<form action="index.php?id={$id}&pass={$pass}" method="post">";
echo "Тема:<br/>";
echo "<input type="text" name="theme" maxlength="150"><br/>";
if ( $row['trans'] == 1 )
{
echo "<input name="tr" type="checkbox" value="1">Транслит<br/>";
}
echo "<input type="hidden" name="f" value="{$f}">";
echo "<input type="hidden" name="mod" value="s3">";
echo "<input type="submit" value="Добавить" class="cp">";
echo "</form>";
echo "<a href="index.php?id={$id}&pass={$pass}&mod=s1&f={$f}">Назад в «{$sect['name']}»</a><br/>";
break;
case "s3" :
echo "<meta http-equiv="refresh" content="1;URL=index.php?id={$id}&pass={$pass}&f={$f}&mod=s1"/>";
echo "<title>Reload...</title>";
echo "<style type="text/css">";
echo "body { font-size: {$fs}; color: {$tcol}; background-color: {$bcol}; text-align: center }";
echo "a:link,a:visited { text-decoration: underline; color: {$lcol} }";
echo "div { background-color: {$rcol} }";
echo "</style>";
echo "</head>";
echo "<body>";
$nick = $row['login'];
$theme = substr( $theme, 0, 300 );
if ( $tr == 1 )
{
$theme = trun_to_rus( $theme );
}
$theme = check( $theme );
$q = @mysql_query( @"select `name` from `forum_topic` where name='{$theme}' limit 1;" );
$prev = @mysql_fetch_array( @$q );
if ( empty( $theme ) )
{
echo "<div>Вы не заполнили тему!</div>";
break;
}
else
{
if ( $theme == $prev['name'] )
{
echo "<div>Такая тема уже есть!</div>";
break;
}
else
{
$add = "Insert into forum_topic set section='".$f."', login ='".$nick."', name='".$theme."', close=0, time='".time( )."'";
if ( mysql_query( $add ) )
{
echo "<div>Тема успешно добавленна!</div>";
mysql_query( "update `forum_sections` set time='".time( )."' where id='".$f."';" );
break;
}
else
{
$msg = "<div>Произошла ошибка...</div>";
break;
}
}
}
case "s4" :
$q = @mysql_query( @"select * from `forum_sections` WHERE id = '{$f}' ;" );
$sect = @mysql_fetch_array( @$q );
$q1 = @mysql_query( @"select * from `forum_topic` where `id`='".$t."' ;" );
$topic = @mysql_fetch_array( @$q1 );
echo "<title>{$topic['name']}</title>rn<style type="text/css">rnbody { font-size: {$fs}; color: {$tcol}; background-color: {$bcol} }rna:link,a:visited { text-decoration: underline; color: {$lcol} }rndiv { background-color: {$rcol} }rn</style>rn</head>rn<body>";
$max = $row['num_msgs'];
if ( $p < 0 )
{
$p = 0;
}
$page = $p * $max;
echo "<div align="center"><b>{$topic['name']}</b><br/>(".( $p + 1 )." стр.)</div>";
if ( $topic['close'] == 1 )
{
echo "<b>Тема закрыта</b>";
}
else
{
echo "<a href="index.php?id={$id}&pass={$pass}&f={$f}&t={$t}&mod=s5">Ответить</a>";
}
echo "<div>";
$q2 = @mysql_query( @"SELECT * from `forum_message` WHERE `topic` = '{$t}' order by time desc limit {$page},{$max};" );
$k = mysql_num_rows( $q2 );
if ( $k == 0 )
{
echo "Здесь сообщений пока нет :)";
}
while ( $mess = @mysql_fetch_array( @$q2 ) )
{
$nick = $mess['login'];
$text = $mess['msg'];
$time = $mess['time'];
$m = $mess['id'];
echo date( "d.m H:i", $time )." <b>{$nick}</b><br/>{$text}";
if ( 5 < $row['level'] )
{
echo " <a href="index.php?id={$id}&pass={$pass}&f={$f}&m={$m}&mod=d1">[X]</a>";
}
echo "<br/><br/>";
}
echo "</div>";
if ( $topic['close'] == 1 )
{
echo "<b>Тема закрыта</b><br/>";
}
else
{
echo "<a href="index.php?id={$id}&pass={$pass}&f={$f}&t={$t}&mod=s5">Ответить</a><br/>";
}
if ( $max <= $k )
{
++$p;
echo "<a href="index.php?id={$id}&pass={$pass}&f={$f}&t={$t}&mod=s4&p={$p}">Дальше...</a><br/>";
}
echo "<a href="index.php?id={$id}&pass={$pass}&f={$f}&t={$t}&mod=s4&ref={$ref}">В начало</a><br/>";
echo "<a href="index.php?id={$id}&pass={$pass}&mod=s1&f={$f}">Назад в «{$sect['name']}»</a><br/>";
if ( 5 < $row['level'] )
{
echo "---<br/>";
if ( $topic['close'] == 1 )
{
echo "<a href="index.php?id={$id}&pass={$pass}&mod=o2&f={$f}&t={$t}">Открыть тему</a><br/>";
}
else
{
echo "<a href="index.php?id={$id}&pass={$pass}&mod=o1&f={$f}&t={$t}">Закрыть тему</a><br/>";
}
echo "<a href="index.php?id={$id}&pass={$pass}&mod=d2&f={$f}&t={$t}">Удалить тему</a><br/>";
break;
}
case "s5" :
$q = @mysql_query( @"select * from `forum_sections` WHERE id = '{$f}' ;" );
$sect = @mysql_fetch_array( @$q );
$q1 = @mysql_query( @"select * from `forum_topic` where `id`='".$t."' ;" );
$topic = @mysql_fetch_array( @$q1 );
echo "<title>Форумы</title>rn<style type="text/css">rnbody { font-size: {$fs}; color: {$tcol}; background-color: {$bcol} }rna:link,a:visited { text-decoration: underline; color: {$lcol} }rndiv { background-color: {$rcol} }rn.cp t{ border-style:solid; border-width: 0px; color: {$lcol} ; background-color: {$bcol}; text-align: left }rn</style>rn</head>rn<body>";
echo "<div align="center"><b>Ответить на сообщение в «{$sect['name']}»</b></div>";
echo "<form action="index.php?id={$id}&pass={$pass}" method="post">";
echo "Тема: [Re: {$topic['name']}]<br/>";
echo "Сообщение:<br/>";
echo "<input type="text" name="msg" maxlength="300"><br/>";
if ( $row['trans'] == 1 )
{
echo "<input name="tr" type="checkbox" value="1">Транслит<br/>";
}
echo "<input type="hidden" name="f" value="{$f}">";
echo "<input type="hidden" name="t" value="{$t}">";
echo "<input type="hidden" name="mod" value="s6">";
echo "<input type="submit" value="Добавить" class="cp">";
echo "</form>";
echo "<a href="index.php?id={$id}&pass={$pass}&mod=s1&f={$f}">Назад в «{$sect['name']}»</a><br/>";
break;
case "s6" :
echo "<meta http-equiv="refresh" content="1;URL=index.php?id={$id}&pass={$pass}&f={$f}&t={$t}&mod=s4"/>";
echo "<title>Reload...</title>";
echo "<style type="text/css">";
echo "body { font-size: {$fs}; color: {$tcol}; background-color: {$bcol}; text-align: center }";
echo "a:link,a:visited { text-decoration: underline; color: {$lcol} }";
echo "div { background-color: {$rcol} }";
echo "</style>";
echo "</head>";
echo "<body>";
$q1 = @mysql_query( @"select * from `forum_topic` where `id`='".$t."' ;" );
$topic = @mysql_fetch_array( @$q1 );
if ( $topic['close'] == 1 )
{
echo "<div>Тема «{$topic['name']}» закрыта!</div>";
break;
}
else
{
if ( empty( $msg ) )
{
echo "<div>Пустое сообщение!</div>";
break;
}
else
{
$nick = $row['login'];
$msg = substr( $msg, 0, 600 );
if ( $tr == 1 )
{
$msg = trun_to_rus( $msg );
}
$msg = check( $msg );
if ( 3 < $row['level'] )
{
$msg = eregi_replace( "[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]", "<a href="\0">\0</a>", $msg );
}
else
{
$msg = eregi_replace( "[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]", "[<b>DELETED</b>]", $msg );
}
require( "../smiles/convert_to_smiles.php" );
$mysm = "s".$id.".gif";
if ( file_exists( "../prsm/{$mysm}" ) )
{
$msg = str_replace( ".my.", "<img src="../prsm/{$mysm}" alt=".my."/>", $msg );
}
$q = mysql_query( "select `msg` from `forum_message` where login='".$row['login']."' order by id desc;" );
$prev = mysql_fetch_array( $q );
if ( $msg == $prev['msg'] )
{
echo "<div>Такое сообщение уже есть!</div>";
break;
}
else
{
$add = "Insert into forum_message set topic='".$t."', login ='".$nick."', msg='".$msg."',time='".time( )."'";
if ( mysql_query( $add ) )
{
echo "<div>Ваше сообщение добавленно!</div>";
mysql_query( "update `forum_topic` set time='".time( )."' where id='".$t."';" );
break;
}
else
{
echo "<div>Произошла ошибка...</div>";
break;
}
}
}
}
case "d1" :
echo "<meta http-equiv="refresh" content="1;URL=index.php?id={$id}&pass={$pass}&f={$f}&mod=s1"/>";
echo "<title>Удаление сообщений</title>";
echo "<style type="text/css">";
echo "body { font-size: {$fs}; color: {$tcol}; background-color: {$bcol}; text-align: center }";
echo "a:link,a:visited { text-decoration: underline; color: {$lcol} }";
echo "div { background-color: {$rcol} }";
echo "</style>";
echo "</head>";
echo "<body>";
if ( $row['level'] < 6 )
{
echo "<div>Доступ закрыт!</div>";
break;
}
else
{
echo "<div>";
if ( mysql_query( "delete from forum_message where id='{$m}';" ) )
{
echo "Сообщение удалено!";
}
else
{
echo "Произошла ошибка...";
}
echo "</div>";
break;
}
case "d2" :
echo "<meta http-equiv="refresh" content="1;URL=index.php?id={$id}&pass={$pass}&f={$f}&mod=s1"/>";
echo "<title>Удаление темы</title>";
echo "<style type="text/css">";
echo "body { font-size: {$fs}; color: {$tcol}; background-color: {$bcol}; text-align: center }";
echo "a:link,a:visited { text-decoration: underline; color: {$lcol} }";
echo "div { background-color: {$rcol} }";
echo "</style>";
echo "</head>";
echo "<body>";
if ( $row['level'] < 6 )
{
echo "<div>Доступ закрыт!</div>";
break;
}
else
{
if ( mysql_query( "delete from forum_message where topic='{$t}';" ) )
{
echo "<div>Все сообщения удалены!</div>";
if ( mysql_query( "delete from forum_topic where id='{$t}';" ) )
{
echo "<div>Тема удалена!</div>";
break;
}
else
{
echo "<div>Невозможно удалить тему...</div>";
break;
}
}
else
{
echo "<div>Невозможно удалить сообщения в теме...</div>";
break;
}
}
case "o1" :
if ( mysql_query( "Update forum_topic set close='1' where id ='".$t."'" ) )
{
$msg = "Тема закрыта!";
}
else
{
$msg = "Произошла ошибка...";
}
echo "<meta http-equiv="refresh" content="1;URL=index.php?id={$id}&pass={$pass}&f={$f}&mod=s1"/>";
echo "<title>Reload...</title>";
echo "<style type="text/css">";
echo "body { font-size: {$fs}; color: {$tcol}; background-color: {$bcol}; text-align: center }";
echo "a:link,a:visited { text-decoration: underline; color: {$lcol} }";
echo "div { background-color: {$rcol} }";
echo "</style>";
echo "</head>";
echo "<body>";
echo "<div>{$msg}</div>";
break;
case "o2" :
if ( mysql_query( "Update forum_topic set close='0' where id ='".$t."'" ) )
{
$msg = "Тема открыта!";
}
else
{
$msg = "Произошла ошибка...";
}
echo "<meta http-equiv="refresh" content="1;URL=index.php?id={$id}&pass={$pass}&f={$f}&mod=s1"/>";
echo "<title>Reload...</title>";
echo "<style type="text/css">";
echo "body { font-size: {$fs}; color: {$tcol}; background-color: {$bcol}; text-align: center }";
echo "a:link,a:visited { text-decoration: underline; color: {$lcol} }";
echo "div { background-color: {$rcol} }";
echo "</style>";
echo "</head>";
echo "<body>";
echo "<div>{$msg}</div>";
break;
/////////////////////////////////////////////////////
case "team" :
$q = mysql_query( "select name from `forum_sections` WHERE section = '{$f}' ;" );
$sect = mysql_fetch_array( $q );
echo "<title>Форумы</title>rn<style type="text/css">rnbody { font-size: {$f}; color: {$tcol}; background-color: {$bcol} }rna:link,a:visited { text-decoration: underline; color: {$lcol} }rndiv { background-color: {$rcol} }rn.cp t{ border-style:solid; border-width: 0px; color: {$lcol} ; background-color: {$bcol}; text-align: left }rn</style>rn</head>rn<body>rn<div align="center"><b>Новая тема в «{$sect['name']}»</b></div>";
echo "<form action="index.php?id={$id}&pass={$pass}" method="post">";
echo "Тема:<br/>";
echo "<input type="text" name="theme" maxlength="150"><br/>";
if ( $row['trans'] == 1 )
{
echo "<input name="tr" type="checkbox" value="1">Транслит<br/>";
}
echo "<input type="hidden" name="f" value="{$fs}">";
echo "<input type="hidden" name="mod" value="s3">";
echo "<input type="submit" value="Добавить" class="cp">";
echo "</form>";
echo "<a href="index.php?id={$id}&pass={$pass}&mod=s1&f={$f}">Назад в «{$sect['name']}»</a><br/>";
break;
//////////////////////////////////////////////////////////
default :
echo "<title>Форумы</title>rn<style type="text/css">rnbody { font-size: {$fs}; color: {$tcol}; background-color: {$bcol} }rna:link,a:visited { text-decoration: underline; color: {$lcol} }rndiv { background-color: {$rcol} }rn</style>rn</head>rn<body>rn<div align="center"><b>Наш форум</b></div>";
$que = @mysql_query( "select * from `forum_sections` order by id limit 10;" );
while ( $dtm = @mysql_fetch_array( @$que ) )
{
$f = $dtm['id'];
$f_name = $dtm['name'];
$q = @mysql_query( @"select * from `forum_topic` WHERE section = '{$f}' ;" );
$kol = mysql_num_rows( $q );
echo date( "d.m H:i", $dtm['time'] )."<b>(".$kol.")</b><br/>";
print "<a href="index.php?id={$id}&pass={$pass}&mod=s1&f={$f}"><b>{$f_name}</b></a><br/><br/>";
}
//echo "<b><div><a href="index.php?id={$id}&pass={$pass}&mod=team">Добавить раздел</a></b><br/></div>";
break;
}
$end = gettime( );
echo "<p align="center">";
echo "<a href="index.php?id={$id}&pass={$pass}">Форумы</a><br/>";
echo "<a href="../enter.php?id={$id}&pass={$pass}&ref={$ref}">В чат</a><br/>";
echo "<p>{$ip}</p>[".round( $end - $mystart, 5 )."]";
echo "</p></body></html>";
mysql_close( $link );
?>