'Доступ закрыт', 1 => 'Только чтение', 2 => 'Разрешено добавлять ответы', 3 => 'Разрешено создовать топики', 4 => 'Разрешено добавлять ответы и создавать топики']; public function paginator($t, $pagers = 0) { if (isset($_GET['search'])) { $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"'; $pre_url = 'search=' . htmlspecialchars($_GET['search'], null) . '&read=' . $pagers . '&'; $idpaginator = $pagers; } elseif ($pagers != 0) { $where = '`topic` = "' . $pagers . '" AND `delete` = "0"'; $pre_url = 'read=' . $pagers . '&'; $idpaginator = $pagers; } elseif ($t == 1) { $where = '`topic` < "0" AND `fid` = "' . $this->r . '" AND `delete` = "0"'; $pre_url = 'r=' . $this->r . '&'; $idpaginator = $this->r; } elseif ($t == 2) { $where = '`topic` = "' . $this->see['id'] . '" AND `delete` = "0"'; $pre_url = 'read=' . $this->see['id'] . '&'; $idpaginator = $this->see['id']; } $q = "SELECT count(*) FROM forum_msg WHERE " . $where; $res = mysql_query($q); $row = mysql_fetch_row($res); $total_rows = $row[0]; $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 .= '' . $i . ""; } elseif (($_GET['page'] != $i || $pagers != 0)) { $plist .= '' . $i . ""; } else { $plist .= '' . $i . ''; } } if ($plist == '') { $plist = '1'; } return '' . $plist . ''; } 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'] . '")'); die(''); } } } $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 = '' . $prc . ''; } } else { $prc = floor($prc / $pr_all * 100); if ($prc > 0) { $pr_lst += $prc; $prc = '' . $prc . ''; } } if (isset($this->user['id'])) { if (isset($yg['id'])) { if ($yg['answer'] == $j) { $zm = '• ' . $ra[$j] . '     -   ' . $prc . '%   (Ваш голос)'; } else { $zm = '• ' . $ra[$j] . '     -   ' . $prc . '%'; } } else { $zm = '• ' . $ra[$j] . '     -   ' . $prc . '%'; } } else { $zm = '• ' . $ra[$j] . '     -   ' . $prc . '%'; } $text = str_replace('[:]' . $ra[$j], $zm, $text); } else { $zm = '

' . $ra[$j] . '

'; $text = str_replace(str_replace('
', '', $ra[$j]), $zm, $text); } } else { $j = -2; } $j++; } $text = str_replace('[?]', '', $text); } else { $i = -2; } $i++; } $text = str_replace('[/?]', '


Всего проголосовало людей ' . $pr_us_all . '
', $text); return $text; } public function startForum() { //Выделяем пользователя $ufr = mysql_fetch_array(mysql_query('SELECT * FROM `users` WHERE `login` = "' . mysql_real_escape_string($_COOKIE['login']) . '" AND `banned` = 0')); if (!isset($ufr['id']) || $ufr['banned'] > 0) { unset($u); } else { $ufr['sl'] = '' . $ufr['login'] . ' [' . $ufr['level'] . ']'; $this->user = $ufr; } //Выделяем раздел который просматривает пользователь if (isset($_GET['read'])) { //читаем сообщение $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; $this->error = 'Топик форума не найден.'; } 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; $this->error = 'Раздел форума не найден.'; } 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')); //Проверяем форум на доступность if ($this->gd[$this->fm['id']] == 0 && $ufr['admin'] == 0) { //просмотр закрыт $this->r = -2; $this->error = 'Вы не можете читать данную конференцию.'; } elseif ($this->fm['only_admin'] == 1 && $this->user['admin'] == 0) { //просмотр закрыт $this->r = -2; $this->error = 'Вы не можете читать данную конференцию.'; } } 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'])) { //Выводим заголовок 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 ' 
'; if ($this->user['admin'] > 0) { echo ''; } echo ''; echo ''; echo '
'; } echo '     (' . date('d.m.Y H:i', $this->see['time']) . ')
'; $this->see['text'] = str_replace("\n", "
", $this->see['text']); $this->see['text'] = $this->testAnswer($this->see['text']); $this->see['text'] = $this->parse_bb_code($this->see['text']); $rtrn = ''; $rtrn .= '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 .= '
' . $this->see['text'] . '
'; } $rtrn .= '
Запись была удалена'; if ($this->user['del_admin'] == 0) { $rtrn .= ', ' . $this->see['del_login'] . ''; } $rtrn .= '
'; } //Записи модераторов и ангелов $sp1 = mysql_query('SELECT * FROM `forum_msg_mod` WHERE `msg_id` = "' . $this->see['id'] . '"'); while ($pl1 = mysql_fetch_array($sp1)) { $rtrn .= '
'; if ($pl1['from_admin'] == 1) { $pl1['login'] = '<Администрация>'; $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", "
", $pl1['text']); $rtrn .= $this->link_it($pl1['text']) . '
'; } $rtrn .= '
'; //Выводим комментарии $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 .= ' 
'; if ($this->user['admin'] > 0) { $rtrn .= ''; } $rtrn .= ''; $rtrn .= ''; $rtrn .= '
'; } $rtrn .= '     (' . date('d.m.Y H:i', $pl['time']) . ')
'; $pl['text'] = $this->parse_bb_code($pl['text']); $pl['text'] = str_replace("\n", "
", $pl['text']); if ($pl['clear'] == 0) { $rtrn .= '
' . $pl['text'] . '
'; } else { if ($this->user['admin'] > 0) { $rtrn .= '
' . $pl['text'] . '
'; } $rtrn .= '
Комментарий удален'; if ($this->user['del_admin'] == 0) { $rtrn .= ', ' . $pl['del_login'] . ''; } $rtrn .= '
'; } //Записи модераторов и ангелов $sp1 = mysql_query('SELECT * FROM `forum_msg_mod` WHERE `msg_id` = "' . $pl['id'] . '"'); while ($pl1 = mysql_fetch_array($sp1)) { $rtrn .= '
'; if ($pl1['from_admin'] == 1) { $pl1['login'] = '<Администрация>'; $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", "
", $pl1['text']); $rtrn .= $this->link_it($pl1['text']) . '
'; } $rtrn .= '
'; } echo $rtrn; } } public function link_it($text) { $text = preg_replace("/(^|[\n ])([\w]*?)((ht|f)tp(s)?:\/\/[\w]+[^ \,\"\n\r\t<]*)/is", "$1$2$3", $text); $text = preg_replace("/(^|[\n ])([\w]*?)((www|ftp)\.[^ \,\"\t\n\r<]*)/is", "$1$2$3", $text); $text = preg_replace("/(^|[\n ])([a-z0-9&\-_\.]+?)@([\w\-]+\.([\w\-\.]+)+)/i", "$1$2@$3", $text); return ($text); } public function genuser($id, $login, $level, $align, $clan, $invis, $city, $cityreg) { global $c, $code; $ufr = ''; if ($align > 0) { $u .= ''; } if ($clan > 0) { $clan = mysql_fetch_array(mysql_query('SELECT * FROM `clan` WHERE `id` = "' . ((int)$clan) . '" LIMIT 1')); if (isset($clan['id'])) { $u .= ''; } } if ($login == '<Администрация>') { $login = 'Администрация'; } $u .= '' . $login . ' [' . $level . ']'; if ($city != '') { $ufr = '   ' . $u; } 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() { //можно добавлять и просматривать 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'])) { $this->error = 'Сообщение не найдено'; } elseif (trim($text, ' ') == '' || iconv_strlen(trim($text, ' ')) < 2) { $this->error = 'Минимальная длина сообщения должна быть не менее 2-х символов'; } elseif ($this->user['molch2'] > time()) { $this->error = 'Вы не можете писать сообщения и создавать топики на форуме, на вас наложено заклятие молчания'; } elseif (isset($this->see['id']) && $this->see['nocom'] == 3 && $this->user['admin'] == 0 && ($this->user['align'] <= 3 || $this->user['align'] >= 4)) { $this->error = 'В этом топике запрещено оставлять ответы'; } elseif (isset($this->see['id']) && $this->see['nocom'] == 2 && $this->user['admin'] == 0 && ($this->user['align'] <= 1 || $this->user['align'] >= 2)) { $this->error = 'В этом топике запрещено оставлять ответы'; } elseif (isset($this->see['id']) && $this->see['nocom'] == 1 && $this->user['admin'] == 0) { $this->error = 'В этом топике запрещено оставлять ответы'; } elseif ($this->user['level'] < 8) { $this->error = 'Вы не можете писать сообщения и создавать топики на форуме, это возможно с 8-го уровня'; } 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\]/', '
', $text);
        $text = preg_replace('/\[\/code\]/', '
', $text); $text = preg_replace('/\[(\/?)quote\]/', "<$1blockquote>", $text); $text = preg_replace('/\[(\/?)quote(\s*=\s*([\'"]?)([^\'"]+)\3\s*)?\]/', "<$1blockquote>Цитата $4:
", $text); //$text = preg_replace('/\[url\](?:https:\/\/)?([a-z0-9-.]+\.\w{2,4})\[\/url\]/', "$1", $text); $text = preg_replace('/\[url=(.+?)\](.+?)\[\/url\]/', "$2", $text); $text = preg_replace('/\[url\s?=\s?([\'"]?)(?:https:\/\/)?([a-z0-9-.]+\.\w{2,4})\1\](.*?)\[\/url\]/', "$3", $text); $text = preg_replace('/\[img\s*\]([^\]\[]+)\[\/img\]/', "", $text); $text = preg_replace('/\[img\s*=\s*([\'"]?)([^\'"\]]+)\1\]/', "", $text); $text = $this->close_dangling_tags($text); return $text; } // $s - строка, в которой необходимо закрыть теги // $tags - список тегов для закрытия через символ | (b|u|i) 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("##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 .= ''; } } 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) { $this->error = 'Минимальная длина сообщения должна быть не менее 5-ти символов'; } elseif ($this->user['molch2'] > time()) { $this->error = 'Вы не можете писать сообщения и создавать топики на форуме, на вас наложено заклятие молчания'; } elseif ((trim($title, ' ') == '' || iconv_strlen(trim($title, ' ')) < 5) && $topic == -1) { $this->error = 'Минимальная длина заголовка должна быть не менее 5-ти символов'; } elseif (isset($this->see['id']) && $this->see['nocom'] == 3 && $this->user['admin'] == 0 && ($this->user['align'] <= 3 || $this->user['align'] >= 4)) { $this->error = 'В этом топике запрещено оставлять ответы'; } elseif (isset($this->see['id']) && $this->see['nocom'] == 2 && $this->user['admin'] == 0 && ($this->user['align'] <= 1 || $this->user['align'] >= 2)) { $this->error = 'В этом топике запрещено оставлять ответы'; } elseif (isset($this->see['id']) && $this->see['nocom'] == 1 && $this->user['admin'] == 0) { $this->error = 'В этом топике запрещено оставлять ответы'; } elseif ($this->user['level'] < 2) { $this->error = 'Общение на форуме доступно с 2-го уровня'; } 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) { $tl['login'] = '<Администрация>'; $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')); $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'] . '")'); if (!$ins) { $this->error = 'Ошибка создания топика'; return false; } else { if ($topic != -1) { //Если автор предыдущего сообщения не текущий юзер - отправляем в чат сообщение о новом ответе if ($lst['uid'] + 1 != $this->user['id']) { $fnt = '' . date('d.m.Y H:i') . ' На форуме опубликован новый ответ в обсуждении, в котором вы принимали участие. Читать далее'; $ll = []; $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'); while ($pl = mysql_fetch_array($sp)) { if (isset($ll[$pl['uid']]) || $pl['uid'] == $this->user['id']) { continue; } $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; } 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) { $this->error = 'Вы не можете оставлять ответы и создавать топики так быстро'; } else { $this->error = 'Вы не можете оставлять ответы и создавать топики в этой конференции'; } } public function forumData() { $fd_limit = 20; $start = isset($_GET['page']) ? $_GET['page'] * $fd_limit - $fd_limit : 0; global $code; $filter = new Filter(); //отображаем топики данной конференции $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 = '' . $this->paginator(2, $pl['id']) . ''; if ($plist != '') { $plist = ' ' . $plist . ''; } $re .= ' 0) { $fxd = ' '; $re .= ' class="fixed_topik"'; } $re .= ' style="margin-top:10px;">'; $re .= '
' . $fxd . ' ' . $pl['title'] . ' ' . $plist . '   ' . $this->genuser($pl['uid'], $pl['login'], $pl['level'], $pl['align'], $pl['clan'], $pl['invis'], $pl['city'], $pl['cityreg']) . '
'; $re .= '
' . date('d.m.Y H:i', $pl['time']) . ' » '; if ($pl['fid'] == 24) { $re .= $filter->str_count(str_replace('[?]', 'Вопрос: ', str_replace('[/?]', '', str_replace('[:]', ', ', $pl['text']))), 250); } else { $re .= $filter->str_count(str_replace('[?]', 'Вопрос: ', str_replace('[/?]', '', str_replace('[:]', ', ', $pl['text']))), 250); } $re .= '
'; $re .= '
Ответов: ' . $row . ' ... '; $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) . ')
'; $re .= ''; $re .= "\n"; } echo $re; } public function history($id, $uid, $act, $text) { if ($type == 1) { } } public function actionSee($id) { if ($id == 1) { //удалить топик \ коммент $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) { //запретить комментировать mysql_query('UPDATE `forum_msg` SET `nocom` = "1" WHERE `id` = "' . $this->see['id'] . '" LIMIT 1'); $this->see['nocom'] = 1; } elseif ($id == 3) { //разрешить комментировать только Ангелам mysql_query('UPDATE `forum_msg` SET `nocom` = "2" WHERE `id` = "' . $this->see['id'] . '" LIMIT 1'); $this->see['nocom'] = 2; } elseif ($id == 4) { //разрешить комментировать только паладинам mysql_query('UPDATE `forum_msg` SET `nocom` = "3" WHERE `id` = "' . $this->see['id'] . '" LIMIT 1'); $this->see['nocom'] = 3; } elseif ($id == 5) { //разрешить комментировать только тарманам mysql_query('UPDATE `forum_msg` SET `nocom` = "4" WHERE `id` = "' . $this->see['id'] . '" LIMIT 1'); $this->see['nocom'] = 4; } elseif ($id == 6) { //разрешить комментировать всем mysql_query('UPDATE `forum_msg` SET `nocom` = "0" WHERE `id` = "' . $this->see['id'] . '" LIMIT 1'); $this->see['nocom'] = 0; } elseif ($id == 9) { //разрешить комментировать всем $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) { //фиксация топика или сообщения 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) { //удаление сообщения $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'])) { //0 - доступ закрыт, нелья даже читать, 1 - только чтение, 2 - разрешено добавлять ответы, 3 - разрешено создавать топики, 4 - разрешено создавать топики и добавлять ответы $ico = 4; if ($pl['level'] > $this->user['level']) { $ico = 1; } //проверяем уровень доступа $this->gd[$pl['id']] = $ico; $ico = ''; $rt = '' . $ico . ' ' . $pl['name'] . ''; } else { $rt = 'Раздел не найден'; } 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) . '
'; 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) . '
'; 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) . '
'; } } } } } } $this->menu = $m; } } $f = new forum; ?>