1. Лучший говнокод

    В номинации:
    За время:
  2. PHP / Говнокод #7879

    +36

    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
    function utf8win ($strin)  {
    	$strin = ereg_replace("а","а",$strin);
    	$strin = ereg_replace("б","б",$strin);
    	$strin = ereg_replace("в","в",$strin);
    	$strin = ereg_replace("г","г",$strin);
    	$strin = ereg_replace("д","д",$strin);
    	$strin = ereg_replace("е","е",$strin);
    	$strin = ereg_replace("ё","ё",$strin);
    	$strin = ereg_replace("ж","ж",$strin);
    	$strin = ereg_replace("з","з",$strin);
    	$strin = ereg_replace("и","и",$strin);
    	$strin = ereg_replace("й","й",$strin);
    	$strin = ereg_replace("к","к",$strin);
    	$strin = ereg_replace("л","л",$strin);
    	$strin = ereg_replace("м","м",$strin);
    	$strin = ereg_replace("н","н",$strin);
    	$strin = ereg_replace("о","о",$strin);
    	$strin = ereg_replace("п","п",$strin);
    	$strin = ereg_replace("р","р",$strin);
    	$strin = ereg_replace("с","с",$strin);
    	$strin = ereg_replace("т","т",$strin);
    	$strin = ereg_replace("у","у",$strin);
    	$strin = ereg_replace("ф","ф",$strin);
    	$strin = ereg_replace("х","х",$strin);
    	$strin = ereg_replace("ц","ц",$strin);
    	$strin = ereg_replace("ш","ш",$strin);
    	$strin = ereg_replace("щ","щ",$strin);
    	$strin = ereg_replace("ъ","ъ",$strin);
    	$strin = ereg_replace("ь","ь",$strin);
    	$strin = ereg_replace("э","э",$strin);
    	$strin = ereg_replace("ю","ю",$strin);
    	$strin = ereg_replace("я","я",$strin);
    	$strin = ereg_replace("ч","ч",$strin);
    	$strin = ereg_replace("ы","ы",$strin);
    	$strin = ereg_replace("А","А",$strin);
    	$strin = ereg_replace("Б","Б",$strin);
    	$strin = ereg_replace("В","В",$strin);
    	$strin = ereg_replace("Г","Г",$strin);
    	$strin = ereg_replace("Д","Д",$strin);
    	$strin = ereg_replace("Е","Е",$strin);
    	$strin = ereg_replace("Ж","Ж",$strin);
    	$strin = ereg_replace("З","З",$strin);
    	$strin = ereg_replace("И","И",$strin);
    	$strin = ereg_replace("Й","Й",$strin);
    	$strin = ereg_replace("К","К",$strin);
    	$strin = ereg_replace("Л","Л",$strin);
    	$strin = ereg_replace("М","М",$strin);
    	$strin = ereg_replace("Н","Н",$strin);
    	$strin = ereg_replace("О","О",$strin);
    	$strin = ereg_replace("П","П",$strin);
    	$strin = ereg_replace("Р","Р",$strin);
    	$strin = ereg_replace("С","С",$strin);
    	$strin = ereg_replace("Т","Т",$strin);
    	$strin = ereg_replace("У","У",$strin);
    	$strin = ereg_replace("Ф","Ф",$strin);
    	$strin = ereg_replace("Х","Х",$strin);
    	$strin = ereg_replace("Ц","Ц",$strin);
    	$strin = ereg_replace("Ш","Ш",$strin);
    	$strin = ereg_replace("Щ","Щ",$strin);
    	$strin = ereg_replace("Ъ","Ъ",$strin);
    	$strin = ereg_replace("Ь","Ь",$strin);
    	$strin = ereg_replace("Э","Э",$strin);
    	$strin = ereg_replace("Ю","Ю",$strin);
    	$strin = ereg_replace("Я","Я",$strin);
    	$strin = ereg_replace("Ч","Ч",$strin);
    	$strin = ereg_replace("Ы","Ы",$strin);
    	$strin = ereg_replace("A","Ё",$strin);
    	return $strin;
    }

    brainstorm, 16 Сентября 2011

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

    +36

    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
    /**
     * Implementation of hook_access().
     *
     * Node modules may implement node_access() to determine the operations
     * users may perform on nodes. This example uses a very common access pattern.
     */
    function node_example_access($op, $node, $account) {
      if ($op == 'create') {
        return user_access('create example content', $account);
      }
    
      if ($op == 'update') {
        if (user_access('edit any example content', $account) || (user_access('edit own example content', $account) && ($account->uid == $node->uid))) {
          return TRUE;
        }
      }
    
      if ($op == 'delete') {
        if (user_access('delete any example content', $account) || (user_access('delete own example content', $account) && ($account->uid == $node->uid))) {
          return TRUE;
        }
      }
    }

    http://api.drupal.org/api/examples/node_example--node_example.module/6/source
    тут еще много.
    но факт что те кто это пишут таки нужные люди. сама документация достаточно достоверна

    brainstorm, 02 Февраля 2011

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

    +36

    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
    //
                  <?php if (arg(0) == 'taxonomy' && arg(1) == 'term') {
                   $term = taxonomy_get_term(arg(2));
                   if ($term->vid == 2) { ?>
                     LCD TV Listings
                   <?php } elseif ($term->vid == 1) { ?>
                     Size LCD TV Listings
                   <?php } elseif ($term->vid == 8) { ?>
                     Questions
                   <?php } elseif ($term->vid == 10) { ?>
                     LCD TV News
                   <?php } elseif ($term->vid == 11) { ?>
                     Related LCD TV News
                   <?php } ?>
               <?php } ?>

    Вот такое прямо в шаблоне.... no comments

    brainstorm, 15 Декабря 2010

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

    +36

    1. 1
    2. 2
    3. 3
    4. 4
    ...
    catch (HeadshotException $e) {
    echo "Извините, вы застрелились: {$e->getMessage()}";
    ...

    В книге Котерова и Костарева по PHP5 наткнулся на замечательный пример кода. Прям за душу взяло, чесслово!

    (с) bash

    guest, 24 Ноября 2008

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

    +35.9

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    void Gllibform::setYear(int year)
    {
    	if ( (!is_connection) && ( (_IRZ=="t0406") || (_IRZ=="t0306") ) )
    	{
    		defaultDB = (QSqlDatabase*)year;
    		is_connection = true;
    	} else {
    		plgod = year;
    	}
    }

    Отформатировано для удобочитаемости.
    Цель кода - хз.
    ИРЗ - это Информационно-расчётная задача (номер модуля).
    Приведение int'а к подключению БД - это просто финиш...

    guest, 20 Января 2009

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

    +35.8

    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
    <?php
    function utf8_to_cp1251($text) {
    	$text = str_replace(chr(208),chr(208).chr(160),$text); # Р
    	$text = str_replace(chr(192),chr(208).chr(144),$text); # А
    	$text = str_replace(chr(193),chr(208).chr(145),$text); # Б
    	$text = str_replace(chr(194),chr(208).chr(146),$text); # В
    	$text = str_replace(chr(195),chr(208).chr(147),$text); # Г
    	$text = str_replace(chr(196),chr(208).chr(148),$text); # Д
    	$text = str_replace(chr(197),chr(208).chr(149),$text); # Е
    	$text = str_replace(chr(168),chr(208).chr(129),$text); # Ё
    	$text = str_replace(chr(198),chr(208).chr(150),$text); # Ж
    	$text = str_replace(chr(199),chr(208).chr(151),$text); # З
    	$text = str_replace(chr(200),chr(208).chr(152),$text); # И
    	$text = str_replace(chr(201),chr(208).chr(153),$text); # Й
    	$text = str_replace(chr(202),chr(208).chr(154),$text); # К
    	$text = str_replace(chr(203),chr(208).chr(155),$text); # Л
    	$text = str_replace(chr(204),chr(208).chr(156),$text); # М
    	$text = str_replace(chr(205),chr(208).chr(157),$text); # Н
    	$text = str_replace(chr(206),chr(208).chr(158),$text); # О
    	$text = str_replace(chr(207),chr(208).chr(159),$text); # П
    	$text = str_replace(chr(209),chr(208).chr(161),$text); # С
    	$text = str_replace(chr(210),chr(208).chr(162),$text); # Т
    	$text = str_replace(chr(211),chr(208).chr(163),$text); # У
    	$text = str_replace(chr(212),chr(208).chr(164),$text); # Ф
    	$text = str_replace(chr(213),chr(208).chr(165),$text); # Х
    	$text = str_replace(chr(214),chr(208).chr(166),$text); # Ц
    	$text = str_replace(chr(215),chr(208).chr(167),$text); # Ч
    	$text = str_replace(chr(216),chr(208).chr(168),$text); # Ш
    	$text = str_replace(chr(217),chr(208).chr(169),$text); # Щ
    	$text = str_replace(chr(218),chr(208).chr(170),$text); # Ъ
    	$text = str_replace(chr(219),chr(208).chr(171),$text); # Ы
    	$text = str_replace(chr(220),chr(208).chr(172),$text); # Ь
    	$text = str_replace(chr(221),chr(208).chr(173),$text); # Э
    	$text = str_replace(chr(222),chr(208).chr(174),$text); # Ю
    	$text = str_replace(chr(223),chr(208).chr(175),$text); # Я
    	$text = str_replace(chr(224),chr(208).chr(176),$text); # а
    	$text = str_replace(chr(225),chr(208).chr(177),$text); # б
    	$text = str_replace(chr(226),chr(208).chr(178),$text); # в
    	$text = str_replace(chr(227),chr(208).chr(179),$text); # г
    	$text = str_replace(chr(228),chr(208).chr(180),$text); # д
    	$text = str_replace(chr(229),chr(208).chr(181),$text); # е
    	$text = str_replace(chr(184),chr(209).chr(145),$text); # ё
    	$text = str_replace(chr(230),chr(208).chr(182),$text); # ж
    	$text = str_replace(chr(231),chr(208).chr(183),$text); # з
    	$text = str_replace(chr(232),chr(208).chr(184),$text); # и
    	$text = str_replace(chr(233),chr(208).chr(185),$text); # й
    	$text = str_replace(chr(234),chr(208).chr(186),$text); # к
    	$text = str_replace(chr(235),chr(208).chr(187),$text); # л
    	$text = str_replace(chr(236),chr(208).chr(188),$text); # м
    	$text = str_replace(chr(237),chr(208).chr(189),$text); # н
    	$text = str_replace(chr(238),chr(208).chr(190),$text); # о
    	$text = str_replace(chr(239),chr(208).chr(191),$text); # п
    	$text = str_replace(chr(240),chr(209).chr(128),$text); # р
    	$text = str_replace(chr(241),chr(209).chr(129),$text); # с
    	$text = str_replace(chr(242),chr(209).chr(130),$text); # т
    	$text = str_replace(chr(243),chr(209).chr(131),$text); # у
    	$text = str_replace(chr(244),chr(209).chr(132),$text); # ф
    	$text = str_replace(chr(245),chr(209).chr(133),$text); # х
    	$text = str_replace(chr(246),chr(209).chr(134),$text); # ц
    	$text = str_replace(chr(247),chr(209).chr(135),$text); # ч
    	$text = str_replace(chr(248),chr(209).chr(136),$text); # ш
    	$text = str_replace(chr(249),chr(209).chr(137),$text); # щ
    	$text = str_replace(chr(250),chr(209).chr(138),$text); # ъ
    	$text = str_replace(chr(251),chr(209).chr(139),$text); # ы
    	$text = str_replace(chr(252),chr(209).chr(140),$text); # ь
    	$text = str_replace(chr(253),chr(209).chr(141),$text); # э
    	$text = str_replace(chr(254),chr(209).chr(142),$text); # ю
    	$text = str_replace(chr(255),chr(209).chr(143),$text); # я
    	return $text;
    }
    ?>

    Функция переобразования кодировки

    guest, 14 Января 2009

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

    +35.6

    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
        function getError() {
            var error = false;
            if (isNaN($('client_sum').value) || $('client_sum').value <= 0) {
                $('error_op').innerHTML = "Только число большее  нуля";
                error = true;
            } else {
                $('error_op').innerHTML = "";
            }
            if ($('comment').value == "") {
                $('error_op2').innerHTML = "Введите примечание";
                error = true;
            } else {
                $('error_op2').innerHTML = "";
            }
            if (error == true) return false;
        }

    guest, 25 Ноября 2008

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

    +35.2

    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
    function ViewStar($prop){
    	switch ($prop) {
    	case 3:
    	    return "<img alt=\"Star\" src=\"".$z."images/star.gif\"/>
    				<img alt=\"Star\" src=\"".$z."images/star.gif\"/>
    				<img alt=\"Star\" src=\"".$z."images/star.gif\"/>";
    	    break;
    	case 4:
    	    return "<img alt=\"Star\" src=\"".$z."images/star.gif\"/>
    				<img alt=\"Star\" src=\"".$z."images/star.gif\"/>
    				<img alt=\"Star\" src=\"".$z."images/star.gif\"/>
    				<img alt=\"Star\" src=\"".$z."images/star.gif\"/>";
    	    break;
    	case 5:
    	    return "<img alt=\"Star\" src=\"".$z."images/star.gif\"/>
    				<img alt=\"Star\" src=\"".$z."images/star.gif\"/>
    				<img alt=\"Star\" src=\"".$z."images/star.gif\"/>
    				<img alt=\"Star\" src=\"".$z."images/star.gif\"/>
    				<img alt=\"Star\" src=\"".$z."images/star.gif\"/>";
    	    break;
    	}
    }

    Только что копался в старых исходниках.... эх, не знал про str_repeat

    guest, 23 Января 2009

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

    +35

    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
    main ()
    {
    system("COLOR 0A");
    double ob, x1 , x2 , y1 , y2, p1 , p2 , pi , skolko , status;
     
        system("echo Интерполяция X1 - X2 ");
        system("echo Ввести число:");
        cin >> ob;
     
        system("echo Например 62, C1 = 60, L1 = 1.31 ,C2 = 80 , L2 = 1.29");
        cout << "C1 = ";
               cin >> x1;
        cout << "L1 = " ;
               cin >> x2;
        cout << "C2 = " ;
               cin >> y1;
        cout << "L2 = " ;  
               cin >> y2;
     
          p1 = y1 - x1;
          p2 = y2 - x2;
     
        pi = p2 / p1;
          skolko = ob - x1;
          status = x2 + (pi * skolko);
     
        cout << "_______________________________________________________________";
        cout << endl <<  ob << " = " << status;
        _getch ();
        system("CLS");
     
        return 0;
    }

    с википедии
    вывод с помощью потока уникально сочетается с выводом путём вызова системных команд

    TarasB, 24 Июля 2014

    Комментарии (51)
  11. C++ / Говнокод #13094

    +35

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    #if defined(_WIN32) || defined(_WIN64)
        ofstream outfile("help.txt");
        outfile << message << endl;
        system("notepad.exe help.txt");
     #else
        cout << message ;
    #endif

    Зачем бороться с юникодом в консоли, когда есть блокнот?

    crastinus, 03 Июня 2013

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