1. C++ / Говнокод #4546

    +168

    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
    /*++
      прямое ли?
    --*/
    bool ModelCurve3D::IsStraight() const {
      return m_mathCurve ? m_mathCurve->IsStraight() : false;
    }
    
    /*++
      замкнутость
    --*/
    bool ModelCurve3D::IsClosed()  const
    {
      return m_mathCurve ? m_mathCurve->IsStraight() : false;
    }

    Замкнутый... ну знаешь, это типа как прямолинейный. И такое лежит годами. А как поправишь, еще может и регрессия случится. Ну как так можно?

    guest666, 06 Ноября 2010

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

    +193

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    /**
     * Посылает команду удалённой машине
     * перейти по указанному адресу.
     * Рекомендуется использовать вместо Header('Location: ...');
     */
    function GO( $address)
    {
         Header('Location: '.$address);
    }

    Мартин, 06 Ноября 2010

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

    +145

    1. 1
    2. 2
    3. 3
    4. 4
    foreach($new as $key => $value)
    {
    	$config[$key] = $value;
    }

    stasoft, 06 Ноября 2010

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

    +162

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    private function trailing_slash_check($str)
         {
              if ((strrpos($str, '/') + 1) != strlen($str))
              {
                   $str = $str.'/';
              }
              
              return $str;
         }

    stasoft, 06 Ноября 2010

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

    +164

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    BYTE* ptr = PreventCommand(mode,3);
    WORD chksum=this->calc_chksum((BYTE*)(ptr+2));
    ptr[4] = (char)(chksum/256 & 0xff);
    ptr[5] = (char)(chksum%256 & 0xff);
    _interface_array[0]->write(ptr,6, NULL);
    delete [] ptr;

    Формирование пакета
    На третью и четвертую строки смотреть особенно больно.

    seregakabancheg, 05 Ноября 2010

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

    +75

    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
    //...
            Hashtable somehash = new Hashtable();
    //...
    
            public String keyByValue (String value) {
                String s;
    
                    while (somehash.elements().hasMoreElements()) {
                        s = (String) somehash.elements().nextElement(); //!!!
    
                        if (s.equals(value)) { //!!!
                         return s;
                        }
                    }
                return null;
            }

    Cr0s, 05 Ноября 2010

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

    +150

    1. 1
    2. 2
    3. 3
    $stat_connect = @mysql_connect("stats.amxbans.de","amxbstats","");
    *skipped…*
    @mysql_close($stat_connect) or die(mysql_error());

    desagr, 05 Ноября 2010

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

    −158

    1. 1
    2. 2
    ParticleArray.push(new ParticleExplosion());
    var par:ParticleExplosion = ParticleArray[ParticleArray.length - 1];

    Запихнуть в массив, а потом сразу же выдернуть, чтобы с этим поработать ))

    NeonSelf, 05 Ноября 2010

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

    +165

    1. 1
    alert(( (/([^(A-z)&&(А-я)])/ || prompt.length<1 ).test(prompt('Введите Ваше имя',''))) ? 'Ошибка' : 'Принято')

    Не совсем говнокод, просто весёлый бред. Найдено здесь http://tinyurl.com/22w4b8q

    eval, 05 Ноября 2010

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

    +151

    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
    void TPEForm::LoadFromFile(AnsiString _FileName)
    {
        FileName = _FileName;
        Caption = FileName + " - " + DOS_HEADER_STRING;
        iPEFileHandle = FileOpen(FileName,fmOpenRead);
        FileRead(iPEFileHandle,&dos_header,sizeof(IMAGE_DOS_HEADER));
        TreeView->Items->AddChild(NULL,DOS_HEADER_STRING);
        dos_header_frame = new TDOSHeader(this);
        dos_header_frame->Parent = Panel;
        dos_header_frame->e_magic->Text = "0x"+IntToHex(dos_header.e_magic,4);
        dos_header_frame->e_cblp->Text = "0x"+IntToHex(dos_header.e_cblp,4);
        dos_header_frame->e_cp->Text = "0x"+IntToHex(dos_header.e_cp,4);
        dos_header_frame->e_crlc->Text = "0x"+IntToHex(dos_header.e_crlc,4);
        dos_header_frame->e_cparhdr->Text = "0x"+IntToHex(dos_header.e_cparhdr,4);
    ...
        dos_header_frame->e_ovno->Text = "0x"+IntToHex(dos_header.e_ovno,4);
        dos_header_frame->e_oemid->Text = "0x"+IntToHex(dos_header.e_oemid,4);
        dos_header_frame->e_oeminfo->Text = "0x"+IntToHex(dos_header.e_oeminfo,4);
        dos_header_frame->e_lfanew->Text = "0x"+IntToHex((int)dos_header.e_lfanew,4);
    
    ...
    
        TreeView->Items->AddChild(nt_header_node,FILE_HEADER_STRING);
        file_header_frame = new TFileHeader(this);
        file_header_frame->Parent = Panel;
        file_header_frame->Machine->Text = "0x"+IntToHex((int)nt_header.FileHeader.Machine,4);
        file_header_frame->NumberOfSections->Text = "0x"+IntToHex((int)nt_header.FileHeader.NumberOfSections,4);
        file_header_frame->TimeDateStamp->Text = "0x"+IntToHex((int)nt_header.FileHeader.TimeDateStamp,8);
        file_header_frame->PointerToSymbolTable->Text = "0x"+IntToHex((int)nt_header.FileHeader.PointerToSymbolTable,8);
        file_header_frame->NumberOfSymbols->Text = "0x"+IntToHex((int)nt_header.FileHeader.NumberOfSymbols,8);
        file_header_frame->SizeOfOptionalHeader->Text = "0x"+IntToHex((int)nt_header.FileHeader.SizeOfOptionalHeader,4);
        file_header_frame->Characteristics->Text = "0x"+IntToHex((int)nt_header.FileHeader.Characteristics,4);
    
        TTreeNode *optional_header_node = TreeView->Items->AddChild(nt_header_node,OPTIONAL_HEADER_STRING);
        optional_header_frame = new TOptionalHeader(this);
        optional_header_frame->Parent = Panel;
    
        TreeView->Items->AddChild(optional_header_node,STANDARD_FIELDS_STRING);
        standard_fields_frame = new TStandardFieldsFrame(this);
        standard_fields_frame->Parent = Panel;
        TTreeNode *additional_fields_node = TreeView->Items->AddChild(optional_header_node,ADDITIONAL_FIELDS_STRING);
        additional_fields_frame = new TAdditionalFieldsFrame(this);
        additional_fields_frame->Parent = Panel;
    
        standard_fields_frame->Magic->Text = "0x"+IntToHex((int)nt_header.OptionalHeader.Magic,4);
        standard_fields_frame->MajorLinkerVersion->Text = "0x"+IntToHex((int)nt_header.OptionalHeader.MajorLinkerVersion,2);
    ...
        additional_fields_frame->ImageBase->Text = "0x"+IntToHex((int)nt_header.OptionalHeader.ImageBase,8);
        additional_fields_frame->SectionAlignment->Text = "0x"+IntToHex((int)nt_header.OptionalHeader.SectionAlignment,8);
        additional_fields_frame->FileAlignment->Text = "0x"+IntToHex((int)nt_header.OptionalHeader.FileAlignment,8);
    
    ...

    писал на третьем курсе загрузку заголовка PE-файлов в GUI

    stas, 05 Ноября 2010

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