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

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

    +139

    1. 1
    <span style="display: block">

    div? не, не слышал

    dead_star, 31 Августа 2012

    Комментарии (11)
  3. Си / Говнокод #11685

    +103

    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
    93. 93
    94. 94
    void str2ip_s_Before( unsigned char* ptrIP, unsigned short* ptrPort, const wchar_t* src, size_t count )
    {
        int i;
        if( !ptrIP )
            return;
    
        while( src && count && !iswdigit( *src ) )//skip separators and spaces
            ++src, --count;
    
        for( i = 0; i < 4 && count; ++i )//IP address
        {
            ptrIP[ i ] = ( unsigned char )_wtoi( src );
    
            while( src && count && iswdigit( *src ) )//skip current number
                ++src, --count;
    
            while( src && count && !iswdigit( *src ) )//skip separators and spaces
                ++src, --count;
        }
    
        if( ptrPort && src && count )
            *ptrPort = ( unsigned short )_wtoi( src );
    }
    
    int str2ip_sAfter( unsigned char* ptrIP, unsigned short* ptrPort, const wchar_t* src, size_t count )
    {
        int i, iRadix;
        wchar_t* endptr;
    
        if( !ptrIP || !src || 0 == count )
            return 0;
    
        for( i = 0; i < 4; ++i )
            ptrIP[ i ] = 0;
        if( ptrPort )
            *ptrPort = 0;
    
        while( 0 != count && !iswdigit( *src ) ) //skip separators and spaces
            ++src, --count;
    
        for( i = 0; i < 4 && 0 != count; ++i ) //IP address
        {
            if( count > 1 && src[ 0 ] == L'0' )
            {
                if( src[ 1 ] != L'x' && src[ 1 ] != L'X' )
                    iRadix = 8;
                else
                    iRadix = 16;
            }
            else
                iRadix = 10;
    
            ptrIP[ i ] = ( unsigned char )wcstol( src, &endptr, iRadix );
            if( src == endptr )
                return 0;
            count -= endptr - src;
            src = endptr;
    
            while( 0 != count && iswspace( *src ) ) //skip spaces
                ++src, --count;
    
            if( i < 3 )
            {
                if( L'.' == *src ) //skip point
                    ++src, --count;
                else
                    return 0;
            }
    
            while( 0 != count && iswspace( *src ) ) //skip spaces
                ++src, --count;
        }
    
        if( i < 4 )
            return 0;
    
        if( ptrPort )
        {
            if( 0 == count || L':' != *src ) //skip point
                return 0;
            ++src, --count;
    
            while( 0 != count && iswspace( *src ) ) //skip spaces
                ++src, --count;
    
            *ptrPort = ( unsigned short )wcstol( src, &endptr, 10 );
            if( src == endptr )
                return 0;
            else
                return 1;
        }
        else
            return 1;
    }

    Пуресишник зарефакторил

    sokol, 31 Августа 2012

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

    −159

    1. 1
    Говно.Наложить(Это)

    Коллеги намедни выдали

    noosipip, 18 Августа 2012

    Комментарии (11)
  5. Java / Говнокод #11571

    +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
    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
    private void viewField(int id) {
            try {
                List<Fieldmaterials> materials = materialsSession.FieldmaterialsBy(id);
                int size = materials.size() - 1;
                int i = 0;
                JSONWriter json = new JSONStringer().object();
                json.key("namefield").array();
    
                while (i <= size) {
                    Fieldmaterials get = materials.get(i);
                    json.value(get.getNamefield());
                    i++;
                }
                json.endArray();
                json.key("typefield").array();
    
                i = 0;
                while (i <= size) {
                    Fieldmaterials get = materials.get(i);
                    json.value(get.getTypefield());
                    i++;
                }
    
                json.endArray();
                json.key("orderfield").array();
    
                i = 0;
                while (i <= size) {
                    Fieldmaterials get = materials.get(i);
                    json.value(get.getOrderfieldmaterials());
                    i++;
                }
                json.endArray().endObject();
    
            } catch (Exception e) {
                e.printStackTrace();
            }

    Не нашел более хорошего способа сериализовать в JSON. Нужно было оформить поля объектов в массивы, что-бы потом удобно разобрать в javascript

    Kerny, 11 Августа 2012

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

    +52

    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
    $hash = md5($eshopId."::".
                            $orderId."::".
                    	    $_REQUEST["serviceName"]."::".
                            $_REQUEST["eshopAccount"]."::".
                            $_REQUEST["recipientAmount"]."::".
                			$_REQUEST["recipientCurrency"]."::".
                			$_REQUEST["paymentStatus"]."::".
                			$_REQUEST["userName"]."::".
                            $_REQUEST["userEmail"]."::".
                			$_REQUEST["paymentData"]."::".
                			$secretKey);
                if (strtoupper($_REQUEST["hash"]) != strtoupper($hash)) {
                    die('Err: wrong hash.');
                }
    ......

    я конечно уважаю modx но ето через чур
    http://bezumkin.ru/modx/minishop/extra/intellectmoney.html

    Sulik78, 11 Августа 2012

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

    +154

    1. 1
    2. 2
    3. 3
    if(Math.round(Math.random()*10)==7){
              alert('Your name/lastname alredy used! Try other.');
    }

    Валидация форм, чё

    denis90, 08 Августа 2012

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

    +140

    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
    FileInfo file = new FileInfo(fileName);
    FileSecurity fSecurity = File.GetAccessControl(fileName);
    
    foreach (FileSystemAccessRule permissions in fSecurity.GetAccessRules(true, true, typeof(NTAccount)))
    {
         string login = permissions.IdentityReference.Translate(typeof(NTAccount)).Value.ToString();
         string permiss =  permissions.FileSystemRights.ToString();
    
         if ((login != "логин") && (login != "логин") && (login != "логин"))
         {
             fSecurity.SetAccessRuleProtection(true, false);
             fSecurity.RemoveAccessRule(new FileSystemAccessRule(login, permissions.FileSystemRights, AccessControlType.Allow));
         }
         fSecurity.AddAccessRule(new FileSystemAccessRule("логин", FileSystemRights.FullControl, AccessControlType.Allow));
         fSecurity.AddAccessRule(new FileSystemAccessRule("логин", FileSystemRights.FullControl, AccessControlType.Allow));
    
    }
    File.SetAccessControl(fileName, fSecurity);

    vertu, 03 Августа 2012

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

    +62

    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
    <?php
    
    define( 'SIGNATURE', 'eval(base64_decode("<закодированный код виря>"));' );
    
    function analyzeFolder( $path ) {
    	
    	foreach ( glob( $path . DIRECTORY_SEPARATOR . '*' ) as $file ) {
    		if ( is_dir( $file ) ) analyzeFolder( $file );
    		elseif ( is_file( $file ) ) delBody( $file );
    	}
    	
    }
    
    function delBody( $file ) {
    	if ( $file != $argv[0] && !is_dir( $file ) && is_file( $file ) ) {
    		$file_info = pathinfo( $file );
    		
    		if ( strtolower( $file_info['extension'] ) == 'php' ) {
    			$o = file_get_contents( $file );
    			$w = str_replace( SIGNATURE, '', $o );
    			file_put_contents($file, $w, LOCK_EX);
    			
    			if ( strcasecmp($o, $w) != 0 ) echo "file \"$file\" was modified\n";
    		}
    	}
    }
    
    if ( !empty( $argv[1] ) && ( $argv[1] == '--help' || $argv[1] == '-h' ) ) {
    	
    	print( "using: $ php antivirus [path]\n" );
    	
    } elseif ( !empty( $argv[1] ) && is_dir( $argv[1] ) ) {
    	
    	analyzeFolder( realpath( $argv[1] ) );
    	
    } else {
    	
    	analyzeFolder( dirname( __FILE__ ) );
    	 
    }

    Мой быдлядский антивирь, удаляющий тело вируса из скриптов.

    psycho-coder, 18 Июля 2012

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

    −11

    1. 1
    rampage=1<<12;

    Видимо кто-то из буйных писал.

    HaskellGovno, 02 Июля 2012

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

    +65

    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
    <?php
    
    $str = file_get_contents('source.txt');
    $out = '';
    
    $len = strlen($str);
    $word = '';
    
    $bad_words = array(
        'Аноним',
        'Птн',
        'Сен',
        'Ответ',
        'Пропущено',
        'ответов',
        'изображениями',
        'Нажмите',
        'jpg',
        'png',
        'gif',
        'Кб',
        'x',
    );
    
    $str=str_replace('Нажмите "ответ", чтобы увидеть тред целиком.','', $str);
    $str=str_replace('Показана уменьшенная копия, оригинал по клику.','', $str);
    $str=str_replace('Пропущено ','', $str);
    $str=str_replace(' ответов, из них ','', $str);
    $str=str_replace(' с изображениями.','', $str);
    $str=str_replace('Аноним','', $str);
    $str=str_replace('Ответы','', $str);
    $str=str_replace('Ответ','', $str);
    $str=str_replace('Птн','', $str);
    $str=str_replace('Сен','', $str);
    $str=str_replace('jpg','', $str);
    $str=str_replace('png','', $str);
    $str=str_replace('gif','', $str);
    $str=str_replace('Кб','', $str);
    $str=str_replace('x','', $str);
    
    
    
    for ($i = 0; $i < $len; $i++) {
        $c = $str[$i];
        if (($c >= 'a') && ($c <= 'z') ||
                ($c >= 'A') && ($c <= 'Z') ||
                ($c >= 'а') && ($c <= 'я') ||
                ($c >= 'А') && ($c <= 'Я')
        ) {
            $word.=$c;
        } else {
            if ($word != '') {
                $out.=strtolower($word) . "\r\n";
            }
            $word = '';
        }
    }
    file_put_contents('dictonary.txt', $out);
    ?>

    Из чьей-то пхп-вайпалки для известной имиджборды.
    Генерирует словарь слов из текста, взятого с помощью Ctrl+C с любой из страниц борды.

    7ion, 14 Июня 2012

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