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

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

    +141

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    function toArray($xml) {
                    $xml = simplexml_load_string($xml);
                    $json = json_encode($xml);
                    return json_decode($json,TRUE);                        
            }

    Но зачем?!

    mr.The, 11 Июня 2012

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

    +148

    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
    var isScheduledRadio = $('#ContentPlaceHolder1_FormView1_ctl04_ctl00___IsScheduled_RadioButtonList1_0')[0],
                    isSitnGoRadio = $('#ContentPlaceHolder1_FormView1_ctl04_ctl00___IsScheduled_RadioButtonList1_1')[0],
                    startDateTextBox = $('#ContentPlaceHolder1_FormView1_ctl04_ctl07___StartDate_TextBox1')[0],
                    minPlayersTextBox = $('#ContentPlaceHolder1_FormView1_ctl04_ctl14___MinPlayers_TextBox1')[0],
                    maxPlayersTextBox = $('#ContentPlaceHolder1_FormView1_ctl04_ctl15___MaxPlayers_TextBox1')[0],
                    maxPlayersRequiredValidator = $('#ContentPlaceHolder1_FormView1_ctl04_ctl15___MaxPlayers_RequiredFieldValidator1')[0],
                    maxPlayersRow = $('#ContentPlaceHolder1_FormView1_ctl04_ctl15___MaxPlayers_TextBox1')
                        .parent()
                        .parent()[0],
                    endDateTextBox = $('#ContentPlaceHolder1_FormView1_ctl04_ctl08___EndDate_TextBox1')[0],
                    endDateRequiredValidator = $('#ContentPlaceHolder1_FormView1_ctl04_ctl08___EndDate_RequiredFieldValidator1')[0],
                    endDateRow = $('#ContentPlaceHolder1_FormView1_ctl04_ctl08___EndDate_TextBox1')
                        .parent()
                        .parent()[0],

    Увидел такой код с сорцах ASP.Net страницы

    krikz, 08 Июня 2012

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

    +160

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    function changeFilter(event) {
      if (parseInt(event.newValue) < 1000) {
        api.Msg.showErr("Укажите год!");
      }
    }

    Обработчик onchange поля "Год"

    glprizes, 07 Июня 2012

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

    +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
    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
    function navigationblock() {
    	$lettersarr=array();
    
    function _strtolower($string)
    {
        $small = array('а','б','в','г','д','е','ё','ж','з','и','й',
                       'к','л','м','н','о','п','р','с','т','у','ф',
                       'х','ч','ц','ш','щ','э','ю','я','ы','ъ','ь',
                       'э', 'ю', 'я');
        $large = array('А','Б','В','Г','Д','Е','Ё','Ж','З','И','Й',
                       'К','Л','М','Н','О','П','Р','С','Т','У','Ф',
                       'Х','Ч','Ц','Ш','Щ','Э','Ю','Я','Ы','Ъ','Ь',
                       'Э', 'Ю', 'Я');
        return str_replace($large, $small, $string); 
    }
     
    function _strtoupper($string)
    {
        $small = array('а','б','в','г','д','е','ё','ж','з','и','й',
                       'к','л','м','н','о','п','р','с','т','у','ф',
                       'х','ч','ц','ш','щ','э','ю','я','ы','ъ','ь',
                       'э', 'ю', 'я');
        $large = array('А','Б','В','Г','Д','Е','Ё','Ж','З','И','Й',
                       'К','Л','М','Н','О','П','Р','С','Т','У','Ф',
                       'Х','Ч','Ц','Ш','Щ','Э','Ю','Я','Ы','Ъ','Ь',
                       'Э', 'Ю', 'Я');
        return str_replace($small, $large, $string); 
    }
    
    	$rs=mysql_query("SELECT DISTINCT firstletter FROM mr_gazette WHERE firstletter!=' ' AND parent=0 ORDER BY firstletter");
    	while($one=mysql_fetch_array($rs)) $lettersarr[]=$one["firstletter"];
    	?><form name=findform action='index.php' method=get style="margin:10px 20px 20px 0px; text-align:right; ">
    		<font style='font:bold 8pt Tahoma;'><? 
    		for ($i=0; $i<count($lettersarr);$i++) {
    			?><a href="index.php?&letter=<?=$lettersarr[$i]?>" style='font:bold 8pt Tahoma; text-transform:uppercase;'><?=_strtolower($lettersarr[$i])?></a><img src="img/null.gif" width=5><?
    		}
    		?></font>
    		<input type=hidden name="act" value="search">
    		<input type=text name=searchval class=frmtextsub>&nbsp;&nbsp;<input type=submit value='найти' class=mybutton style="width:50px; height:18px;">
    	</form><?
    	return $lettersarr;
    }

    T_T

    форматирование сохранено

    psycho-coder, 07 Июня 2012

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

    +62

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    <?php
    if($res==true){
    $bool_res=true;
    } else {
    $bool_res=false;
    }
    ?>

    Нашёл в одной малоизвестной CMS.

    BiggestFox, 02 Июня 2012

    Комментарии (7)
  7. ActionScript / Говнокод #10347

    −153

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    var regs:Array;
    				if ( USE_NEW_SYNTAX )
    					regs = line.match( /vc\[([vif][acost]?)(\d*)?(\.[xyzwrgba](\+\d{1,3})?)?\](\.[xyzwrgba]{1,4})?|([vif][acost]?)(\d*)?(\.[xyzwrgba]{1,4})?/gi );
    				else
    					regs = line.match( /vc\[([vof][actps]?)(\d*)?(\.[xyzwrgba](\+\d{1,3})?)?\](\.[xyzwrgba]{1,4})?|([vof][actps]?)(\d*)?(\.[xyzwrgba]{1,4})?/gi );

    игра найди 10 отличий от Adobe :)

    makc3d, 23 Мая 2012

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

    +130

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    Вакансия: Программист Java
    Требования:
        ....
        знание компьютерных программ: Java, pl/sql, Eclipse, Oracle Repotrs приветствуется;
        ....

    Не совсем то, но не мог пройти мимо.

    -EZ-, 17 Мая 2012

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

    +93

    1. 1
    if (indSpec == false || indZone == false || (FRof != null && FRof == 2)) result = 1;

    Нашли в проекте вот такое "женское" условие. Видимо, префиксом "ind" автор намекала на своё происхождение.

    DukeGonzo, 15 Мая 2012

    Комментарии (7)
  10. Куча / Говнокод #10258

    +128

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>По колено в коде —  Говнокод.ру</title>
    
    <!-- Пару десятков строчек спустя -->
    
    <li><script type="text/javascript" src="http://reformal.ru/tab.js?title=%C3%EE%E2%ED%EE%EA%EE%E4.%F0%F3%3A+%EF%EE+%EA%EE%EB%E5%ED%EE+%E2+%EA%EE%E4%E5&amp;domain=govnokod&amp;color=adadad&amp;align=left&amp;charset=cp1251&amp;ltitle=%CE%F2%E7%FB%E2%FB&amp;lfont=Verdana, Geneva, sans-serif&amp;lsize=11px&amp;waction=0&amp;regime=1"></script></li>

    Чтобы решить проблему с кодировкой - нужно просто поменять charset=cp1251 на charset=utf8, вестимо.
    Но страйко который год не может.

    7ion, 13 Мая 2012

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

    +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
    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
    #include <stdio.h>
    #include <string>
    int main()
    {
    	freopen("input.txt","r",stdin);
            freopen("output.txt","w",stdout);
    	char s[100];
    	int n1 = 0,eq = 0,i = 0,o = 0,e = 0;
    	scanf("%s",&s);
    	int len;
    	len = strlen(s);
    	for(i = 0; i <= len; i++)
    	{
    		if ((s[i] == '+') || (s[i] == '-') || (s[i] == '/') || (s[i] == '*')) 
    		{
    			if (s[i-1] != '=')
    			{
    				n1 = i;
    				o = 1;
    			}
    				
    			
    			if ((n1 == '-') && (s[i-1] == '+') || (s[i-1] == '-') || (s[i-1] == '/') || (s[i-1] == '*'))
    			{
    				n1--;
    				o = 1;
    			}
    
    			
    		}
    		if (s[i] == '=')
    		{
    			eq = i;
    			e++;
    		}
    	}
    
    	if ((eq == 0) || (n1 == 0) || (e != 1) || (o != 1))
    	{
    		printf("ERROR");
    		return 0;
    	}
    	char* err ;
    	//begin copy-paste :(
    	char s1[100] = "0";
    	for(i = 0; i < n1; i++)
    	{
    		s1[i] = s[i];
    	}
    	long l1 = strtol(s1, &err, 10);
    	if (*err) 
    	{
    		printf("ERROR");
    		return 0;
    	}
    	//еще 10-15 строк
    	//end copy-paste :(
    	//begin new copy-paste :((
    	if (s[n1] == '+')
    	{
    		if (l1 + l2 == l3)
    		{
    			printf("YES");
    		} else 
    		{
    			printf("NO");
    		}
    	}
    	if (s[n1] == '/')
    	{
    		if (l2 != 0) 
    		{
    			if((l1 / l2 == l3) && (l1 % l2 == 0))
    			{
    				printf("YES");
    			} else 
    			{
    				printf("NO");
    			}
    		} else
    		{
    			printf("NO");
    		}
    
    
    	}
    	//Еще 10-15 строк
    	//end new copy-paste :((
    
    	
    	return 0;
    }

    А всего-то надо проверить верно ли тождество. (Тождество очень простое и состоит из числа, операции («+», «-», «*», «/»), числа, знака равенства и числа)

    bars66, 10 Мая 2012

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