1. Куча / Говнокод #16723

    +128

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    <a href="#" id="foo" onclick="this.nextSibling.style.display=''; return!1;">Click here for view</a><p style="display: none;">
    <noscript>
        </p>
            <style type="text/css"> a#foo { display:none; } </style>
        <p>
    </noscript>
    
        /*... some info ...*/
    </p>

    Баян, не? Вот. Наговнокодилось. captcha=5555

    istem, 18 Сентября 2014

    Комментарии (13)
  2. PHP / Говнокод #16722

    +158

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    $rand = rand(1,100);
    if (($rand => 1) && ($rand <= 50)) {
    include 'код баннера 1';
    }
    elseif (($rand => 51) && ($rand <= 80)) {
    include 'код баннера 2';
    }
    else {
    include 'код баннера 3';
    }
    
    50% - баннер 1, 30% - баннер 2, остальное (20%) - баннер 3.

    Хотели сделать "ротацию с весом" для X баннеров :)

    SVP, 18 Сентября 2014

    Комментарии (10)
  3. JavaScript / Говнокод #16721

    +143

    1. 1
    2. 2
    3. 3
    if (typeof window.$lab === 'undefined') {
        document.write('<script type="text/javascript">var $lab = jQuery.noConflict(true);\x3C/script>');
    }

    потому что eval - зло
    P.s. \x3C/script> - такая запись ибо впилено тегом скрипт в head

    RedMonkey, 18 Сентября 2014

    Комментарии (15)
  4. PHP / Говнокод #16720

    +158

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    if ($qproizv_r->s > 0 && $qpriem_n > 0) {
        if ($qproizv_r->s >= $row->Kol) {
            $Status = 6;
        }
    } else {
        if ($qpriem_n > 0) {
            $Status = 6;
        }
    }

    Так и живем.

    Khvorostin, 18 Сентября 2014

    Комментарии (0)
  5. Java / Говнокод #16719

    +82

    1. 1
    Boolean hasRefId = !node.getAttributes().getNamedItem("refid").equals(null);

    equals(null)

    roman-kashitsyn, 18 Сентября 2014

    Комментарии (10)
  6. Java / Говнокод #16718

    +76

    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
    function returnUserId() {
        if (document.getElementById('userstap') != null )  {
            var obj = document.getElementById('userstap');
            <% if ((sUserIdForPrint != null) && !sUserIdForPrint.equals("")) {%>
            if (obj.options[obj.selectedIndex].value == 0) {
                return "<%=sUserIdForPrint%>";
            <% } %>
            <% if (((sAccGrpUserIdForPrint != null) && !sAccGrpUserIdForPrint.equals("")) && ((sUserIdForPrint != null) && !sUserIdForPrint.equals(""))) {%>
            } else if (obj.options[obj.selectedIndex].value == 1 ) {
                return "<%=sAccGrpUserIdForPrint%>";
            <% } else if ((sAccGrpUserIdForPrint != null) && !sAccGrpUserIdForPrint.equals("")){%>
            if (obj.options[obj.selectedIndex].value == 1 ) {
                return "<%=sAccGrpUserIdForPrint%>";
            <% } %>
            <% if (((sAccGrpUserIdForPrint != null) && !sAccGrpUserIdForPrint.equals("")) || ((sUserIdForPrint != null) && !sUserIdForPrint.equals(""))) {%>
            } else if (obj.options[obj.selectedIndex].value == 2) {
                return "<%=userId%>";
            }
            <% } else {%>
            if (obj.options[obj.selectedIndex].value == 2) {
                return "<%=userId%>";
            }
            <% } %>
        } else {
            return "<%=userId%>";
        }
    }

    Любите ли вы JSP так, как люблю его я?

    codingHorror, 18 Сентября 2014

    Комментарии (14)
  7. PHP / Говнокод #16717

    +155

    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
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    <?php
    
    /**
     * Get category tree.
     * 
     * @param db $db
     * @return array
     */
    function getCategoryTree ($db) {
    	$query = $db->query('SELECT * FROM dle_category ORDER BY posi');
    	
    	if ($query->num_rows <= 0) {
    		return FALSE;
    	}
    	
    	$categories = $query->fetch_all(MYSQLI_ASSOC);
    	
    	$tree = array();
    	
    	foreach ($categories as $cat) {
    		if ($cat['parentid'] == '0') {
    			$tree[$cat['id']] = $cat;
    		}
    		else {
    			$tree[$cat['parentid']]['subcategories'][] = $cat;
    		}
    	}
    	
    	return $tree;
    }
    
    /**
     * Display categories.
     * Sorry for my french 'echo'.
     * 
     * @param array $category
     */
    function displayCategory ($category) {
    	$html = '';
    	
    	foreach ($category as $cat) {
    		$html .= '<li class="lonely "><a href="/">' . $cat['name'] . '</a>';
    		
    		if ($cat['subcategories']) {
    			$html .= '<span class="accordion"></span><ul>';
    			$html .= displayCategory ($cat['subcategories']);
    			$html .= '</ul>';
    		}
    		
    		$html .= '</li>';
    	}
    	
    	return $html;
    }
    
    // Getting categories
    $categories = getCategoryTree($db);
    
    if ($categories) {
    	echo displayCategory ($categories);
    }
    else {
    	echo '<li>Нету категорий</li>';
    }

    Мой говно модуль для DLE для отображения дерева категорий в меню.
    Почему DLE разработчики не могли это из коробки сделать? И почему там куча говнокода внутри? (на Англ. комментарии потому что привык)

    volter9, 17 Сентября 2014

    Комментарии (69)
  8. C# / Говнокод #16716

    +140

    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
    @foreach (var groupTest in Model.Select(t => t.TestType).Distinct())
    {
        <div class="form-column form-column2">
            <div class="static-height">
                <p class="content-subblock-title left upper-text">
                    <label>
                        @if (@groupTest.GetEnumDescription().Length < 34)
                        {
                            <text>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</text>
                        }
                        @groupTest.GetEnumDescription()
                    </label>
                </p>
                @foreach (var item in Model.Where(t => t.TestType == groupTest).OrderBy(t => t.Order))
                {
                    <div class="donation-row">
                        <label>@item.TestName</label>
                        <span class="@item.TestClass blood-test-value-don">
                            @item.TestValue
                        </span>
                    </div>
                }
    
            </div>
        </div>
    }

    Я пялюсь на этот кусок вот уже полчаса...

    amatenkov, 17 Сентября 2014

    Комментарии (16)
  9. C# / Говнокод #16715

    +135

    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
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    if ((Mathf.Abs(_mouseOverX) > 0.2f || Mathf.Abs(_mouseOverY) > 0.2f))
         {
    
    
            switch (selecetedItemIndex)
         {
                case -1 :
                    var a = Mathf.Atan2(_mouseOverX, _mouseOverY) * Mathf.Rad2Deg;
                    a += angle / 2.0f;
                    if (a < 0) a = a + 360.0f;
    
                    index = (int)(a / angle);
             break;
                case 0:
                    var a0 = Mathf.Atan2(_mouseOverX, _mouseOverY) * Mathf.Rad2Deg;
                    a0 += angle / 2.0f;
                    if (a0 < 0) a0 = a0 + 360.0f;
    
                    index = (int)(a0 / angle);
    
                 switch (index)
                 {
                     case 5 :
                         index = 7;
                         break;
                        case 6:
                            index = 7;
                            break;
                        case 4 :
                         index = -1;
                         break;
                        case 3:
                            index = 1;
                            break;
                        case 2:
                            index = 1;
                            break;
                 }
                 break;
                case 1:
                    var a1 = Mathf.Atan2(_mouseOverX, _mouseOverY) * Mathf.Rad2Deg;
                    a1 += angle / 2.0f;
                    if (a1 < 0) a1 = a1 + 360.0f;
    
                    index = (int)(a1 / angle);
    
                 switch (index)
                 {
                     case 0 :
                         index = 0;
                         break;
                        case 7:
                            index = 0;
                            break;
                        case 6 :
                         index = -1;
                         break;
                        case 5:
                            index = -1;
                            break;
                        case 4:
                            index = 3;
                            break;
                        case 3:
                            index = 3;
                            break;
                        case 2:
                            index = 2;
                            break;
                 }
                 break;
                case 2:
                    var a2 = Mathf.Atan2(_mouseOverX, _mouseOverY) * Mathf.Rad2Deg;
                    a2 += angle / 2.0f;
                    if (a2 < 0) a2 = a2 + 360.0f;
    
                    index = (int)(a2 / angle);
    
                    switch (index)
                    {
                        case 0: index = 1; break;
                        case 7: index = 1; break;
                        case 6: index = -1; break;
                        case 5: index = 3; break;
                        case 4: index = 3; break;
                    }
                    break;
                case 3:
                    var a3 = Mathf.Atan2(_mouseOverX, _mouseOverY) * Mathf.Rad2Deg;
                    a3 += angle / 2.0f;
                    if (a3 < 0) a3 = a3 + 360.0f;
    
                    index = (int)(a3 / angle);
    
                    switch (index)

    Radial menu govnokod style

    noshitleft, 17 Сентября 2014

    Комментарии (2)
  10. JavaScript / Говнокод #16714

    +135

    1. 1
    function e(id){ return document.getElementById(id); }

    Бредогенерации тред.

    3.14159265, 17 Сентября 2014

    Комментарии (585)