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

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

    +59.6

    1. 1
    *reinterpret_cast<int *>(&showFlags) = behavior.value("showFlags", 0xfffffff);

    Немножко эзотерики, нашел в нашем проекте, писалось видимо в 3 часа ночи.

    Sauron, 18 Января 2010

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

    +156.1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    class BaseDateTimeField extends SmartField{
    var $years = array("1999"=>"1999","2000"=>"2000","2001"=>"2001","2002"=>"2002","2003"=>"2003","2004"=>"2004","2005"=>"2005","2006"=>"2006","2007"=>"2007","2008"=>"2008","2009"=>"2009","2010"=>"2010");
    var $months = array('01'=>'Jan','02'=>'Feb', '03'=>'Mar', '04'=>'Apr', '05'=>'May', '06'=>'Jun', '07'=>'Jul', '08'=>'Aug','09'=>'Sep', '10'=>'Oct', '11'=>'Nov', '12'=>'Dec');
    var $days = array('01'=>'01','02'=>'02','03'=>'03','04'=>'04','05'=>'05','06'=>'06','07'=>'07','08'=>'08','09'=>'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');
    var $hours = array('00'=>'00','01'=>'01','02'=>'02','03'=>'03','04'=>'04','05'=>'05','06'=>'06','07'=>'07','08'=>'08','09'=>'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');
    var $minutes = array('00'=>'00','01'=>'01','02'=>'02','03'=>'03','04'=>'04','05'=>'05','06'=>'06','07'=>'07','08'=>'08','09'=>'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');
    var $secundes = array('00'=>'00','01'=>'01','02'=>'02','03'=>'03','04'=>'04','05'=>'05','06'=>'06','07'=>'07','08'=>'08','09'=>'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');
    
    }

    Самописная CMS для веб-сайта

    nikl, 18 Января 2010

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

    +159.6

    1. 1
    document.getElementById('myID').disabled = document.getElementById('myCheckbox').checked == false ? true : false;

    Это замечательно, тащем-та! =) Досталось в наследство от команды аутсорсеров. =)

    Red Son, 15 Января 2010

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

    +143.5

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    if (data.success) {
         document.location = "/contests/" + $('#contest_id').val() + '/' + $('#composition_type').val() + '/page/1';
    }else {
         document.location = "/contests/" + $('#contest_id').val() + '/' + $('#composition_type').val() + '/page/1';
    }

    Stinkie, 15 Января 2010

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

    +68.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
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    public Vector<SystemUser> listAllSystemUsers()
            {
    
                Vector <SystemUser> v = new Vector<SystemUser>();
    
                Query q = manager.createNativeQuery("SELECT * FROM SystemUser;");
                List list  = (List)q.getResultList();
                for (int i=0; i<list.size(); i++)
                {
                try {
                    Vector a = (Vector) list.iterator().next();
                    SystemUser SU = new SystemUser();
                    System.out.print("99*1 > "+SU.getClass().getMethods()[1].getName());
                    SU.setId(new Integer (a.get(0).toString()));
                    SU.setLogin(
                                new String (
                                    new BASE64Decoder().decodeBuffer(a.get(1).toString())
                                    ));
                    System.out.print("506*1*1+0 > " + SU);
                } catch (SecurityException ex) {
                    Logger.getLogger(UserManagement.class.getName()).log(Level.SEVERE, null, ex);
                }catch (IOException e){
                    
                }
                }
                return v;
            }

    Однако O_o

    AlDjabad, 12 Января 2010

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

    +156.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
    <?php
    session_start();
    $lgn=$_SESSION['lgn'];
    $pswd=$_SESSION['pswd'];
    //  print_r($_GET);
    include_once('spyLib.php');
    $dbConn=connectToSpy();
    mysql_query("SET NAMES cp1251");
    $option=$_REQUEST['option'];
      
    $ID=autentID($lgn, $pswd);
    //$ID='45';
    if ($ID=='8') {
    
      if ($option=='editTable'){
      include_once("bd/editTable.php");
      }elseif($option=="addRecord"){
      include_once( 'bd/addRecord.php' );
      }elseif($option=="processAdd"){
      include_once( 'bd/processAdd.php' );
      }elseif($option=="deleteRecord"){
      include_once( 'bd/deleteRecord.php' );
      }elseif($option=="editRecord"){
      include_once( 'bd/editRecord.php' );
      }elseif($option=="updateRecord"){
      include_once( 'bd/updateRecord.php' );  
      }else{
      
      print <<<HERE
    <link href="./style.css" rel="stylesheet" type="text/css">
      <!-----------главная страница------------------------------------->
    <img src="./img/fonpageleft.png" style="position: absolute; top:50px; left: 50px;" width="670" height="370">
    <div style="position: absolute; top:70px; left: 100px;">
    
    <form action="index.php" method="post">
      <input name="ok" type="image" src="img/admin.gif" class="bulleon" alt="Перейти на сайт">
    </form>
    <table border="0" cellpadding="0" cellspacing="0">
      <tr>
      <td valign="top" width="458">
      <div class="text_10">Страница находится в разработке.</div>
      <form action="admin.php">
      <input name="option" type="hidden" value="editTable">
      <input name="page" type="hidden" value="admin">
      <input name="back" type="hidden" value="false">
      <table cellspacing="1" cellpadding="3" width='100%'>
      <tr  class="title">
      <td>
      </td>
      <td class='title2'>
      Выберите таблицу для редактирования
      </td>
      <td>
      </td>
      </tr>
      <tr class='table_top'>
      <td width='30' nowrap="nowrap">
      </td>
      <td  align="left">
      <select name="tableName" size=5>
      <option value="kompleks">комплексы</option>
      <option value="glav">главная страница</option>
      <option value="bulletin">новости</option>
      <option value="forleader">для руководителей</option>
      <option value="lunchoffice">обеды в офис</option>
      <option value="partner">партнеры</option>
      <option value="contact">контакты</option>
      <option value="review">отзывы</option>
      </select>
      </td>
      <td width='30' nowrap="nowrap">
      </td>
      </tr>
      <tr>
      <td colspan='3' align='left'>
      <input name="option2" type="image" value="1" src="./img/ok4.gif" class="bulleon">
      </td>
      </tr>
      </table>
      </form>
      </td>
        </tr>
      </table>
    </div>
    <!---!--------главная страница------------------------------------->
    HERE;
      }//if
    
    }else{
      print "<p class=\"mes_small_error\">Попробуйте ввести пороль и логин еще раз</p>";
    }
    ?>

    что тут комментировать - аффтар даже русский с трудом осилил: "Попробуйте ввести пороль"(sic!)

    xXx_totalwar, 09 Января 2010

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

    +162.3

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    $comments = (isset($_POST['lici-'.$login->id.'-comments']))?"yes":"no";
    
    if($comments === "yes")
    {
    $xml .= "<nocomment>1</nocomment>\r\n";
    }

    Код из плагина кросспостера для wordpress.
    Автор, видимо, не знает про булев тип. Все бы было хорошо, если бы плагин не закрывал комментарии, когда их нужно было открывать.

    gunya, 31 Декабря 2009

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

    +63.4

    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
    /* This construction seems to be more optimiser friendly.
           (without it gcc does the isDIGIT test and the *s - '0' separately)
           With it gcc on arm is managing 6 instructions (6 cycles) per digit.
           In theory the optimiser could deduce how far to unroll the loop
           before checking for overflow.  */
        if (++s < send) {
          int digit = *s - '0';
          if (digit >= 0 && digit <= 9) {
            value = value * 10 + digit;
            if (++s < send) {
              digit = *s - '0';
              if (digit >= 0 && digit <= 9) {
                value = value * 10 + digit;
                if (++s < send) {
                  digit = *s - '0';
                  if (digit >= 0 && digit <= 9) {
                    value = value * 10 + digit;
    		        if (++s < send) {
                      digit = *s - '0';
                      if (digit >= 0 && digit <= 9) {
                        value = value * 10 + digit;
                        if (++s < send) {
                          digit = *s - '0';
                          if (digit >= 0 && digit <= 9) {
                            value = value * 10 + digit;
                            if (++s < send) {
                              digit = *s - '0';
                              if (digit >= 0 && digit <= 9) {
                                value = value * 10 + digit;
                                if (++s < send) {
                                  digit = *s - '0';
                                  if (digit >= 0 && digit <= 9) {
                                    value = value * 10 + digit;
                                    if (++s < send) {
                                      digit = *s - '0';
                                      if (digit >= 0 && digit <= 9) {
                                        value = value * 10 + digit;
                                        if (++s < send) {
                                          /* Now got 9 digits, so need to check
                                             each time for overflow.  */
                                          digit = *s - '0';
                                          while (digit >= 0 && digit <= 9
                                                 && (value < max_div_10
                                                     || (value == max_div_10
                                                         && digit <= max_mod_10))) {
                                            value = value * 10 + digit;
                                            if (++s < send)
                                              digit = *s - '0';
                                            else
                                              break;
                                          }
                                          if (digit >= 0 && digit <= 9
                                              && (s < send)) {
                                            /* value overflowed.
                                               skip the remaining digits, don't
                                               worry about setting *valuep.  */
                                            do {
                                              s++;
                                            } while (s < send && isDIGIT(*s));
                                            numtype |=
                                              IS_NUMBER_GREATER_THAN_UV_MAX;
                                            goto skip_value;
                                          }
                                        }
                                      }
    				 }
                                  }
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
    	 }
          }
        }

    Проверка числа в Perl-модуле. Судя по всему стояла задача оптимизировать под что-то.

    Thomas_55, 30 Декабря 2009

    Комментарии (4)
  10. Pascal / Говнокод #2353

    +92

    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
    {$R-}
    fal:=true;
    ty:= length(mas1);
    while(fal=true)  do
      for j:=0 to kp-1 do
      begin
        for i:=i+k+j to length(mas2)-1 do
        begin
          while mas2[i+k]= ty do
          begin
            s:=s+c[i,j];
            inc(k);
          end;
        end;
        nl:=mas1[ty-1];
        if nl=0 then
          mas_Mj[ty]:=0
        else
          mas_Mj[ty-1][j]:=s/nl;
        s:=0;
      end;

    TAX, 30 Декабря 2009

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

    +168.1

    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
    function check($pass) 
    { if (strpos($pass,'0') || strpos($pass,'1') 
        || strpos($pass,'2') || strpos($pass,'3') 
        || strpos($pass,'4') || strpos($pass,'5') 
        || strpos($pass,'6') || strpos($pass,'7') 
        || strpos($pass,'8') || strpos($pass,'9')) 
        { 
         if (strpos($pass,'a') || strpos($pass,'b') || strpos($pass,'c') 
             || strpos($pass,'d') || strpos($pass,'e') || strpos($pass,'f') 
             || strpos($pass,'g') || strpos($pass,'h') || strpos($pass,'i') 
             || strpos($pass,'j') || strpos($pass,'k') || strpos($pass,'l') 
             || strpos($pass,'m') || strpos($pass,'n') || strpos($pass,'o') 
             || strpos($pass,'p') || strpos($pass,'q') || strpos($pass,'r') 
             || strpos($pass,'s') || strpos($pass,'t') || strpos($pass,'u') 
             || strpos($pass,'v') || strpos($pass,'w') || strpos($pass,'x') 
             || strpos($pass,'y') || strpos($pass,'z')) 
             { 
              if (strpos($pass,'A') || strpos($pass,'B') || strpos($pass,'C') 
                  || strpos($pass,'D') || strpos($pass,'E') || strpos($pass,'F') 
                  || strpos($pass,'G') || strpos($pass,'H') || strpos($pass,'I') 
                  || strpos($pass,'J') || strpos($pass,'K') || strpos($pass,'K') 
                  || strpos($pass,'M') || strpos($pass,'N') || strpos($pass,'O') 
                  || strpos($pass,'P') || strpos($pass,'Q') || strpos($pass,'R') 
                  || strpos($pass,'S') || strpos($pass,'T') || strpos($pass,'U') 
                  || strpos($pass,'V') || strpos($pass,'W') || strpos($pass,'X') 
                  || strpos($pass,'Y') || strpos($pass,'Z')) 
                  {                if (ctype_lower(substr($pass,0,1)) || ctype_upper(substr($pass,0,1)) || is_numeric(substr($pass,0,1))) 
                       {                        if (ctype_lower(substr($pass,0,1))) 
                               {                             if (!ctype_lower(substr($pass,-1))) 
                                    {                                  return $pass;                                 }                            } 
                           if (ctype_upper(substr($pass,0,1))) 
                               { 
                                if (!ctype_upper(substr($pass,-1))) 
                                    { 
                                     return $pass; 
                                    } 
                               } 
                           if (is_numeric(substr($pass,0,1))) 
                               { 
                                if (!is_numeric(substr($pass,-1))) 
                                    { 
                                     return $pass; 
                                    } 
                               }                    } 
                  } 
             } 
        } }

    без коментариев. (из одного вап чата)

    [email protected], 28 Декабря 2009

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