2022-06-06 21:30:34 +00:00
< ? php
2022-08-25 11:23:36 +00:00
if ( ! defined ( 'GAME' )) {
die ();
2022-06-06 21:30:34 +00:00
}
//Forum class
2022-08-25 11:23:36 +00:00
class forum
2022-06-06 21:30:34 +00:00
{
2023-01-10 16:29:32 +00:00
public $mod = 0 , $see = [], $lst = [], $gd = [], $menu = '' , $pages = '' , $r , $user = false , $fm = false , $error , $acs = [ 0 => 'Доступ закрыт' , 1 => 'Только чтение' , 2 => 'Разрешено добавлять ответы' , 3 => 'Разрешено создовать топики' , 4 => 'Разрешено добавлять ответы и создавать топики' ];
2022-08-25 11:23:36 +00:00
public function paginator ( $t , $pagers = 0 )
{
2023-08-10 14:51:16 +00:00
$args = [];
2022-08-25 11:23:36 +00:00
if ( isset ( $_GET [ 'search' ])) {
2023-08-10 14:51:16 +00:00
$where = '(text like ? or title like ? or login like ?) and topic < 0 and `delete` = 0' ;
$args = [ $_GET [ 'search' ], $_GET [ 'search' ], $_GET [ 'search' ]];
2023-01-10 17:26:14 +00:00
$pre_url = 'search=' . htmlspecialchars ( $_GET [ 'search' ], null ) . '&read=' . $pagers . '&' ;
2022-08-25 11:23:36 +00:00
} elseif ( $pagers != 0 ) {
2023-08-10 14:51:16 +00:00
$where = 'topic = ? and `delete` = 0' ;
$args = [ $pagers ];
2022-08-25 11:23:36 +00:00
$pre_url = 'read=' . $pagers . '&' ;
} elseif ( $t == 1 ) {
2023-08-10 14:51:16 +00:00
$where = 'topic < 0 and fid = ? and `delete` = 0' ;
$args = [ $this -> r ];
2022-08-25 11:23:36 +00:00
$pre_url = 'r=' . $this -> r . '&' ;
} elseif ( $t == 2 ) {
2023-08-10 14:51:16 +00:00
$where = 'topic = ? and `delete` = 0' ;
$args = [ $this -> see [ 'id' ]];
2022-08-25 11:23:36 +00:00
$pre_url = 'read=' . $this -> see [ 'id' ] . '&' ;
}
2023-08-10 14:51:16 +00:00
$total_rows = \Core\Db :: getValue ( " select count(*) from forum_msg where $where " , $args );
2022-08-25 11:23:36 +00:00
$num_pages = ceil ( $total_rows / 20 );
$plist = '' ;
for ( $i = 1 ; $i <= $num_pages ; $i ++ ) {
if (( ! isset ( $_GET [ 'page' ]) || round (( int ) $_GET [ 'page' ]) < 1 ) && $i == 1 && ( $t != 2 || isset ( $_GET [ 'read' ]))) {
$plist .= '<u>' . $i . " </u> " ;
} elseif (( $_GET [ 'page' ] != $i || $pagers != 0 )) {
$plist .= '<a href="' . $_SERVER [ 'PHP_SELF' ] . '?' . $pre_url . 'page=' . $i . '"><b>' . $i . " </b></a> " ;
} else {
$plist .= '<u>' . $i . '</u>' ;
}
}
if ( $plist == '' ) {
$plist = '<u>1</u>' ;
}
return '<pages>' . $plist . '</pages>' ;
}
public function testAnswer ( $text )
{
$r = str_replace ( '[/?]' , '[?]' , $text );
$r = explode ( '[?]' , $r );
$i = 1 ;
$pr_us_all = 0 ;
while ( $i != - 1 ) {
if ( isset ( $r [ $i ])) {
$ra = explode ( '[:]' , $r [ $i ]);
$j = 0 ;
if ( isset ( $this -> user [ 'id' ])) {
$yg = mysql_fetch_array ( mysql_query ( 'SELECT * FROM `forum_answers` WHERE `msg_id` = "' . $this -> see [ 'id' ] . '" AND `q_id` = "' . $i . '" AND `uid` = "' . $this -> user [ 'id' ] . '" AND `delete` = "0" LIMIT 1' ));
if ( ! isset ( $yg [ 'id' ], $_GET [ 'q_now' ], $_GET [ 'answer_now' ]) && $_GET [ 'q_now' ] == $i ) {
$_GET [ 'answer_now' ] = round (( int ) $_GET [ 'answer_now' ]);
$_GET [ 'q_now' ] = round (( int ) $_GET [ 'q_now' ]);
if ( isset ( $ra [ $_GET [ 'answer_now' ]])) {
mysql_query ( ' INSERT INTO `forum_answers` ( `uid` , `msg_id` , `q_id` , `answer` , `time` , `city` ) VALUES
( " ' . $this->user ['id'] . ' " , " ' . $this->see ['id'] . ' " , " ' . mysql_real_escape_string( $_GET['q_now'] ) . ' " , " ' . mysql_real_escape_string( $_GET['answer_now'] ) . ' " ,
" ' . time() . ' " , " ' . $this->user ['city'] . ' " ) ' );
2023-03-31 18:30:14 +00:00
die ( '<meta http-equiv="refresh" content="0; URL=/forum?read=' . round (( int ) $_GET [ 'read' ]) . '&page=' . round (( int ) $_GET [ 'page' ]) . '">' );
2022-08-25 11:23:36 +00:00
}
}
}
$pr_all = mysql_fetch_array ( mysql_query ( 'SELECT COUNT(`id`) FROM `forum_answers` WHERE `msg_id` = "' . $this -> see [ 'id' ] . '" AND `q_id` = "' . $i . '" AND `delete` = "0" LIMIT 1' ));
$pr_all = $pr_all [ 0 ];
$pr_us_all += $pr_all ;
$pr_lst = 0 ;
$pr_asw = 0 ;
while ( $j != - 1 ) {
if ( isset ( $ra [ $j ]) && $ra [ $j ] != '' ) {
if ( $j > 0 ) {
$prc = mysql_fetch_array ( mysql_query ( 'SELECT COUNT(`id`) FROM `forum_answers` WHERE `msg_id` = "' . $this -> see [ 'id' ] . '" AND `answer` = "' . $j . '" AND `q_id` = "' . $i . '" AND `delete` = "0" LIMIT 1' ));
$prc = 0 + $prc [ 0 ];
$pr_asw += $prc ;
if ( $pr_asw == $pr_all ) {
$prc = 100 - $pr_lst ;
$pr_lst += $prc ;
if ( $prc > 0 ) {
$prc = '<b>' . $prc . '</b>' ;
}
} else {
$prc = floor ( $prc / $pr_all * 100 );
if ( $prc > 0 ) {
$pr_lst += $prc ;
$prc = '<b>' . $prc . '</b>' ;
}
}
if ( isset ( $this -> user [ 'id' ])) {
if ( isset ( $yg [ 'id' ])) {
if ( $yg [ 'answer' ] == $j ) {
2023-01-10 16:29:32 +00:00
$zm = '<tr class="answ1h"><td>• <b>' . $ra [ $j ] . '</b></td><td> - ' . $prc . '% <small style="color:red">(Ваш голос)</small></td></tr>' ;
2022-08-25 11:23:36 +00:00
} else {
$zm = '<tr><td>• ' . $ra [ $j ] . '</td><td> - ' . $prc . '%</td></tr>' ;
}
} else {
2023-01-10 16:29:32 +00:00
$zm = '<tr onclick="location.href=\'?read=' . round (( int ) $_GET [ 'read' ]) . '&page=' . round (( int ) $_GET [ 'page' ]) . '&q_now=' . $i . '&answer_now=' . $j . '\'" class="answ1" title="Голосовать за этот вариант"><td>• ' . $ra [ $j ] . '</td><td> - ' . $prc . '%</td></tr>' ;
2022-08-25 11:23:36 +00:00
}
} else {
$zm = '<tr><td>• ' . $ra [ $j ] . '</td><td> - ' . $prc . '%</td></tr>' ;
}
$text = str_replace ( '[:]' . $ra [ $j ], $zm , $text );
} else {
$zm = '<h4>' . $ra [ $j ] . '</h4><table>' ;
$text = str_replace ( str_replace ( '<br>' , '' , $ra [ $j ]), $zm , $text );
}
} else {
$j = - 2 ;
}
$j ++ ;
}
$text = str_replace ( '[?]' , '' , $text );
} else {
$i = - 2 ;
}
$i ++ ;
}
2023-01-10 16:29:32 +00:00
$text = str_replace ( '[/?]' , '</table><br><br>В с е г о проголосовало людей ' . $pr_us_all . '<div class="line2"></div>' , $text );
2022-08-25 11:23:36 +00:00
return $text ;
}
public function startForum ()
{
2023-01-10 16:29:32 +00:00
//Выделяем пользователя
2023-01-06 14:57:25 +00:00
$ufr = mysql_fetch_array ( mysql_query ( 'SELECT * FROM `users` WHERE `login` = "' . mysql_real_escape_string ( $_COOKIE [ 'login' ]) . '" AND `banned` = 0' ));
2022-08-25 11:23:36 +00:00
if ( ! isset ( $ufr [ 'id' ]) || $ufr [ 'banned' ] > 0 ) {
unset ( $u );
} else {
$ufr [ 'sl' ] = '<b>' . $ufr [ 'login' ] . '</b> [' . $ufr [ 'level' ] . ']' ;
$this -> user = $ufr ;
}
2023-01-10 16:29:32 +00:00
//Выделяем раздел который просматривает пользователь
2022-08-25 11:23:36 +00:00
if ( isset ( $_GET [ 'read' ])) {
2023-01-10 16:29:32 +00:00
//читаем сообщение
2022-08-25 11:23:36 +00:00
$see = mysql_fetch_array ( mysql_query ( 'SELECT * FROM `forum_msg` WHERE `id` = "' . mysql_real_escape_string ( $_GET [ 'read' ]) . '" AND `delete` = "0" LIMIT 1' ));
if ( ! isset ( $see [ 'id' ]) || ( $see [ 'fid' ] == 65 && $this -> user [ 'admin' ] == 0 && ( $this -> user [ 'align' ] <= 1 || $this -> user [ 'align' ] >= 2 )) || ( $see [ 'fid' ] == 75 && $this -> user [ 'admin' ] == 0 && ( $this -> user [ 'align' ] <= 3 || $this -> user [ 'align' ] >= 4 ))) {
$this -> r = - 2 ;
2023-01-10 16:29:32 +00:00
$this -> error = 'Топик форума не найден.' ;
2022-08-25 11:23:36 +00:00
} else {
$this -> r = - 1 ;
$see [ 'goodAdd' ] = 1 ;
if ( $see [ 'nocom' ] > 0 ) {
if ( $this -> user [ 'align' ] > 1 && $this -> user [ 'align' ] < 2 ) {
if ( $see [ 'nocom' ] == 2 || $see [ 'nocom' ] == 4 ) {
$see [ 'goodAdd' ] = 0 ;
}
}
if ( $this -> user [ 'align' ] > 3 && $this -> user [ 'align' ] < 4 ) {
if ( $see [ 'nocom' ] == 2 || $see [ 'nocom' ] == 3 ) {
$see [ 'goodAdd' ] = 0 ;
}
}
if ( $this -> user [ 'admin' ] > 0 ) {
$see [ 'goodAdd' ] = 1 ;
}
}
$this -> see = $see ;
$this -> fm = mysql_fetch_array ( mysql_query ( 'SELECT * FROM `forum_menu` WHERE `id` = "' . mysql_real_escape_string ( $see [ 'fid' ]) . '" LIMIT 1' ));
}
} else {
if ( isset ( $_GET [ 'r' ])) {
$this -> r = ( int ) $_GET [ 'r' ];
} else {
$this -> r = 1 ;
}
$fm = mysql_fetch_array ( mysql_query ( 'SELECT * FROM `forum_menu` WHERE `id` = "' . mysql_real_escape_string ( $this -> r ) . '" LIMIT 1' ));
if ( ! isset ( $fm [ 'id' ]) || ( $fm [ 'id' ] == 65 && $this -> user [ 'admin' ] == 0 && ( $this -> user [ 'align' ] <= 1 || $this -> user [ 'align' ] >= 2 )) || ( $fm [ 'id' ] == 75 && $this -> user [ 'admin' ] == 0 && ( $this -> user [ 'align' ] <= 3 || $this -> user [ 'align' ] >= 4 ))) {
$this -> r = - 2 ;
$this -> fm = false ;
2023-01-10 16:29:32 +00:00
$this -> error = 'Раздел форума не найден.' ;
2022-08-25 11:23:36 +00:00
} else {
$this -> fm = $fm ;
}
}
$this -> genMenu ();
$this -> lst = mysql_fetch_array ( mysql_query ( 'SELECT `id`,`time` FROM `forum_msg` WHERE `uid` = "' . $this -> user [ 'id' ] . '" AND `delete` = "0" ORDER BY `time` DESC LIMIT 1' ));
2023-01-10 16:29:32 +00:00
//Проверяем форум на доступность
2022-08-25 11:23:36 +00:00
if ( $this -> gd [ $this -> fm [ 'id' ]] == 0 && $ufr [ 'admin' ] == 0 ) {
2023-01-10 16:29:32 +00:00
//просмотр закрыт
2022-08-25 11:23:36 +00:00
$this -> r = - 2 ;
2023-01-10 16:29:32 +00:00
$this -> error = 'Вы не можете читать данную конференцию.' ;
2022-08-25 11:23:36 +00:00
} elseif ( $this -> fm [ 'only_admin' ] == 1 && $this -> user [ 'admin' ] == 0 ) {
2023-01-10 16:29:32 +00:00
//просмотр закрыт
2022-08-25 11:23:36 +00:00
$this -> r = - 2 ;
2023-01-10 16:29:32 +00:00
$this -> error = 'Вы не можете читать данную конференцию.' ;
2022-08-25 11:23:36 +00:00
}
}
public function seeTopic ()
{
global $c ;
$fd_limit = 20 ;
if ( isset ( $_GET [ 'page' ])) {
$start = $_GET [ 'page' ] * $fd_limit - $fd_limit ;
} else {
$start = 0 ;
//echo 'SELECT * FROM `forum_msg` WHERE `topic` < "0" AND `fid` = "'.$this->r.'" AND `delete` = "0" ORDER BY `id` DESC LIMIT '.$start.','.$fd_limit;
}
if ( $this -> see [ 'fid' ] == 65 && $this -> user [ 'admin' ] == 0 && ( $this -> user [ 'align' ] <= 1 || $this -> user [ 'align' ] >= 2 )) {
} elseif ( $this -> see [ 'fid' ] == 75 && $this -> user [ 'admin' ] == 0 && ( $this -> user [ 'align' ] <= 3 || $this -> user [ 'align' ] >= 4 )) {
} elseif ( isset ( $this -> see [ 'id' ])) {
2023-01-10 16:29:32 +00:00
//Выводим заголовок
2022-08-25 11:23:36 +00:00
echo $this -> genuser ( $this -> see [ 'uid' ], $this -> see [ 'login' ], $this -> see [ 'level' ], $this -> see [ 'align' ], $this -> see [ 'clan' ], $this -> see [ 'invis' ], $this -> see [ 'city' ], $this -> see [ 'cityreg' ]);
if ( $this -> user [ 'admin' ] > 0 || ( $this -> user [ 'align' ] > 1 && $this -> user [ 'align' ] < 2 ) || ( $this -> user [ 'align' ] > 3 && $this -> user [ 'align' ] < 4 )) {
echo ' <div class="btnAdm">' ;
if ( $this -> user [ 'admin' ] > 0 ) {
2023-03-31 18:30:14 +00:00
echo '<a href="?aem=' . $this -> see [ 'id' ] . '"><img title="Редактировать" src="/forum_script/img/ic_acc3.gif" width="10" height="10"></a>' ;
2022-08-25 11:23:36 +00:00
}
2023-03-31 18:30:14 +00:00
echo '<a href="?delete_msg=' . $this -> see [ 'id' ] . '&read=' . $this -> see [ 'id' ] . '"><img title="Стереть запись" src="/forum_script/img/ic_acc0.gif" width="10" height="10"></a>' ;
echo '<img onclick="acma(' . $this -> see [ 'id' ] . ');" title="Комментировать" src="/forum_script/img/ic_acc2.gif" width="10" height="10" style="cursor:pointer">' ;
2022-08-25 11:23:36 +00:00
echo '</div>' ;
}
echo ' (<span class="date">' . date ( 'd.m.Y H:i' , $this -> see [ 'time' ]) . '</span>)<br>' ;
$this -> see [ 'text' ] = str_replace ( " \n " , " <br> " , $this -> see [ 'text' ]);
$this -> see [ 'text' ] = $this -> testAnswer ( $this -> see [ 'text' ]);
$this -> see [ 'text' ] = $this -> parse_bb_code ( $this -> see [ 'text' ]);
$rtrn = '' ;
$rtrn .= '<div' ;
if ( $this -> see [ 'fixed' ] > 0 ) {
$rtrn .= ' class="fixed_topik"' ;
}
$rtrn .= ' style="margin-left:31px;">' ;
if ( $this -> see [ 'clear' ] == 0 ) {
$rtrn .= $this -> see [ 'text' ];
} else {
if ( $this -> user [ 'admin' ] > 0 ) {
$rtrn .= '<div style="margin-left:31px;color:#9d9472;padding:10px;border:1px solid #ebdca0;">' . $this -> see [ 'text' ] . '</div>' ;
}
2023-01-10 16:29:32 +00:00
$rtrn .= '<div style="margin-left:31px;"><font color=red>Запись была удалена' ;
2022-08-25 11:23:36 +00:00
if ( $this -> user [ 'del_admin' ] == 0 ) {
$rtrn .= ', <img src="https://' . $c [ 'img' ] . '/i/align/align' . $this -> see [ 'del_align' ] . '.gif"><b>' . $this -> see [ 'del_login' ] . '</b>' ;
}
$rtrn .= '</font></div>' ;
}
2023-01-10 16:29:32 +00:00
//Записи модераторов и ангелов
2022-08-25 11:23:36 +00:00
$sp1 = mysql_query ( 'SELECT * FROM `forum_msg_mod` WHERE `msg_id` = "' . $this -> see [ 'id' ] . '"' );
while ( $pl1 = mysql_fetch_array ( $sp1 )) {
$rtrn .= '<div style="margin-left:31px;color:' . $pl1 [ 'color' ] . ';">' ;
if ( $pl1 [ 'from_admin' ] == 1 ) {
2023-01-10 16:29:32 +00:00
$pl1 [ 'login' ] = '<Администрация>' ;
2022-08-25 11:23:36 +00:00
$pl1 [ 'city' ] = '' ;
$pl1 [ 'cityreg' ] = '' ;
$pl1 [ 'clan' ] = '' ;
$pl1 [ 'level' ] = '??' ;
$pl1 [ 'uid' ] = 0 ;
}
$rtrn .= $this -> genuser ( $pl1 [ 'uid' ], $pl1 [ 'login' ], $pl1 [ 'level' ], $pl1 [ 'align' ], $pl1 [ 'clan' ], $pl1 [ 'invis' ], $pl1 [ 'city' ], $pl1 [ 'cityreg' ]);
$rtrn .= ' (' . date ( 'd.m.y H:i' , $pl1 [ 'time' ]) . '): ' ;
$pl1 [ 'text' ] = str_replace ( " \n " , " <br> " , $pl1 [ 'text' ]);
$rtrn .= $this -> link_it ( $pl1 [ 'text' ]) . '</div>' ;
}
$rtrn .= '</div><div class="line2"></div>' ;
2023-01-10 16:29:32 +00:00
//Выводим комментарии
2022-08-25 11:23:36 +00:00
$sp = mysql_query ( 'SELECT * FROM `forum_msg` WHERE `topic` = "' . $this -> see [ 'id' ] . '" AND `delete` = "0" ORDER BY `time` ASC LIMIT ' . $start . ',' . $fd_limit );
while ( $pl = mysql_fetch_array ( $sp )) {
$rtrn .= $this -> genuser ( $pl [ 'uid' ], $pl [ 'login' ], $pl [ 'level' ], $pl [ 'align' ], $pl [ 'clan' ], $pl [ 'invis' ], $pl [ 'city' ], $pl [ 'cityreg' ]);
if ( $this -> user [ 'admin' ] > 0 || ( $this -> user [ 'align' ] > 1 && $this -> user [ 'align' ] < 2 ) || ( $this -> user [ 'align' ] > 3 && $this -> user [ 'align' ] < 4 )) {
$rtrn .= ' <div class="btnAdm">' ;
if ( $this -> user [ 'admin' ] > 0 ) {
2023-03-31 18:30:14 +00:00
$rtrn .= '<a href="?aem=' . $pl [ 'id' ] . '"><img title="Редактировать" src="/forum_script/img/ic_acc3.gif" width="10" height="10"></a>' ;
2022-08-25 11:23:36 +00:00
}
2023-03-31 18:30:14 +00:00
$rtrn .= '<a href="?delete_msg=' . $pl [ 'id' ] . '&read=' . $pl [ 'topic' ] . '"><img title="Стереть комментарий" src="/forum_script/img/ic_acc0.gif" width="10" height="10"></a>' ;
$rtrn .= '<img onclick="acma(' . $pl [ 'id' ] . ');" title="Комментировать" src="/forum_script/img/ic_acc2.gif" width="10" height="10" style="cursor:pointer">' ;
2022-08-25 11:23:36 +00:00
$rtrn .= '</div>' ;
}
$rtrn .= ' (<span class="date">' . date ( 'd.m.Y H:i' , $pl [ 'time' ]) . '</span>)<br>' ;
$pl [ 'text' ] = $this -> parse_bb_code ( $pl [ 'text' ]);
$pl [ 'text' ] = str_replace ( " \n " , " <br> " , $pl [ 'text' ]);
if ( $pl [ 'clear' ] == 0 ) {
$rtrn .= '<div style="margin-left:31px;">' . $pl [ 'text' ] . '</div>' ;
} else {
if ( $this -> user [ 'admin' ] > 0 ) {
$rtrn .= '<div style="margin-left:31px;color:#9d9472;padding:10px;border:1px solid #ebdca0;">' . $pl [ 'text' ] . '</div>' ;
}
2023-01-10 16:29:32 +00:00
$rtrn .= '<div style="margin-left:31px;"><font color=red>Комментарий удален' ;
2022-08-25 11:23:36 +00:00
if ( $this -> user [ 'del_admin' ] == 0 ) {
$rtrn .= ', <img src="https://' . $c [ 'img' ] . '/i/align/align' . $pl [ 'del_align' ] . '.gif"><b>' . $pl [ 'del_login' ] . '</b>' ;
}
$rtrn .= '</font></div>' ;
}
2023-01-10 16:29:32 +00:00
//Записи модераторов и ангелов
2022-08-25 11:23:36 +00:00
$sp1 = mysql_query ( 'SELECT * FROM `forum_msg_mod` WHERE `msg_id` = "' . $pl [ 'id' ] . '"' );
while ( $pl1 = mysql_fetch_array ( $sp1 )) {
$rtrn .= '<div style="margin-left:31px;color:' . $pl1 [ 'color' ] . ';">' ;
if ( $pl1 [ 'from_admin' ] == 1 ) {
2023-01-10 16:29:32 +00:00
$pl1 [ 'login' ] = '<Администрация>' ;
2022-08-25 11:23:36 +00:00
$pl1 [ 'city' ] = '' ;
$pl1 [ 'cityreg' ] = '' ;
$pl1 [ 'clan' ] = '' ;
$pl1 [ 'level' ] = '??' ;
$pl1 [ 'uid' ] = 0 ;
}
$rtrn .= $this -> genuser ( $pl1 [ 'uid' ], $pl1 [ 'login' ], $pl1 [ 'level' ], $pl1 [ 'align' ], $pl1 [ 'clan' ], $pl1 [ 'invis' ], $pl1 [ 'city' ], $pl1 [ 'cityreg' ]);
$rtrn .= ' (' . date ( 'd.m.y H:i' , $pl1 [ 'time' ]) . '): ' ;
$pl1 [ 'text' ] = str_replace ( " \n " , " <br> " , $pl1 [ 'text' ]);
$rtrn .= $this -> link_it ( $pl1 [ 'text' ]) . '</div>' ;
}
$rtrn .= '<div class="line2"></div>' ;
}
echo $rtrn ;
}
}
public function link_it ( $text )
{
$text = preg_replace ( " /(^|[ \n ])([ \ w]*?)((ht|f)tp(s)?: \ / \ /[ \ w]+[^ \ , \" \n \r \t <]*)/is " , " $ 1 $ 2<a target= \" _blank \" href= \" $ 3 \" > $ 3</a> " , $text );
$text = preg_replace ( " /(^|[ \n ])([ \ w]*?)((www|ftp) \ .[^ \ , \" \t \n \r <]*)/is " , " $ 1 $ 2<a target= \" _blank \" href= \" https:// $ 3 \" > $ 3</a> " , $text );
$text = preg_replace ( " /(^|[ \n ])([a-z0-9& \ -_ \ .]+?)@([ \ w \ -]+ \ .([ \ w \ - \ .]+)+)/i " , " $ 1<a target= \" _blank \" href= \" mailto: $ 2@ $ 3 \" > $ 2@ $ 3</a> " , $text );
return ( $text );
}
public function genuser ( $id , $login , $level , $align , $clan , $invis , $city , $cityreg )
{
global $c , $code ;
$ufr = '' ;
if ( $align > 0 ) {
$u .= '<img src="https://' . $c [ 'img' ] . '/i/align/align' . $align . '.gif" />' ;
}
if ( $clan > 0 ) {
$clan = mysql_fetch_array ( mysql_query ( 'SELECT * FROM `clan` WHERE `id` = "' . (( int ) $clan ) . '" LIMIT 1' ));
if ( isset ( $clan [ 'id' ])) {
$u .= '<img src="https://' . $c [ 'img' ] . '/i/clan/' . $clan [ 'name_mini' ] . '.gif" />' ;
}
}
2023-01-10 16:29:32 +00:00
if ( $login == '<Администрация>' ) {
$login = 'Администрация' ;
2022-08-25 11:23:36 +00:00
}
2023-01-10 16:29:32 +00:00
$u .= '<b>' . $login . '</b> [' . $level . ']<a href="https://' . $c [ 'host' ] . '/info/' . $id . '" target="_blank" title="Инф. о ' . $login . '"><img src="https://' . $c [ 'img' ] . '/i/inf_capitalcity.gif"></a>' ;
2022-08-25 11:23:36 +00:00
if ( $city != '' ) {
2023-03-31 18:30:14 +00:00
$ufr = '<img title="' . $city . '" src="/forum_script/img/city/' . $city . '.gif" width="17" height="15"> ' . $u ;
2022-08-25 11:23:36 +00:00
}
return $u ;
}
private function isAlign1 ()
{
return $this -> user [ 'align' ] > 1 && $this -> user [ 'align' ] < 2 ;
}
private function isAlign3 ()
{
return $this -> user [ 'align' ] > 3 && $this -> user [ 'align' ] < 4 ;
}
public function pravasee ()
{
2023-01-10 16:29:32 +00:00
//можно добавлять и просматривать
2022-08-25 11:23:36 +00:00
return ( $this -> see [ 'fid' ] != 65 || $this -> user [ 'admin' ] != 0 || $this -> isAlign1 ()) && ( $this -> see [ 'fid' ] != 75 || $this -> user [ 'admin' ] != 0 || $this -> isAlign3 ()) && ( ! isset ( $this -> see [ 'id' ]) || $this -> see [ 'nocom' ] != 3 || $this -> user [ 'admin' ] != 0 || $this -> isAlign3 ()) && ( ! isset ( $this -> see [ 'id' ]) || $this -> see [ 'nocom' ] != 2 || $this -> user [ 'admin' ] != 0 || $this -> isAlign1 ()) && ( ! isset ( $this -> see [ 'id' ]) || $this -> see [ 'nocom' ] != 1 || $this -> user [ 'admin' ] != 0 ) && $this -> user [ 'level' ] >= 1 && $this -> lst [ 'time' ] <= time () - 60 ;
}
public function admintopmsg ( $read , $id , $text , $color , $adm )
{
$msg = mysql_fetch_array ( mysql_query ( 'SELECT `id` FROM `forum_msg` WHERE `id` = "' . mysql_real_escape_string ( $id ) . '" LIMIT 1' ));
if ( ! isset ( $msg [ 'id' ])) {
2023-01-10 16:29:32 +00:00
$this -> error = 'Сообщение не найдено' ;
2022-08-25 11:23:36 +00:00
} elseif ( trim ( $text , ' ' ) == '' || iconv_strlen ( trim ( $text , ' ' )) < 2 ) {
2023-01-10 16:29:32 +00:00
$this -> error = 'Минимальная длина сообщения должна быть не менее 2-х символов' ;
2022-08-25 11:23:36 +00:00
} elseif ( $this -> user [ 'molch2' ] > time ()) {
2023-01-10 16:29:32 +00:00
$this -> error = 'Вы не можете писать сообщения и создавать топики на форуме, на вас наложено заклятие молчания' ;
2022-08-25 11:23:36 +00:00
} elseif ( isset ( $this -> see [ 'id' ]) && $this -> see [ 'nocom' ] == 3 && $this -> user [ 'admin' ] == 0 && ( $this -> user [ 'align' ] <= 3 || $this -> user [ 'align' ] >= 4 )) {
2023-01-10 16:29:32 +00:00
$this -> error = 'В этом топике запрещено оставлять ответы' ;
2022-08-25 11:23:36 +00:00
} elseif ( isset ( $this -> see [ 'id' ]) && $this -> see [ 'nocom' ] == 2 && $this -> user [ 'admin' ] == 0 && ( $this -> user [ 'align' ] <= 1 || $this -> user [ 'align' ] >= 2 )) {
2023-01-10 16:29:32 +00:00
$this -> error = 'В этом топике запрещено оставлять ответы' ;
2022-08-25 11:23:36 +00:00
} elseif ( isset ( $this -> see [ 'id' ]) && $this -> see [ 'nocom' ] == 1 && $this -> user [ 'admin' ] == 0 ) {
2023-01-10 16:29:32 +00:00
$this -> error = 'В этом топике запрещено оставлять ответы' ;
2022-08-25 11:23:36 +00:00
} elseif ( $this -> user [ 'level' ] < 8 ) {
2023-01-10 16:29:32 +00:00
$this -> error = 'Вы не можете писать сообщения и создавать топики на форуме, это возможно с 8-г о уровня' ;
2022-08-25 11:23:36 +00:00
} else {
mysql_query ( ' INSERT INTO `forum_msg_mod` ( `uid` , `login` , `align` , `level` , `admin` , `clan` , `time` , `text` , `msg_id` , `delete` , `color` , `city` , `cityreg` , `from_admin` ) VALUES
( " ' . $this->user ['id'] . ' " , " ' . $this->user ['login'] . ' " , " ' . $this->user ['align'] . ' " , " ' . $this->user ['level'] . ' " , " ' . $this->user ['admin'] . ' " , " ' . $this->user ['clan'] . ' " ,
" ' . time() . ' " , " ' . mysql_real_escape_string( $text ) . ' " , " ' . mysql_real_escape_string( $msg['id'] ) . ' " , " 0 " , " red " , " ' . $this->user ['city'] . ' " , " ' . $this->user ['cityreg'] . ' " ,
" ' . mysql_real_escape_string(round((int) $adm )) . ' " ) ' );
if ( ! isset ( $this -> see [ 'id' ])) {
header ( 'location: ?r=' . round (( int ) $_GET [ 'r' ]) . '&page=' . round (( int ) $_GET [ 'page' ]));
} else {
header ( 'location: ?read=' . $this -> see [ 'id' ] . '&page=' . round (( int ) $_GET [ 'page' ]));
}
}
}
public function parse_bb_code ( $text )
{
$text = preg_replace ( '/\[(\/?)(b|i|u|s)\s*\]/' , " < $ 1 $ 2> " , $text );
$text = preg_replace ( '/\[code\]/' , '<pre><code>' , $text );
$text = preg_replace ( '/\[\/code\]/' , '</code></pre>' , $text );
$text = preg_replace ( '/\[(\/?)quote\]/' , " < $ 1blockquote> " , $text );
2023-01-10 16:29:32 +00:00
$text = preg_replace ( '/\[(\/?)quote(\s*=\s*([\'"]?)([^\'"]+)\3\s*)?\]/' , " < $ 1blockquote>Цитата $ 4:<br> " , $text );
2022-08-25 11:23:36 +00:00
//$text = preg_replace('/\[url\](?:https:\/\/)?([a-z0-9-.]+\.\w{2,4})\[\/url\]/', "<a href=\"https://$1\">$1</a>", $text);
$text = preg_replace ( '/\[url=(.+?)\](.+?)\[\/url\]/' , " <a target= \" _blank \" href= \" $ 1 \" > $ 2</a> " , $text );
$text = preg_replace ( '/\[url\s?=\s?([\'"]?)(?:https:\/\/)?([a-z0-9-.]+\.\w{2,4})\1\](.*?)\[\/url\]/' , " <a href= \" https:// $ 2 \" > $ 3</a> " , $text );
$text = preg_replace ( '/\[img\s*\]([^\]\[]+)\[\/img\]/' , " <img src=' $ 1'/> " , $text );
$text = preg_replace ( '/\[img\s*=\s*([\'"]?)([^\'"\]]+)\1\]/' , " <img src=' $ 2'/> " , $text );
$text = $this -> close_dangling_tags ( $text );
return $text ;
}
2023-01-10 16:29:32 +00:00
// $s - строка, в которой необходимо закрыть теги
// $tags - список тегов для закрытия через символ | (b|u|i)
2022-08-25 11:23:36 +00:00
public function close_dangling_tags ( $html )
{
#put all opened tags into an array
preg_match_all ( " #<([a-z]+)( .*)?(?!/)>#iU " , $html , $result );
$openedtags = $result [ 1 ];
#put all closed tags into an array
preg_match_all ( " #</([a-z]+)>#iU " , $html , $result );
$closedtags = $result [ 1 ];
$len_opened = count ( $openedtags );
# all tags are closed
if ( count ( $closedtags ) == $len_opened ) {
return $html ;
}
$openedtags = array_reverse ( $openedtags );
# close tags
for ( $i = 0 ; $i < $len_opened ; $i ++ ) {
if ( ! in_array ( $openedtags [ $i ], $closedtags )) {
if ( $openedtags [ $i ] != 'br' ) {
$html .= '</' . $openedtags [ $i ] . '>' ;
}
} else {
unset ( $closedtags [ array_search ( $openedtags [ $i ], $closedtags )]);
}
}
return $html ;
}
public function addnewtop ( $title , $text , $ico , $time , $login , $uid , $fid , $topic )
{
if ( trim ( $text , ' ' ) == '' || iconv_strlen ( trim ( $text , ' ' )) < 5 ) {
2023-01-10 16:29:32 +00:00
$this -> error = 'Минимальная длина сообщения должна быть не менее 5-ти символов' ;
2022-08-25 11:23:36 +00:00
} elseif ( $this -> user [ 'molch2' ] > time ()) {
2023-01-10 16:29:32 +00:00
$this -> error = 'Вы не можете писать сообщения и создавать топики на форуме, на вас наложено заклятие молчания' ;
2022-08-25 11:23:36 +00:00
} elseif (( trim ( $title , ' ' ) == '' || iconv_strlen ( trim ( $title , ' ' )) < 5 ) && $topic == - 1 ) {
2023-01-10 16:29:32 +00:00
$this -> error = 'Минимальная длина заголовка должна быть не менее 5-ти символов' ;
2022-08-25 11:23:36 +00:00
} elseif ( isset ( $this -> see [ 'id' ]) && $this -> see [ 'nocom' ] == 3 && $this -> user [ 'admin' ] == 0 && ( $this -> user [ 'align' ] <= 3 || $this -> user [ 'align' ] >= 4 )) {
2023-01-10 16:29:32 +00:00
$this -> error = 'В этом топике запрещено оставлять ответы' ;
2022-08-25 11:23:36 +00:00
} elseif ( isset ( $this -> see [ 'id' ]) && $this -> see [ 'nocom' ] == 2 && $this -> user [ 'admin' ] == 0 && ( $this -> user [ 'align' ] <= 1 || $this -> user [ 'align' ] >= 2 )) {
2023-01-10 16:29:32 +00:00
$this -> error = 'В этом топике запрещено оставлять ответы' ;
2022-08-25 11:23:36 +00:00
} elseif ( isset ( $this -> see [ 'id' ]) && $this -> see [ 'nocom' ] == 1 && $this -> user [ 'admin' ] == 0 ) {
2023-01-10 16:29:32 +00:00
$this -> error = 'В этом топике запрещено оставлять ответы' ;
2022-08-25 11:23:36 +00:00
} elseif ( $this -> user [ 'level' ] < 2 ) {
2023-01-10 16:29:32 +00:00
$this -> error = 'Общение на форуме доступно с 2-г о уровня' ;
2022-08-25 11:23:36 +00:00
} elseif ( $this -> gd [ $fid ] > 0 && $this -> lst [ 'time' ] < time () - 60 ) {
$ico = ( int ) $ico ;
if ( $ico < 1 || $ico > 14 ) {
$ico = 13 ;
}
$tl = [];
if ( isset ( $_POST [ 'adminname' ]) && $this -> user [ 'admin' ] > 0 ) {
2023-01-10 16:29:32 +00:00
$tl [ 'login' ] = '<Администрация>' ;
2022-08-25 11:23:36 +00:00
$tl [ 'level' ] = '??' ;
$tl [ 'align' ] = '0' ;
$tl [ 'clan' ] = '0' ;
$tl [ 'cityreg' ] = 'newvillage' ;
$tl [ 'city' ] = 'questcity' ;
$tl [ 'id' ] = '0' ;
} else {
$tl [ 'login' ] = $this -> user [ 'login' ];
$tl [ 'level' ] = $this -> user [ 'level' ];
$tl [ 'align' ] = $this -> user [ 'align' ];
$tl [ 'clan' ] = $this -> user [ 'clan' ];
$tl [ 'cityreg' ] = $this -> user [ 'cityreg' ];
$tl [ 'city' ] = $this -> user [ 'city' ];
$tl [ 'id' ] = $uid ;
}
$lst = mysql_fetch_array ( mysql_query ( 'SELECT * FROM `forum_msg` WHERE `topic` = "' . mysql_real_escape_string ( $topic ) . '" OR (`topic` = "-1" AND `id` = "' . mysql_real_escape_string ( $topic ) . '") ORDER BY `time` DESC LIMIT 1' ));
2023-01-10 17:26:14 +00:00
$ins = mysql_query ( 'INSERT INTO `forum_msg` (`cityreg`,`city`,`align`,`clan`,`level`,`login`,`fid`,`title`,`topic`,`ico`,`text`,`time`,`ip`,`uid`) VALUES ("' . mysql_real_escape_string ( $tl [ 'cityreg' ]) . '","' . mysql_real_escape_string ( $tl [ 'city' ]) . '","' . mysql_real_escape_string ( $tl [ 'align' ]) . '","' . mysql_real_escape_string ( $tl [ 'clan' ]) . '","' . mysql_real_escape_string ( $tl [ 'level' ]) . '","' . mysql_real_escape_string ( $tl [ 'login' ]) . '","' . mysql_real_escape_string ( $fid ) . '","' . mysql_real_escape_string ( htmlspecialchars ( $title , null )) . '","' . mysql_real_escape_string ( $topic ) . '","' . mysql_real_escape_string ( $ico ) . '","' . mysql_real_escape_string ( htmlspecialchars ( $text , null )) . '","' . mysql_real_escape_string ( $time ) . '","' . $_SERVER [ 'HTTP_X_REAL_IP' ] . '","' . $tl [ 'id' ] . '")' );
2022-08-25 11:23:36 +00:00
if ( ! $ins ) {
2023-01-10 16:29:32 +00:00
$this -> error = 'Ошибка создания топика' ;
2022-08-25 11:23:36 +00:00
return false ;
} else {
if ( $topic != - 1 ) {
2023-01-10 16:29:32 +00:00
//Если автор предыдущего сообщения не текущий юзер - отправляем в чат сообщение о новом ответе
2022-08-25 11:23:36 +00:00
if ( $lst [ 'uid' ] + 1 != $this -> user [ 'id' ]) {
2023-03-31 18:30:14 +00:00
$fnt = '<b>' . date ( 'd.m.Y H:i' ) . '</b> Н а форуме опубликован новый ответ в обсуждении, в котором вы принимали участие. <a href=/forum?read=' . $topic . ' target=_blank \>Читать далее</a>' ;
2022-08-25 11:23:36 +00:00
$ll = [];
2023-01-28 02:24:37 +00:00
$sp = mysql_query ( 'SELECT `u`.`city`,`u`.`id`,`u`.`login`,`f`.`uid`,`f`.`login` FROM `forum_msg` AS `f` LEFT JOIN `users` AS `u` ON `f`.`uid` = `u`.`id` WHERE `f`.`delete` = 0 AND (`f`.`topic` = ' . ( int ) $topic . ' OR (`f`.`topic` = -1 AND `f`.`id` = ' . ( int ) $topic . ')) LIMIT 1' );
2022-08-25 11:23:36 +00:00
while ( $pl = mysql_fetch_array ( $sp )) {
2023-01-28 02:24:37 +00:00
if ( isset ( $ll [ $pl [ 'uid' ]]) || $pl [ 'uid' ] == $this -> user [ 'id' ]) {
continue ;
2022-08-25 11:23:36 +00:00
}
2023-01-28 02:24:37 +00:00
$cmsg = new ChatMessage ();
$cmsg -> setCity ( $pl [ 'city' ]);
$cmsg -> setTo ( $pl [ 'login' ]);
$cmsg -> setText ( $fnt );
$cmsg -> setType ( 6 );
( new Chat ()) -> sendMsg ( $cmsg );
$ll [ $pl [ 'uid' ]] = true ;
2022-08-25 11:23:36 +00:00
}
unset ( $ll );
}
}
$fid = mysql_insert_id ();
$this -> lst [ 'time' ] = time ();
if ( isset ( $this -> see [ 'id' ])) {
header ( 'location: ?read=' . $this -> see [ 'id' ] . '&page=' . round (( int ) $_GET [ 'page' ]));
} else {
header ( 'location: ?r=' . round (( int ) $_GET [ 'r' ]) . '&page=' . round (( int ) $_GET [ 'page' ]));
}
return $fid ;
}
} elseif ( $this -> lst [ 'time' ] > time () - 60 ) {
2023-01-10 16:29:32 +00:00
$this -> error = 'Вы не можете оставлять ответы и создавать топики так быстро' ;
2022-08-25 11:23:36 +00:00
} else {
2023-01-10 16:29:32 +00:00
$this -> error = 'Вы не можете оставлять ответы и создавать топики в этой конференции' ;
2022-08-25 11:23:36 +00:00
}
}
public function forumData ()
{
$fd_limit = 20 ;
$start = isset ( $_GET [ 'page' ]) ? $_GET [ 'page' ] * $fd_limit - $fd_limit : 0 ;
global $code ;
$filter = new Filter ();
2023-01-10 16:29:32 +00:00
//отображаем топики данной конференции
2022-08-25 11:23:36 +00:00
$re = '' ;
if ( isset ( $_GET [ 'search' ])) {
$sp = mysql_query ( 'SELECT * FROM `forum_msg` WHERE ( `text` LIKE "%' . mysql_real_escape_string ( $_GET [ 'search' ]) . '%" OR `title` LIKE "%' . mysql_real_escape_string ( $_GET [ 'search' ]) . '%" OR `login` LIKE "%' . mysql_real_escape_string ( $_GET [ 'search' ]) . '%" ) AND `topic` < "0" AND `delete` = "0" ORDER BY `id` DESC LIMIT ' . $start . ',' . $fd_limit );
} else {
$sp = mysql_query ( 'SELECT * FROM `forum_msg` WHERE `topic` < "0" AND `fid` = "' . $this -> r . '" AND `delete` = "0" ORDER BY `fixed` DESC,`id` DESC LIMIT ' . $start . ',' . $fd_limit );
}
while ( $pl = mysql_fetch_array ( $sp )) {
$lstDT = $pl [ 'time' ];
$row = mysql_num_rows ( mysql_query ( 'SELECT `id` FROM `forum_msg` WHERE `topic` = "' . $pl [ 'id' ] . '" AND `delete` = "0"' ));
$plist = '<small>' . $this -> paginator ( 2 , $pl [ 'id' ]) . '</small>' ;
if ( $plist != '' ) {
2023-03-31 18:30:14 +00:00
$plist = '<img src="/forum_script/img/p.gif" width="10" height="12"> ' . $plist . '' ;
2022-06-06 21:30:34 +00:00
}
2022-08-25 11:23:36 +00:00
$re .= '<div' ;
$fxd = '' ;
if ( $pl [ 'fixed' ] > 0 ) {
2023-03-31 18:30:14 +00:00
$fxd = '<img src="/forum_script/img/fixed.gif"> ' ;
2022-08-25 11:23:36 +00:00
$re .= ' class="fixed_topik"' ;
}
$re .= ' style="margin-top:10px;">' ;
2023-03-31 18:30:14 +00:00
$re .= '<div>' . $fxd . '<img style="border:0px;" src="/forum_script/img/icon' . $pl [ 'ico' ] . '.gif"> <a href="?read=' . $pl [ 'id' ] . '&rnd=' . $code . '"><b>' . $pl [ 'title' ] . '</b></a> ' . $plist . ' ' . $this -> genuser ( $pl [ 'uid' ], $pl [ 'login' ], $pl [ 'level' ], $pl [ 'align' ], $pl [ 'clan' ], $pl [ 'invis' ], $pl [ 'city' ], $pl [ 'cityreg' ]) . '</div>' ;
2022-08-25 11:23:36 +00:00
$re .= '<div style="margin-left:21px;"><small class="date">' . date ( 'd.m.Y H:i' , $pl [ 'time' ]) . '</small> » <small style="color:#606060;">' ;
if ( $pl [ 'fid' ] == 24 ) {
2023-01-10 16:29:32 +00:00
$re .= $filter -> str_count ( str_replace ( '[?]' , 'Вопрос: ' , str_replace ( '[/?]' , '' , str_replace ( '[:]' , ', ' , $pl [ 'text' ]))), 250 );
2022-08-25 11:23:36 +00:00
} else {
2023-01-10 16:29:32 +00:00
$re .= $filter -> str_count ( str_replace ( '[?]' , 'Вопрос: ' , str_replace ( '[/?]' , '' , str_replace ( '[:]' , ', ' , $pl [ 'text' ]))), 250 );
2022-08-25 11:23:36 +00:00
}
$re .= '</small></div>' ;
2023-01-10 16:29:32 +00:00
$re .= '<div style="margin-left:21px;"><small>Ответов: <b>' . $row . '</b> ... ' ;
2022-08-25 11:23:36 +00:00
$pku = mysql_query ( 'SELECT `login`,`invis`,`time` FROM `forum_msg` WHERE `topic` = "' . $pl [ 'id' ] . '" AND `delete` = 0 ORDER BY `id` DESC LIMIT 10' );
$pkusr = '' ;
while ( $plku = mysql_fetch_array ( $pku )) {
$pkusr = $plku [ 'login' ] . ', ' . $pkusr ;
$lstDT = $plku [ 'time' ];
}
$pkusr = rtrim ( $pkusr , ', ' );
$re .= $pkusr ;
unset ( $pkusr );
$re .= ' (' . date ( 'd.m.Y H:i' , $lstDT ) . ')</small></div>' ;
$re .= '</div>' ;
$re .= " \n " ;
}
echo $re ;
}
public function history ( $id , $uid , $act , $text )
{
if ( $type == 1 ) {
}
}
public function actionSee ( $id )
{
if ( $id == 1 ) {
2023-01-10 16:29:32 +00:00
//удалить топик \ коммент
2022-08-25 11:23:36 +00:00
$up = mysql_query ( 'UPDATE `forum_msg` SET `delete` = "' . time () . '",`del_login`="' . $this -> user [ 'login' ] . '" WHERE `id` = "' . $this -> see [ 'id' ] . '" LIMIT 1' );
$this -> see [ 'delete' ] = time ();
} elseif ( $id == 2 ) {
2023-01-10 16:29:32 +00:00
//запретить комментировать
2022-08-25 11:23:36 +00:00
mysql_query ( 'UPDATE `forum_msg` SET `nocom` = "1" WHERE `id` = "' . $this -> see [ 'id' ] . '" LIMIT 1' );
$this -> see [ 'nocom' ] = 1 ;
} elseif ( $id == 3 ) {
2023-01-10 16:29:32 +00:00
//разрешить комментировать только Ангелам
2022-08-25 11:23:36 +00:00
mysql_query ( 'UPDATE `forum_msg` SET `nocom` = "2" WHERE `id` = "' . $this -> see [ 'id' ] . '" LIMIT 1' );
$this -> see [ 'nocom' ] = 2 ;
} elseif ( $id == 4 ) {
2023-01-10 16:29:32 +00:00
//разрешить комментировать только паладинам
2022-08-25 11:23:36 +00:00
mysql_query ( 'UPDATE `forum_msg` SET `nocom` = "3" WHERE `id` = "' . $this -> see [ 'id' ] . '" LIMIT 1' );
$this -> see [ 'nocom' ] = 3 ;
} elseif ( $id == 5 ) {
2023-01-10 16:29:32 +00:00
//разрешить комментировать только тарманам
2022-08-25 11:23:36 +00:00
mysql_query ( 'UPDATE `forum_msg` SET `nocom` = "4" WHERE `id` = "' . $this -> see [ 'id' ] . '" LIMIT 1' );
$this -> see [ 'nocom' ] = 4 ;
} elseif ( $id == 6 ) {
2023-01-10 16:29:32 +00:00
//разрешить комментировать всем
2022-08-25 11:23:36 +00:00
mysql_query ( 'UPDATE `forum_msg` SET `nocom` = "0" WHERE `id` = "' . $this -> see [ 'id' ] . '" LIMIT 1' );
$this -> see [ 'nocom' ] = 0 ;
} elseif ( $id == 9 ) {
2023-01-10 16:29:32 +00:00
//разрешить комментировать всем
2022-08-25 11:23:36 +00:00
$rzn = mysql_fetch_array ( mysql_query ( 'SELECT * FROM `forum_menu` WHERE `id` = "' . mysql_real_escape_string ( $_GET [ 'trm' ]) . '" LIMIT 1' ));
if ( isset ( $rzn [ 'id' ])) {
mysql_query ( 'UPDATE `forum_msg` SET `fid` = "' . mysql_real_escape_string ( $rzn [ 'id' ]) . '" WHERE `id` = "' . $this -> see [ 'id' ] . '" LIMIT 1' );
}
} elseif ( $id == 7 ) {
2023-01-10 16:29:32 +00:00
//фиксация топика или сообщения
2022-08-25 11:23:36 +00:00
if ( $this -> see [ 'fixed' ] == 0 ) {
$this -> see [ 'fixed' ] = time ();
} else {
$this -> see [ 'fixed' ] = 0 ;
}
mysql_query ( 'UPDATE `forum_msg` SET `fixed` = "' . $this -> see [ 'fixed' ] . '" WHERE `id` = "' . $this -> see [ 'id' ] . '" LIMIT 1' );
} elseif ( $id == 8 ) {
2023-01-10 16:29:32 +00:00
//удаление сообщения
2022-08-25 11:23:36 +00:00
$tpdms = mysql_fetch_array ( mysql_query ( 'SELECT `id`,`clear`,`delete` FROM `forum_msg` WHERE `id` = "' . mysql_real_escape_string ( round (( int ) $_GET [ 'delete_msg' ])) . '" LIMIT 1' ));
if ( isset ( $tpdms [ 'id' ])) {
// if(isset($this->see['id'])) {
if ( $tpdms [ 'clear' ] == 0 ) {
$tpdms [ 'clear' ] = time ();
} else {
$tpdms [ 'delete' ] = $this -> user [ 'id' ];
}
mysql_query ( 'UPDATE `forum_msg` SET `clear` = "' . $tpdms [ 'clear' ] . '",`delete` = "' . $tpdms [ 'delete' ] . '",`del_login` = "' . $this -> user [ 'login' ] . '",`del_align` = "' . $this -> user [ 'align' ] . '",`del_clan` = "' . $this -> user [ 'clan' ] . '",`del_admin` = "' . $this -> user [ 'admin' ] . '" WHERE `id` = "' . $tpdms [ 'id' ] . '" LIMIT 1' );
// }
}
}
if ( ! isset ( $this -> see [ 'id' ])) {
header ( 'location: ?r=' . round (( int ) $_GET [ 'r' ]) . '&page=' . round (( int ) $_GET [ 'page' ]));
} else {
header ( 'location: ?read=' . $this -> see [ 'id' ] . '&page=' . round (( int ) $_GET [ 'page' ]));
}
}
public function genRz ( $pl )
{
global $code ;
$rt = '' ;
if ( isset ( $pl [ 'id' ])) {
2023-01-10 16:29:32 +00:00
//0 - доступ закрыт, нелья даже читать, 1 - только чтение, 2 - разрешено добавлять ответы, 3 - разрешено создавать топики, 4 - разрешено создавать топики и добавлять ответы
2022-08-25 11:23:36 +00:00
$ico = 4 ;
if ( $pl [ 'level' ] > $this -> user [ 'level' ]) {
$ico = 1 ;
}
2023-01-10 16:29:32 +00:00
//проверяем уровень доступа
2022-08-25 11:23:36 +00:00
$this -> gd [ $pl [ 'id' ]] = $ico ;
2023-03-31 18:30:14 +00:00
$ico = '<img width="10" height="10" title="' . $this -> acs [ $ico ] . '" src="/forum_script/img/ic_acc' . $ico . '.gif">' ;
2022-08-25 11:23:36 +00:00
$rt = '' . $ico . ' <a href="?r=' . $pl [ 'id' ] . '&rnd=' . $code . '"><b>' . $pl [ 'name' ] . '</b></a>' ;
} else {
2023-01-10 16:29:32 +00:00
$rt = 'Раздел не найден' ;
2022-08-25 11:23:36 +00:00
}
return $rt ;
}
public function genMenu ()
{
$m = '' ;
$sp = mysql_query ( 'SELECT * FROM `forum_menu` WHERE `parent` = "0" ORDER BY `pos` DESC' );
while ( $pl = mysql_fetch_array ( $sp )) {
if ( $pl [ 'id' ] == 65 && $this -> user [ 'admin' ] == 0 && ( $this -> user [ 'align' ] <= 1 || $this -> user [ 'align' ] >= 2 )) {
} elseif ( $pl [ 'id' ] == 75 && $this -> user [ 'admin' ] == 0 && ( $this -> user [ 'align' ] <= 3 || $this -> user [ 'align' ] >= 4 )) {
} elseif ( $pl [ 'only_admin' ] == 0 || $this -> user [ 'admin' ] > 0 ) {
$m .= $this -> genRz ( $pl ) . '<br>' ;
if ( $this -> r == $pl [ 'id' ] || $this -> fm [ 'parent' ] == $pl [ 'id' ]) {
$sp2 = mysql_query ( 'SELECT * FROM `forum_menu` WHERE `parent` = "' . $pl [ 'id' ] . '" AND `parent2`="0"' );
while ( $pl2 = mysql_fetch_array ( $sp2 )) {
$m .= ' ' . $this -> genRz ( $pl2 ) . '<br>' ;
if ( $this -> r == $pl2 [ 'id' ] || $this -> fm [ 'parent2' ] == $pl2 [ 'id' ]) {
$sp3 = mysql_query ( 'SELECT * FROM `forum_menu` WHERE `parent2` = "' . $pl2 [ 'id' ] . '"' );
while ( $pl3 = mysql_fetch_array ( $sp3 )) {
$m .= ' ' . $this -> genRz ( $pl3 ) . '<br>' ;
}
}
}
}
}
}
$this -> menu = $m ;
}
2022-06-06 21:30:34 +00:00
}
$f = new forum ;
?>