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

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

    +22.3

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    if ($_POST['id']) {
      $id = $_POST['id'];
    } elseif ($_GET['id']) {
      $id = $_GET['id'];
    }
    if (isset($_POST['password'])) {
      $password = md5($_POST['password']);
    } elseif (isset($_GET['password'])) {
      $password = md5($_GET['password']);
    }

    guest, 03 Января 2009

    Комментарии (2)
  3. Pascal / Говнокод #319

    +30

    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
    for i := 0 to high(vParagsChanges) do
        begin
          if vParNumIn < vParagsChanges[i].ParNo1 then
          begin
            inc(vParNumOut, vParagsChanges[i].ParNo1 - vParNumIn);
            vParNumIn := vParagsChanges[i].ParNo1;
          end;
    
          if i < high(vParagsChanges) then
            if (vParagsChanges[i].ParNo1+vParagsChanges[i].Range=vParagsChanges[i+1].ParNo1) and
            ((vParagsChanges[i].Kind=ckDelete) and (vParagsChanges[i+1].Kind=ckAdd)) then
              {if vParagsChanges[i].Range = vParagsChanges[i+1].Range then} 
              begin
                vUnitedPars := min(vParagsChanges[i].Range, vParagsChanges[i+1].Range);
                if vParagsChanges[i+1].Range >= vUnitedPars then
                  vParagsChanges[i+1].Range := vParagsChanges[i+1].Range - vUnitedPars;
                if vParagsChanges[i].Range >= vUnitedPars then
                  vParagsChanges[i].Range := vParagsChanges[i].Range - vUnitedPars;
                for j := 0 to vUnitedPars-1 do 
                begin
                  FParsHL[vParNumIn+vInsertedCount1+j].Kind := pkReplaced;
                  vTagsInfoEx := GetTagsInfo(Editor1.Parag(vParNumIn+vInsertedCount1+j).Str); 
                  FParsHL[vParNumIn+vInsertedCount1+j].ViewGroups := GetViewGroupsByChangeItems(vTagsInfoEx.TagKinds);
                  vTagsInfoEx := GetTagsInfo(Editor2.Parag(vParNumIn+vInsertedCount1+j).Str);
                  FParsHL[vParNumIn+vInsertedCount1+j].ViewGroups := FParsHL[vParNumIn+vInsertedCount1+j].ViewGroups + GetViewGroupsByChangeItems(vTagsInfoEx.TagKinds);
                  if vParagsChanges[i].InCard then 
                    FParsHL[vParNumIn+vInsertedCount1+j].ViewGroups := FParsHL[vParNumIn+vInsertedCount1+j].ViewGroups + [vgCard]
                  else
                    FParsHL[vParNumIn+vInsertedCount1+j].ViewGroups := FParsHL[vParNumIn+vInsertedCount1+j].ViewGroups + [vgText];
                end;
                inc(vParNumIn, vUnitedPars);
                inc(vParNumOut, vUnitedPars);
              end;
    
          case vParagsChanges[i].Kind of
            ckAdd: begin
              for j := 0 to vParagsChanges[i].Range-1 do
              begin
                vTmpParag := TRTFParag.Create(nil, False, False, raLeft{raRight});
                FEditor1.InsPar(vParNumIn+vInsertedCount1+j, vTmpParag, false);
                FParsHL[vParNumIn+vInsertedCount1+j].Kind := pkAdded;
                vTagsInfoEx := GetTagsInfo(Editor2.Parag(vParNumOut+vInsertedCount2+j).Str); 
                if vParagsChanges[i].InCard then 
                  FParsHL[vParNumIn+vInsertedCount1+j].ViewGroups := GetViewGroupsByChangeItems(vTagsInfoEx.TagKinds) + [vgCard]
                else 
                  FParsHL[vParNumIn+vInsertedCount1+j].ViewGroups := GetViewGroupsByChangeItems(vTagsInfoEx.TagKinds) + [vgText];
              end;
              inc(vInsertedCount1, vParagsChanges[i].Range);
              inc(vParNumOut, vParagsChanges[i].Range);
            end;
            ckDelete: begin
              for j := 0 to vParagsChanges[i].Range-1 do
              begin
                vTmpParag := TRTFParag.Create(nil, False, False, raLeft);
                FEditor2.InsPar(vParNumOut+vInsertedCount2+j, vTmpParag, false);
                FParsHL[vParNumOut+vInsertedCount2+j].Kind := pkDeleted;
                vTagsInfoEx := GetTagsInfo(Editor1.Parag(vParNumIn+vInsertedCount1+j).Str); 
                if vParagsChanges[i].InCard then 
                  FParsHL[vParNumOut+vInsertedCount2+j].ViewGroups := GetViewGroupsByChangeItems(vTagsInfoEx.TagKinds) + [vgCard]
                else 
                  FParsHL[vParNumOut+vInsertedCount2+j].ViewGroups := GetViewGroupsByChangeItems(vTagsInfoEx.TagKinds) + [vgText];
              end;
              inc(vInsertedCount2, vParagsChanges[i].Range);
              inc(vParNumIn, vParagsChanges[i].Range);
            end;
            ckModify: begin 
              if (ciAlignment in vParagsChanges[i].ChangedItems) and (vParagsChanges[i].StrChanges = nil) then
                FParsHL[vParNumIn+vInsertedCount1].Kind := pkAlignment
              else
                FParsHL[vParNumIn+vInsertedCount1].Kind := pkModified;
    
              FParsHL[vParNumIn+vInsertedCount1].Changes := GetViewChanges(vParagsChanges[i].StrChanges);
              FParsHL[vParNumIn+vInsertedCount1].ViewGroups := GetViewGroupsByChangeItems(vParagsChanges[i].ChangedItems);
              if vParagsChanges[i].InCard then 
                if (ciText in vParagsChanges[i].ChangedItems) or (ciAlignment in vParagsChanges[i].ChangedItems) then 
                begin 
                  FParsHL[vParNumIn+vInsertedCount1].ViewGroups := FParsHL[vParNumIn+vInsertedCount1].ViewGroups + [vgCard];
                  FParsHL[vParNumIn+vInsertedCount1].ViewGroups := FParsHL[vParNumIn+vInsertedCount1].ViewGroups - [vgText, vgAlignment];
    
                  for j := 0 to high(FParsHL[vParNumIn+vInsertedCount1].Changes) do 
                    if FParsHL[vParNumIn+vInsertedCount1].Changes[j].ViewGroup = vgText then
                      FParsHL[vParNumIn+vInsertedCount1].Changes[j].ViewGroup := vgCard;
                end;
    
              inc(vParNumIn, 1);
              inc(vParNumOut, 1);
            end;
          end;
        end;

    Такой г****код возник не за 1 день. Голову пришлось поломать основательно :))
    Комментарии убраны, дабы не портить удовольствие от прочтения.

    guest, 31 Декабря 2008

    Комментарии (2)
  4. Си / Говнокод #312

    +18.3

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    if( strncmp("ERROR: Unable to service request",msg.data, strlen("Unable to service request")) == 0 )
        return 1;
     if( strncmp("ERROR: (201) Unable to service request",msg.data, strlen("(201) Unable to service request")) == 0 )
        return 1;
     if( strncmp("ОШИБКА: (201) Невозможно обработать запрос.",msg.data, strlen("(201) Невозможно обработать запрос.")) == 0 )
        return 1;
     if( strncmp("ERROR: (201) Невозможно обработать запрос",msg.data, strlen("(201) Невозможно обработать запрос.")) == 0 )
       return 1;

    guest, 30 Декабря 2008

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

    +51.9

    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
    set_include_path(  dirname(__FILE__) . DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'libs'
        . PATH_SEPARATOR . dirname(__FILE__) . DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.
        'libs'.DIRECTORY_SEPARATOR.'doctrine'.DIRECTORY_SEPARATOR.'lib'
        . PATH_SEPARATOR . dirname(__FILE__) . DIRECTORY_SEPARATOR.'..'.
        DIRECTORY_SEPARATOR.'libs'.DIRECTORY_SEPARATOR.'doctrine'.DIRECTORY_SEPARATOR
        . PATH_SEPARATOR . dirname(__FILE__) . DIRECTORY_SEPARATOR.'..'.
        DIRECTORY_SEPARATOR.'libs'.DIRECTORY_SEPARATOR.'doctrine'.DIRECTORY_SEPARATOR.
        'tests'.DIRECTORY_SEPARATOR.'DoctrineTest'
        . PATH_SEPARATOR . dirname(__FILE__) . DIRECTORY_SEPARATOR.'..'.
        DIRECTORY_SEPARATOR.'libs'.DIRECTORY_SEPARATOR.'doctrine'.DIRECTORY_SEPARATOR.
        'tests'
        . PATH_SEPARATOR . dirname(__FILE__) . DIRECTORY_SEPARATOR.'..'
        . PATH_SEPARATOR . dirname(__FILE__) . DIRECTORY_SEPARATOR.'Model'
        . PATH_SEPARATOR . dirname(__FILE__) . DIRECTORY_SEPARATOR.'Model'.DIRECTORY_SEPARATOR.'BaseClasses'
        . PATH_SEPARATOR . dirname(__FILE__) . DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'libs'.DIRECTORY_SEPARATOR.'smarty'
        . PATH_SEPARATOR . dirname(__FILE__) . DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR
        . PATH_SEPARATOR . dirname(__FILE__) . DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'libs'.DIRECTORY_SEPARATOR.'jsPacker'
        . PATH_SEPARATOR . dirname(__FILE__) . DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'libs'.DIRECTORY_SEPARATOR.'FirePHPLibrary'.DIRECTORY_SEPARATOR.'lib'
        . PATH_SEPARATOR . get_include_path());

    guest, 29 Декабря 2008

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

    +40

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    try {
    	$id = $faq->addQuestion($_POST);
    } catch (FaqException $e) {
    	die('Хуй знает что творится... Вбрасывания нет, екзепшн вылез...');
    }

    guest, 24 Декабря 2008

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

    +27

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    function getData ( $id )
    {
     if( intval( $id ) ) {
      ...
      return $result;
     }
     
     return false;
     echo "Сука блять хуй пиздец!!";
    }

    guest, 24 Декабря 2008

    Комментарии (2)
  8. ActionScript / Говнокод #236

    −567.3

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    do {
    
    	t_year++;
    
    	Length_periods[i]++;
    
    
    } while (t_year<=Periods_end);

    А вам слабо!?

    guest, 21 Декабря 2008

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

    +25

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    elseif( $manufacturer_id) {
    		$db->query( "SELECT manufacturer_id, mf_name FROM #__{vm}_manufacturer WHERE manufacturer_id='$manufacturer_id'");
    		$db->next_record();
    		$mainframe->setPageTitle( $db->f("mf_name") );
    		echo "Izdeliya ot";
    	}

    guest, 20 Декабря 2008

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

    −48

    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 static final String PROMPT = " >";
    private static final int BUFFER_SIZE = 255;
    private static final int NEW_LINE_CHAR = 13;
    private static final int CARRIAGE_RETURN_CHAR = 10;
    ...
    System.out.print( prompt + PROMPT );
    StringBuffer sb = new StringBuffer();
    byte[] buf = new byte[BUFFER_SIZE];
    int read = System.in.read( buf );
    if ( read != 0 && buf[0] != CARRIAGE_RETURN_CHAR && buf[0] != NEW_LINE_CHAR )
    {
        sb.append( new String( buf, 0, read ).trim() );
    }
    return sb.toString();

    Вам нужно вывести приглашение и прочитать введенную строку? Что может быть проще?

    guest, 20 Декабря 2008

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

    −40.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
    /* This is bad. Reaaly bad. It's a really, really bad hack. If you're an employee of 
     * Intertrode Communication, then I'm really, really sorry that you have to maintain
     * this. I was honestly planning on removing this tomorrow, but I've been known to 
     * forget things like this. It happens.
     *
     * So here's the thing. I can't seem to figure out why the AccountId variable isn't 
     * set. I've looked and looked, but I gotta leave now. Anyway, I've found that I can
     * just grab the AccountID from the debugging logs.  I suppose that to fix it, you'd
     * have to locate where it's clearing out the ID.
     *
     * Again, I'm sorry.
     */
    
    if ( (AccountId == NULL) || (AccountId == "") ||
         (ServerSesion["AccountId"] == NULL) || (ServerSesion["AccountId"] == "") )
    {
      //open session logs
      FileHandle file = f_open(LOG_PATH + "\sessionlog-" + LOG_FILE_DATE + ".log", 1);
      while (file != NULL)
      {
        
        TString line = f_readline(file);
    
        //look for IP and changereg
        if ( (sfind(line,REMOTE_ADDR) != -1) && (sfind(line,"changereg") != -1) )
        {
          //0000-00-00 00:00 /accountmaint/changereg/?AccountId=123456 255.255.255.255 ...
          //                                                    *
          AccountId = substr(line, 52, 6);
        }
    
        if (f_EOF(file)) { f_close(file); file = NULL; }
      }
    
    }

    У чувака где то перетирается AccountId, так он берет данные из логов IIS'а :) Главное, что он сожалеет об этом.
    Отсюда: http://thedailywtf.com/Articles/The_Apologetic_Coder.aspx

    guest, 18 Декабря 2008

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