1. PHP / Говнокод #5095

    +160

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    /*
                    -----------------------------------------------------------------
                    Список топиков
                    -----------------------------------------------------------------
                    */
                    $total = mysql_result(mysql_query("SELECT COUNT(*) FROM `forum` WHERE `type`='t' AND `refid`='$id'" . ($rights >= 7 ? '' : " AND `close`!='1'")), 0);
                    if ($user_id && !$ban['1'] && !$ban['11']) {
                        // Кнопка создания новой темы
                        echo '<div class="gmenu"><form action="index.php?act=nt&id=' . $id . '" method="post"><input type="submit" value="' . $lng_forum['new_topic'] . '" /></form></div>';
                    }
                    if ($total) {
                        $req = mysql_query("SELECT * FROM `forum` WHERE `type`='t'" . ($rights >= 7 ? '' : " AND `close`!='1'") . " AND `refid`='$id' ORDER BY `vip` DESC, `time` DESC LIMIT $start, $kmess");
                        while ($res = mysql_fetch_assoc($req)) {
                            if($res['close'])
                                echo '<div class="rmenu">';
                            else
                                echo $i % 2 ? '<div class="list2">' : '<div class="list1">';
                            $nikuser = mysql_query("SELECT `from` FROM `forum` WHERE `type` = 'm' AND `close` != '1' AND `refid` = '" . $res['id'] . "' ORDER BY `time` DESC LIMIT 1");
                            $nam = mysql_fetch_assoc($nikuser);
                            $colmes = mysql_query("SELECT COUNT(*) FROM `forum` WHERE `type`='m' AND `refid`='" . $res['id'] . "'" . ($rights >= 7 ? '' : " AND `close` != '1'"));
                            $colmes1 = mysql_result($colmes, 0);
                            $cpg = ceil($colmes1 / $kmess);
                            $np = mysql_result(mysql_query("SELECT COUNT(*) FROM `cms_forum_rdm` WHERE `time` >= '" . $res['time'] . "' AND `topic_id` = '" . $res['id'] . "' AND `user_id`='$user_id'"), 0);
                            // Значки
                            $icons = array(
                                ($np ? (!$res['vip'] ? '<img src="../theme/' . $set_user['skin'] . '/images/op.gif" alt=""/>' : '') : '<img src="../theme/' . $set_user['skin'] . '/images/np.gif" alt=""/>'),
                                ($res['vip'] ? '<img src="../theme/' . $set_user['skin'] . '/images/pt.gif" alt=""/>' : ''),
                                ($res['realid'] ? '<img src="../theme/' . $set_user['skin'] . '/images/rate.gif" alt=""/>' : ''),
                                ($res['edit'] ? '<img src="../theme/' . $set_user['skin'] . '/images/tz.gif" alt=""/>' : '')
                            );
                            echo functions::display_menu($icons, ' ', ' ');
                            echo '<a href="index.php?id=' . $res['id'] . '">' . $res['text'] . '</a> [' . $colmes1 . ']';
                            if ($cpg > 1) {
                                echo '<a href="index.php?id=' . $res['id'] . '&page=' . $cpg . '"> >></a>';
                            }
                            echo '<div class="sub">';
                            echo $res['from'];
                            if (!empty($nam['from'])) {
                                echo ' / ' . $nam['from'];
                            }
                            $vrp = $res['time'] + $set_user['sdvig'] * 3600;
                            echo ' <span class="gray">(' . date("d.m.y / H:i", $vrp) . ')</span></div></div>';
                            ++$i;
                        }
                        unset($_SESSION['fsort_id']);
                        unset($_SESSION['fsort_users']);
                    } else {
                        echo '<div class="menu"><p>' . $lng_forum['topic_list_empty'] . '</p></div>';
                    }

    JohnCMS 4, forum/index.php
    Автор мало того, что не знает о шаблонизации, но и незнает ещё о вреде запросов в цикле

    Запостил: NadiaVita, 28 Декабря 2010

    Комментарии (31) RSS

    Добавить комментарий