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

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

    +133.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
    /* {{{ proto mixed array_reduce(array input, mixed callback [, int initial])
       Iteratively reduce the array to a single value via the callback. */
    ...
    
            if (ZEND_NUM_ARGS() > 2) {
                    ALLOC_ZVAL(result);
                    *result = **initial;
                    zval_copy_ctor(result);
                    convert_to_long(result); // SIC!
                    INIT_PZVAL(result);
            }
    ...

    Исходники PHP, array_reduce.

    Обнаружил http://antilamer.livejournal.com/269560.html

    guest, 23 Марта 2009

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

    +153.9

    1. 1
    if(!$_POST && !isset($_POST['gender'])) ...

    В одном проекте социальной сети, доставшемся от поляков, которым тот достался от индусов

    guest, 20 Марта 2009

    Комментарии (1)
  4. C++ / Говнокод #746

    +161.2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    bool HaW::Object::DestroyMutex()
    {
    	if (0 != pthread_mutex_destroy(&pMutex))
    		if (0 == pthread_mutex_unlock(&pMutex))
    			if(0 == pthread_mutex_destroy(&pMutex))
    				return true;
    			else
    				return false;
    		else
    			return false;
    }

    Метод для освобождения мьютекса, POSIX

    guest, 19 Марта 2009

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

    +146.4

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    for (int i = (orientation == Qt::Horizontal ? x : y); i < x+size; ++i)
        addPipe(orientation == Qt::Horizontal ? i : x, 
                orientation == Qt::Horizontal ? y : i, 
                orientation == Qt::Horizontal,
                orientation == Qt::Horizontal,
                orientation != Qt::Horizontal,
                orientation != Qt::Horizontal,
                randomRotation);

    guest, 18 Марта 2009

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

    +139

    1. 1
    2. 2
    3. 3
    >?php
    echo; print"hui"
    ?>

    пехепе

    guest, 18 Марта 2009

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

    +150

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    public const char ExpMonthSeparator = ':';
    
    
    protected void BindPager()
    {
       var colon = string.Format("{0}", ExpMonthSeparator);
       /* And some lines for refactor */
    }

    Фикся очередную багу наткнулся на такую прелесть

    guest, 18 Марта 2009

    Комментарии (1)
  8. PHP / Говнокод #722

    +147.8

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    $insideitem = ""; $list_id = ""; $title = ""; $price = 0; $price_amazon = 0;
    	$price_low = 0; $asin = ""; $type = ""; $status = ""; $qty = 0;
    	$isbn = ""; $asins = ""; $spage = 0; $list_id = ""; $exchange_id = ""; $title = ""; $price = 0;
    	$price_list = 0; $price_amazon = 0; $price_used = 0; $price_collect = 0; $price_low = 0;
    	$a_asin = ""; $image_url_s = ""; $image_url_l = ""; $type = ""; $status = "";
    	$qty = 0; $sellers_cnt = 0; $publisher = ""; $release_date = "";

    в цикле вот такой кусок кода..

    guest, 17 Марта 2009

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

    +162.3

    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
    <head><title>Статистика ретрекеров сети nextOne</title></head>
    <meta http-equiv="refresh" content="5;URL=index.php">
    <?php
    require_once("config.php");
    error_reporting(&#8764;E_ALL);
    //Торрент трекер on\off
    //Сервер 1
    function check_server1($serverip1, $port1)
    {
        if($fp1=fsockopen($serverip1, $port1, $ERROR_NO, $ERROR_STR,(float)2))
        {
            return true;
            fclose($fp1);
        } else {
            return false;
        }
    }
    //Сервер 2
    function check_server2($serverip2, $port2)
    {
        if($fp2=fsockopen($serverip2, $port2, $ERROR_NO, $ERROR_STR,(float)2))
        {
            return true;
            fclose($fp2);
        } else {
            return false;
        }
    }
    //Сервер 3
    function check_server3($serverip3, $port3)
    {
        if($fp3=fsockopen($serverip3, $port3, $ERROR_NO, $ERROR_STR,(float)2))
        {
            return true;
            fclose($fp3);
        } else {
            return false;
        }
    }
    //Сервер 4
    function check_server4($serverip4, $port4)
    {
        if($fp4=fsockopen($serverip4, $port4, $ERROR_NO, $ERROR_STR,(float)2))
        {
            return true;
            fclose($fp4);
        } else {
            return false;
        }
    }
    if(check_server1($serverip1, $port1)===true)
    {
        echo "<table border=0><tr><td>",$serverip1,":",$port1,"</td>","<td><b><font color=#2E8B57>online</font></b><br></td></tr>";
    } else {
        echo "<table border=0><tr><td>",$serverip1,":",$port1,"</td>","<td><b><font color=red>offline</font></b><br></td></tr>";
    }
    if(check_server2($serverip2, $port2)===true)
    {
        echo "<tr><td>",$severip2,":",$port2,"</td><td>","<b><font color=#2E8B57>online</font></b><br></td></tr>";
    } else {
    
        echo "<tr><td>",$serverip2,":",$port2,"</td><td>","<b><font color=red>offline</font></b><br></td></tr>";
    }
    if(check_server3($serverip3, $port3)===true)
    {
        echo "<tr><td>",$serverip3,":",$port3,"</td><td>","<b><font color=#2E8B57>online</font></b><br></td></tr>";
    } else {
        echo  "<tr><td>",$serverip3,":",$port3,"</td><td>","<b><font color=red>offline</font></b><br></td></tr>";
    }
    if(check_server4($serverip4, $port4)===true)
    {
        echo "<tr><td>",$serverip4,":",$port4,"</td><td>","<b><font color=#2E8B57>online</font></b></td></tr></table>";
    } else {
        echo "<tr><td>",$serverip4,":",$port4,"</td><td>","<b><font color=red>offline</font></b><br></td></tr></table>>";
    }a
    ?>

    Цитата: "Я просо незнаю о работе с операторами array, а известный мне define тут не подходит "

    guest, 13 Марта 2009

    Комментарии (1)
  10. Perl / Говнокод #704

    −305.1

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    my ($_bonus1_l, $_bonus1_y, $_bonus2_l, $_bonus2_y) = ($l1*10 > rand(100) ? 1 : 0, $y1*10 > rand(100) ? 1 : 0, $l2*10 > rand(100) ? 1 : 0, $y2*10 > rand(100) ? 1 : 0);
          ($_bonus1_l, $_bonus2_l) = (0, 0) if $_bonus1_l == 1 and $_bonus2_l == 1;
          ($_bonus1_y, $_bonus2_y) = (0, 0) if $_bonus1_y == 1 and $_bonus2_y == 1;
    if($turn > 12){
          my ($_a1_def, $_b1_def, $_c1_def) = mass($pl1_mov, $User1, "def");
          my ($_a1_att, $_b1_att, $_c1_att) = mass($pl1_att, $User1, "att");
          my ($_a2_def, $_b2_def, $_c2_def) = mass($pl2_mov, $User2, "def");
          my ($_a2_att, $_b2_att, $_c2_att) = mass($pl2_att, $User2, "att");
    
    $N1 += $_a1_att if $_a2_def < 1000000;
    $N1 += $_b1_att if $_b2_def < 1000000;
    $N1 += $_c1_att if $_c2_def < 1000000;
    $N2 += $_a2_att if $_a1_def < 1000000;
    $N2 += $_b2_att if $_b1_def < 1000000;
    $N2 += $_c2_att if $_c1_def < 1000000;
    
          if($_bonus1_l){
           	 my $l = int(rand(3));
    	 ## сБНПНР
             if($l == 0){
             	my $r = 0;
    	 	($_a2_att, $r) = (0, 1) if $_a2_att > 0 and $_a1_def < 1000000;
          	 	($_b2_att, $r) = (0, 1) if $_b2_att > 0 and $_a1_def < 1000000 and $r == 0;
    		($_c2_att, $r) = (0, 1) if $_c2_att > 0 and $_a1_def < 1000000 and $r == 0;
                    $U1 = $r;
             } elsif($l == 1){
                    my $r = 0;
                    ($_a1_att, $r, $K2) = (int($_a1_att * 1.5), 1, int($_a1_att/2)) if $_a1_att > 0  and $_a2_def < 1000000;
                    ($_b1_att, $r, $K2) = (int($_b1_att * 1.5), 1, int($_b1_att/2)) if $_b1_att > 0  and $_b2_def < 1000000 and $r == 0;
                    ($_c1_att, $r, $K2) = (int($_c1_att * 1.5), 1, int($_c1_att/2)) if $_c1_att > 0  and $_c2_def < 1000000 and $r == 0;
             } elsif($l == 2){
                    my ($r, $ov, $v) = (0, 0, int(rand(3)));
                    ($_a1_att, $r, $ov) = (0, 1, (int($_a2_att/2))) if $_a2_att > 0 and $_a1_def > 1000000;
                    ($_b1_att, $r, $ov) = (0, 1, (int($_b2_att/2))) if $_b2_att > 0 and $_b1_def > 1000000 and $r == 0;
                    ($_c1_att, $r, $ov) = (0, 1, (int($_c2_att/2))) if $_c2_att > 0 and $_c1_def > 1000000 and $r == 0;
                    $_a1_att += $ov if $v == 0;
                    $_b1_att += $ov if $v == 1;
                    $_c1_att += $ov if $v == 2;
                    $O1 = $ov;
             }
          }
          if($_bonus2_l){
           	 my $l = int(rand(100));
             if($l == 0){
             	my $r = 0;
    	 	($_a1_att, $r) = (0, 1) if $_a1_att > 0 and $_a2_def < 1000000;
          	 	($_b1_att, $r) = (0, 1) if $_b1_att > 0 and $_a2_def < 1000000 and $r == 0;
    		($_c1_att, $r) = (0, 1) if $_c1_att > 0 and $_a2_def < 1000000 and $r == 0;
                     $U2 = $r;
             } elsif($l == 1){
                    my $r = 0;
                    ($_a2_att, $r, $K1) = (int($_a2_att * 1.5), 1, int($_a2_att/2)) if $_a2_att > 0  and $_a1_def < 1000000;
                    ($_b2_att, $r, $K1) = (int($_b2_att * 1.5), 1, int($_b2_att/2)) if $_b2_att > 0  and $_b1_def < 1000000 and $r == 0;
                    ($_c2_att, $r, $K1) = (int($_c2_att * 1.5), 1, int($_c2_att/2)) if $_c2_att > 0  and $_c1_def < 1000000 and $r == 0;
             } elsif($l == 2){
             	my ($r, $ov, $v) = (0, 0, int(rand(3)));
                    ($_a2_att, $r, $ov) = (0, 1, (int($_a1_att/2))) if $_a1_att > 0 and $_a2_def > 1000000;
                    ($_b2_att, $r, $ov) = (0, 1, (int($_b1_att/2))) if $_b1_att > 0 and $_b2_def > 1000000 and $r == 0;
                    ($_c2_att, $r, $ov) = (0, 1, (int($_c1_att/2))) if $_c1_att > 0 and $_c2_def > 1000000 and $r == 0;
                    $_a2_att += $ov if $v == 0;
                    $_b2_att += $ov if $v == 1;
                    $_c2_att += $ov if $v == 2;
                    $O2 = $ov;
             }
          }
          if($_bonus1_y){
              my $l = int(rand(2));
             if($l == 0){
                my ($r, $rik, $V1) = (0, 0, int(rand(3)) + 1);
                ($r, $rik) = (1, (int($_a1_att/2))) if $_a1_att > 0 and $_a2_def < 1000000 and $V1 == 1;
                ($r, $rik) = (1, (int($_b1_att/2))) if $_b1_att > 0 and $_b2_def < 1000000 and $r == 0 and $V1 == 2;
                ($r, $rik) = (1, (int($_c1_att/2))) if $_c1_att > 0 and $_c2_def < 1000000 and $r == 0 and $V1 == 3;
                $R2 = $rik;
                $db->query("UPDATE duel set pl1_rik = CONCAT(pl1_rik, $V1) where sid = \"$dsid\"") if $R2 > 0;
    
             } elsif($l == 1){
                my $r = 0;
                ($_a2_def, $r) = ($_a2_def - 1000000, 1) if $_a1_att > 0 and $_a2_def > 1000000;
                ($_b2_def, $r) = ($_b2_def - 1000000, 2) if $_b1_att > 0 and $_b2_def > 1000000 and $r == 0;
                ($_c2_def, $r) = ($_c2_def - 1000000, 3) if $_c1_att > 0 and $_c2_def > 1000000 and $r == 0;
                $T2 = $r;
             }
          }
          if($_bonus2_y){
              my $l = int(rand(2));
             if($l == 0){
                my ($r, $rik, $V2) = (0, 0, int(rand(3)) + 1);
                ($r, $rik) = (1, (int($_a2_att/2))) if $_a2_att > 0 and $_a1_def < 1000000 and $V2 == 1;
                ($r, $rik) = (1, (int($_b2_att/2))) if $_b2_att > 0 and $_b1_def < 1000000 and $r == 0 and $V2 == 2;
                ($r, $rik) = (1, (int($_c2_att/2))) if $_c2_att > 0 and $_c1_def < 1000000 and $r == 0 and $V2 == 3;
    
                #$_a2_att += $rik if $V2 == 1;
                #$_b2_att += $rik if $V2 == 2;
                #$_c2_att += $rik if $V2 == 3;
                $R1 = $rik;
                $db->query("UPDATE duel set pl2_rik = CONCAT(pl2_rik, $V2) where sid = \"$dsid\"") if $R1 > 0;
             } elsif($l == 1){
                my $r = 0;
                ($_a1_def, $r) = ($_a1_def - 1000000, 1) if $_a2_att > 0 and $_a1_def > 1000000;
                ($_b1_def, $r) = ($_b1_def - 1000000, 2) if $_b2_att > 0 and $_b1_def > 1000000 and $r == 0;

    Из браузерной игрушки на mod_perl/mysql. Код наглядно демонстрирует, что говнокод зависит не от языка, а от программиста.

    guest, 13 Марта 2009

    Комментарии (1)
  11. Perl / Говнокод #702

    −307.7

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    sub get_ppl{
    	my $self = shift;
            my ($U, $print_done, $team) = @_;
    
             return "<ppl team_id='$team' battle_stats='$U->{_CHAR}->{win},$U->{_CHAR}->{loose},$U->{_CHAR}->{nobody}' medals='".$U->get_medal_string_for_user($U)."' $clan team_id='0' av_id='$U->{_CHAR}->{av_id}' fn='$U->{_CHAR}->{avatara}' u='$U->{_CHAR}->{u}' hp_u='$U->{_CHAR}->{hp_u}' stat0_u='$U->{_CHAR}->{stat0_u}' stat0='$U->{_CHAR}->{f}' stat1='$U->{_CHAR}->{m}' stat2='$U->{_CHAR}->{y}'  stat3='$U->{_CHAR}->{l}' hpmax='$U->{_CHAR}->{maxhp}' hp='$U->{_CHAR}->{hp}' aname='$U->{_USER_NAME}' lvl='$U->{_CHAR}->{lvl}' cname='$U->{_CHAR}->{name}' id='$U->{_ID}' carma='$U->{_CHAR}->{carma}' sex='$U->{_CHAR}->{sex}' slot0='$Item[0]' slot8='$Item[8]' slot7='$Item[7]' slot6='$Item[6]' slot1='$Item[1]' weight='$U->{_CHAR}->{weight}' slot5='$Item[5]' slot4='$Item[4]' slot3='$Item[3]' slot2='$Item[2]' city_id='$U->{_CHAR}->{city_id}'/>" if !$print_done;
             return "<ppl done='true' battle_stats='$U->{_CHAR}->{win},$U->{_CHAR}->{loose},$U->{_CHAR}->{nobody}' medals='".$U->get_medal_string_for_user($U)."' $clan team_id='0' av_id='$U->{_CHAR}->{av_id}' fn='$U->{_CHAR}->{avatara}' u='$U->{_CHAR}->{u}' hp_u='$U->{_CHAR}->{hp_u}' stat0_u='$U->{_CHAR}->{stat0_u}' stat0='$U->{_CHAR}->{f}' stat1='$U->{_CHAR}->{m}' stat2='$U->{_CHAR}->{y}'  stat3='$U->{_CHAR}->{l}' hpmax='$U->{_CHAR}->{maxhp}' hp='$U->{_CHAR}->{hp}' aname='$U->{_USER_NAME}' lvl='$U->{_CHAR}->{lvl}' cname='$U->{_CHAR}->{name}' id='$U->{_ID}' carma='$U->{_CHAR}->{carma}' sex='$U->{_CHAR}->{sex}' slot0='$Item[0]' slot8='$Item[8]' slot7='$Item[7]' slot6='$Item[6]' slot1='$Item[1]' weight='$U->{_CHAR}->{weight}' slot5='$Item[5]' slot4='$Item[4]' slot3='$Item[3]' slot2='$Item[2]' city_id='$U->{_CHAR}->{city_id}'/>" if $print_done;
    }

    Забавная проверка

    guest, 12 Марта 2009

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