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

    +148

    1. 1
    2. 2
    3. 3
    4. 4
    if($line['orderstatus']==0) echo '<td title="Статус" bgcolor="red"><a href="/admin/changeorderstatus2.php?id='.$line['id'].'&sortorder='.$sortorder.'&start='.$start.'" class="gallery4">в обработке</a></td>';
    if($line['orderstatus']==1) echo '<td title="Статус" bgcolor="yellow"><a href="/admin/changeorderstatus2.php?id='.$line['id'].'&sortorder='.$sortorder.'&start='.$start.'" class="gallery4">Не оплачен, отправлен</a></td>';
    if($line['orderstatus']==2) echo '<td title="Статус" bgcolor="cyan"><a href="/admin/changeorderstatus2.php?id='.$line['id'].'&sortorder='.$sortorder.'&start='.$start.'" class="gallery4">Оплачен, отправлен</a></td>';
    if($line['orderstatus']==3) echo '<td title="Статус" bgcolor="lightgreen"><a href="/admin/changeorderstatus2.php?id='.$line['id'].'&sortorder='.$sortorder.'&start='.$start.'" class="gallery4">Оплачен, получен</a></td>';

    rockstar, 20 Апреля 2013

    Комментарии (0)
  2. C# / Говнокод #12921

    +136

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    if (best == null)
                {
                    return null;
                }
                else
                {
                    return best;
                }

    Psilon, 19 Апреля 2013

    Комментарии (16)
  3. Python / Говнокод #12920

    −105

    1. 1
    2. 2
    3. 3
    Дана строка. Разрежьте ее на две равные части (если длина строки — четная, а если длина строки нечетная, то длина первой части должна быть на один символ больше). Переставьте эти две части местами, результат запишите в новую строку и выведите на экран.
    
    При решении этой задачи не стоит пользоваться инструкцией if.

    Вообще не разбираюсь в строках. Помогите пожалуйста.

    alexsid13, 19 Апреля 2013

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

    +151

    1. 1
    2. 2
    3. 3
    4. 4
    <?php
    // autoload.php generated by Composer
    require_once __DIR__ . '/composer' . '/autoload_real.php';
    return ComposerAutoloaderInite3f5acf96d9ae66df74c4805c906a9e2::getLoader();

    Господа, что-то вот не пойму, можно ли ругаться в таких случаях, когда код генерированный. Можно ли писать всякое говно в код, если при этом говорить: "ты не должен туда смотреть, это скрипт, написанный скриптом для скрипта." Я тут вижу говноконкатенацию строковой константы со строковой константой оператором '.' и говноимя, класса в последней строке. Лично моё мнение, что если бы я написал код, в котором вынужден был бы генерировать такие имена, я бы констатировал серьёзную ошибку проектирования на более ранних стадиях.

    zasedanie, 19 Апреля 2013

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

    +137

    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
    if (curMenu != null)
    {
      depth = curMenu.Depth;
      Menu menuG = null;
      if (depth == 1)
      {
        menuG = curMenu;
      }
      if (depth == 2)
      {
        menuG = curMenu.Menu2;
      }
      if (depth == 3)
      {
        menuG = curMenu.Menu2.Menu2;
      }
      if (depth == 4)
      {
        menuG = curMenu.Menu2.Menu2.Menu2;
      }
      if (depth == 5)
      {
        menuG = curMenu.Menu2.Menu2.Menu2.Menu2;
      }
      if (depth == 6)
      {
        menuG = curMenu.Menu2.Menu2.Menu2.Menu2.Menu2;
      }
      if (depth == 7)
      {
        menuG = curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Menu2;
      }
      if (depth == 8)
      {
        menuG = curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Menu2.Menu2;
      }
    }

    Nested set для петухов!

    validol, 19 Апреля 2013

    Комментарии (7)
  6. C# / Говнокод #12917

    +132

    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
    <div class="breadcrumbs">
      <ul>
        <li>
          @if (curMenu != null)
          {
            <a href="@Url.Action("index", "main")">Главная</a><span class="breadcrumbs__dash"> / </span>
            if (depth == 1)
            {
              <span>@(curMenu.Title)</span>
            }
            else if (depth == 2)
            {
              <a href="/@curMenu.Menu2.Url">@(curMenu.Menu2.Title)</a> <span class="breadcrumbs__dash"> / </span>
              <span>@(curMenu.Title)</span>
            }
            else if (depth == 3)
            {
              <a href="/@curMenu.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Url">@(curMenu.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <span>@(curMenu.Title)</span>
            }
            else if (depth == 4)
            {
              <a href="/@curMenu.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Url">@(curMenu.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <span>@(curMenu.Title)</span>
            }
            else if (depth == 5)
            {
              <a href="/@curMenu.Menu2.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Url">@(curMenu.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <span>@(curMenu.Title)</span>
            }
            else if (depth == 6)
            {
              <a href="/@curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Url">@(curMenu.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <span>@(curMenu.Title)</span>
            }
            else if (depth == 7)
            {
              <a href="/@curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Url">@(curMenu.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <span>@(curMenu.Title)</span>
            }
            else if (depth == 8)
            {
              <a href="/@curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Url">@(curMenu.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <span>@(curMenu.Title)</span>
            }                                  
          }
          else if (ViewBag.Title != null && url!="/")
          {
            <a href="@Url.Action("index", "main")">Главная</a><span class="breadcrumbs__dash"> / </span>
            <span>@ViewBag.Title</span>
          }
        </li>
      </ul>
    </div>

    Хлебные крошки в каталоге "неограниченной" вложенности.

    validol, 19 Апреля 2013

    Комментарии (6)
  7. JavaScript / Говнокод #12916

    +159

    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
    $("#menu44").click(function () {
      $("#menu111").hide();
      $("#menu222").hide();
      $("#menu333").hide();
      $("#menu444").show();
      $("#menu555").hide();
      $("#menu666").hide();
      $("#menu777").hide();
      $(".selMenu_group").removeClass("selMenu_group");
      $(this).children().addClass("selMenu_group");
    });
    $("#menu55").click(function () {
      $("#menu111").hide();
      $("#menu222").hide();
      $("#menu333").hide();
      $("#menu444").hide();
      $("#menu555").show();
      $("#menu666").hide();
      $("#menu777").hide();
      $(".selMenu_group").removeClass("selMenu_group");
      $(this).children().addClass("selMenu_group");
    });
    
    $("#menu66").click(function () {
      $("#menu111").hide();
      $("#menu222").hide();
      $("#menu333").hide();
      $("#menu444").hide();
      $("#menu555").hide();
      $("#menu666").show();
      $("#menu777").hide();
      $(".selMenu_group").removeClass("selMenu_group");
      $(this).children().addClass("selMenu_group");
    });
    
    $("#menu77").click(function () {
      $("#menu111").hide();
      $("#menu222").hide();
      $("#menu333").hide();
      $("#menu444").hide();
      $("#menu555").hide();
      $("#menu666").hide();
      $("#menu777").show();
      $(".selMenu_group").removeClass("selMenu_group");
      $(this).children().addClass("selMenu_group");
    });

    Творение самого коммерчески эффективного разработчика студии.

    validol, 19 Апреля 2013

    Комментарии (3)
  8. Java / Говнокод #12915

    +70

    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
    private String formatString(String input, int lenght){
            String result = "";
            int len = lenght - input.length();
            int left = Math.round(len/2);
            int right = len - left;
            for(int i=0; i<left; i++){
                result = " " + result;
            }
            result = result + input;
            for(int i=0; i<right; i++){
                result = result + " ";
            }
            return result;
        }

    выравнивание текста в центре пустой строки фиксированной ширины.

    nafania217518, 19 Апреля 2013

    Комментарии (17)
  9. Pascal / Говнокод #12914

    +100

    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
    procedure print(RTK_select:boolean; RLK_select:boolen;MOLK_select:boolean)
    begin
         if (RTK_select and not RLK_select and not MOLK_select) then
             Excel.ActiveWorkBook.WorkSheets[1].Range['B4'] := 'РТК';
    
         if (not RTK_select and RLK_select and not MOLK_select) then
             Excel.ActiveWorkBook.WorkSheets[1].Range['B4'] := 'РЛК';
    
         if (not RTK_select and not RLK_select and MOLK_select) then
             Excel.ActiveWorkBook.WorkSheets[1].Range['B4'] := 'МОЛК';
    
         if (RTK_select and RLK_select and not MOLK_select) then
             Excel.ActiveWorkBook.WorkSheets[1].Range['B4'] := 'РТК,РЛК';
    
         if (not RTK_select and RLK_select and MOLK_select) then
             Excel.ActiveWorkBook.WorkSheets[1].Range['B4'] := 'РЛК,МОЛК';
    
         if (RTK_select and not RLK_select and  MOLK_select) then
             Excel.ActiveWorkBook.WorkSheets[1].Range['B4'] := 'РТК,МОЛК';
    
         if (RTK_select and RLK_select and  MOLK_select) then
             Excel.ActiveWorkBook.WorkSheets[1].Range['B4'] := 'РТК,РЛК,МОЛК';
    
         if (not RTK_select and not RLK_select and not MOLK_select) then
             Excel.ActiveWorkBook.WorkSheets[1].Range['B4'] := '';
    end

    Обнаружено в недрах старинного проекта. Запись строчки по флажкам.

    astamir, 19 Апреля 2013

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

    +153

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    // проверка при дополнительных надстройках
    		if (
    				$this->struct[$num][$v]['changes'] &&		 // если значение было изменено
    				array_key_exists($v, $this->values) &&		// и существуют альтернативно назначенные тип поля (select или radio)
    				isset( $this->values[$v]['vals'] ) &&			 // и также существуют для них значения для значений...
    				!isset( $this->values[$v]['vals'][ $this->struct[$num][$v]['value'] ] )		// НО, пришедшее значение НЕ СООТВЕТСТВУЕТ
    			) {
    
    					$this->struct[$num][$v]['error'] = 'Неправильно указано значение';
    		}

    Ёжкин кот. Вот чего он хотел этим сказать? И что мне теперь с этим делать теперь?

    DoctorHouse, 19 Апреля 2013

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