1. JavaScript / Говнокод #9626

    +200

    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
    for (k = 0; k < xl; k += 16) {
            AA = a;
            BB = b;
            CC = c;
            DD = d;
            a = _FF(a, b, c, d, x[k + 0], S11, 0xD76AA478);
            d = _FF(d, a, b, c, x[k + 1], S12, 0xE8C7B756);
            c = _FF(c, d, a, b, x[k + 2], S13, 0x242070DB);
            b = _FF(b, c, d, a, x[k + 3], S14, 0xC1BDCEEE);
            a = _FF(a, b, c, d, x[k + 4], S11, 0xF57C0FAF);
            d = _FF(d, a, b, c, x[k + 5], S12, 0x4787C62A);
            c = _FF(c, d, a, b, x[k + 6], S13, 0xA8304613);
            b = _FF(b, c, d, a, x[k + 7], S14, 0xFD469501);
            a = _FF(a, b, c, d, x[k + 8], S11, 0x698098D8);
            d = _FF(d, a, b, c, x[k + 9], S12, 0x8B44F7AF);
            c = _FF(c, d, a, b, x[k + 10], S13, 0xFFFF5BB1);
            b = _FF(b, c, d, a, x[k + 11], S14, 0x895CD7BE);
            a = _FF(a, b, c, d, x[k + 12], S11, 0x6B901122);
            d = _FF(d, a, b, c, x[k + 13], S12, 0xFD987193);
            c = _FF(c, d, a, b, x[k + 14], S13, 0xA679438E);
            b = _FF(b, c, d, a, x[k + 15], S14, 0x49B40821);
            a = _GG(a, b, c, d, x[k + 1], S21, 0xF61E2562);
            d = _GG(d, a, b, c, x[k + 6], S22, 0xC040B340);
            c = _GG(c, d, a, b, x[k + 11], S23, 0x265E5A51);
            b = _GG(b, c, d, a, x[k + 0], S24, 0xE9B6C7AA);
            a = _GG(a, b, c, d, x[k + 5], S21, 0xD62F105D);
            d = _GG(d, a, b, c, x[k + 10], S22, 0x2441453);
            c = _GG(c, d, a, b, x[k + 15], S23, 0xD8A1E681);
    <40 строк поспипано>
            b = _II(b, c, d, a, x[k + 9], S44, 0xEB86D391);
            a = addUnsigned(a, AA);
            b = addUnsigned(b, BB);
            c = addUnsigned(c, CC);
            d = addUnsigned(d, DD);
    }

    http://phpjs.org/downloads/phpjs.commonjs.js.
    Там оказалось реально много жира. Я сначала подумал, что сеть Фейштеля, но потом-таки разглядел MD5.
    Говносути это конечно не меняет.

    3.14159265, 07 Марта 2012

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

    +156

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    if (coms->Strings[1]=="install") {
              if (GetFile("localhost",WinDir+comms->Strings[3]) {
                execCommand=true;
              }else{
                execCommand=false;
              }

    вот такое вот чудо нашел в одном проЭкте предыдущего програмера, который до меня работал)
    вместо localhost передавалось имя файла на сервере

    stasuss, 07 Марта 2012

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

    +997

    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
    char* CFastSmtp::_formatHeader()
    {
    // check for at least one recipient
        if(Recipients.size() <= 0 )    {
            printf("Please add a message recipient!\r\n");
            return NULL;
        }
        int s=0;
        char *msgHeader = new char[16385];
        //char to[1024];
        for (unsigned int i=s=0;i<Recipients.size();i++) {        
            s+=strlen(Recipients.at(i)->GetEmail())+1;
        } if (s==0) s=1; char *to = new char[s];
        //char cc[1024];
        for (i=s=0;i<CCRecipients.size();i++) {        
            s+=strlen(CCRecipients.at(i)->GetEmail())+1;
        } if (s==0) s=1; char *cc = new char[s];
        //char bcc[1024];
        for (i=s=0;i<BCCRecipients.size();i++) {        
            s+=strlen(BCCRecipients.at(i)->GetEmail())+1;
        } if (s==0) s=1; char *bcc = new char[s];
    
        TCHAR szDate[500];
        TCHAR sztTime[500];
    
    // create the recipient string, cc string, and bcc string
        to[0] = '\0';        
        for (i=0;i<Recipients.size();i++) {        
            i > 0 ? strcat(to,","):strcat(to,"");
            strcat(to,Recipients.at(i)->GetEmail());
        }
    
        cc[0] = '\0';    
        for (i=0;i<CCRecipients.size();i++) {
            i > 0 ? strcat(cc,","):strcat(cc,"");
            strcat(cc,CCRecipients.at(i)->GetEmail());
        }
    
        bcc[0] = '\0';    
        for (i=0;i<BCCRecipients.size();i++) {
            i > 0 ? strcat(bcc,","):strcat(bcc,"");
            strcat(bcc,BCCRecipients.at(i)->GetEmail());
        }
    // get the current date and time
        SYSTEMTIME st={0};
        ::GetSystemTime(&st);
        ::GetDateFormat(LOCALE_SYSTEM_DEFAULT,0,&st,"ddd',
                        ' dd MMM yyyy",szDate,sizeof(szDate));
        ::GetTimeFormat(LOCALE_SYSTEM_DEFAULT,TIME_FORCE24HOURFORMAT,&st,
                        "HH':'mm':'ss tt",sztTime,sizeof(sztTime));
    // here it is...the main data of the message
        wsprintf(msgHeader,"DATE: %s %s\r\n", szDate, sztTime);    
        if (m_pcFromName != NULL) {
            strcat(msgHeader,"FROM: ");
            strcat(msgHeader, m_pcFromName);
            strcat(msgHeader, "\r\n");
        }
        strcat(msgHeader,"To: ");
        strcat(msgHeader, to);
        strcat(msgHeader, "\r\n");
        strcat(msgHeader,"Cc: ");
        strcat(msgHeader, cc);
        strcat(msgHeader, "\r\n");
        if (m_pcSubject != NULL) {
            strcat(msgHeader, "Subject: ");
            strcat(msgHeader, m_pcSubject);
            strcat(msgHeader, "\r\n");
        }
        if (m_pcXMailer != NULL) {
            strcat(msgHeader,"X-Mailer: ");
            strcat(msgHeader, m_pcXMailer);
            strcat(msgHeader, "\r\n");
        }
    // start optional fields
        if (m_pcReplyTo != NULL) {
            strcat(msgHeader, "Reply-To: ");
            strcat(msgHeader, m_pcReplyTo);
            strcat(msgHeader, "\r\n");
        }
    // start MIME versions
        strcat(msgHeader, 
               "MIME-Version: 1.0\r\nContent-type: text/plain; charset=US-ASCII\r\n");
    // send header finish command
        strcat(msgHeader, "\r\n");    
    // clean up
        delete to;
        delete cc;
        delete bcc;
    // done    
        return msgHeader;    
    }

    аццкий говнокодер
    http://www.codeproject.com/Articles/623/CFastSmtp-Fast-and-easy-SMTP-class

    63F45EF45RB65R6VR, 07 Марта 2012

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

    +153

    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
    function fnCheckNetwork($intNetworkId)
    {
        if (intval($intNetworkId) == 0)
        {
            return false;
        }
    
        if ($intNetworkId != $this->fnGetNetworkId())
        {
            return false;
        }
    
        return true;
    }

    Замечу, что функция использовалась как приватная, а $intNetworkId никогда не мог быть 0.

    Вобщем оригинальный способ проверить на равентсво два числа ))

    step307, 06 Марта 2012

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

    +130

    1. 1
    public void GetLocalUsers(out List<string> members) { ... }

    Первый раз вижу что-то подобное.

    fr0mrus, 06 Марта 2012

    Комментарии (31)
  6. JavaScript / Говнокод #9620

    +197

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    this.setlocale('LC_ALL',0);return text.search(this.php_js.locales[this.php_js.localeCategories.LC_CTYPE].LC_CTYPE.an)!==-1;},ctype_alpha:function(text){if(typeof text!=='string'){return false;}
    this.setlocale('LC_ALL',0);return text.search(this.php_js.locales[this.php_js.localeCategories.LC_CTYPE].LC_CTYPE.al)!==-1;},ctype_cntrl:function(text){if(typeof text!=='string'){return false;}
    this.setlocale('LC_ALL',0);return text.search(this.php_js.locales[this.php_js.localeCategories.LC_CTYPE].LC_CTYPE.ct)!==-1;},ctype_digit:function(text){if(typeof text!=='string'){return false;}
    this.setlocale('LC_ALL',0);return text.search(this.php_js.locales[this.php_js.localeCategories.LC_CTYPE].LC_CTYPE.dg)!==-1;},ctype_graph:function(text){if(typeof text!=='string'){return false;}
    this.setlocale('LC_ALL',0);return text.search(this.php_js.locales[this.php_js.localeCategories.LC_CTYPE].LC_CTYPE.gr)!==-1;},ctype_lower:function(text){if(typeof text!=='string'){return false;}
    this.setlocale('LC_ALL',0);return text.search(this.php_js.locales[this.php_js.localeCategories.LC_CTYPE].LC_CTYPE.lw)!==-1;},ctype_print:function(text){if(typeof text!=='string'){return false;}
    this.setlocale('LC_ALL',0);return text.search(this.php_js.locales[this.php_js.localeCategories.LC_CTYPE].LC_CTYPE.pr)!==-1;},ctype_punct:function(text){if(typeof text!=='string'){return false;}
    this.setlocale('LC_ALL',0);return text.search(this.php_js.locales[this.php_js.localeCategories.LC_CTYPE].LC_CTYPE.pu)!==-1;},ctype_space:function(text){if(typeof text!=='string'){return false;}
    this.setlocale('LC_ALL',0);return text.search(this.php_js.locales[this.php_js.localeCategories.LC_CTYPE].LC_CTYPE.sp)!==-1;},ctype_upper:function(text){if(typeof text!=='string'){return false;}
    this.setlocale('LC_ALL',0);return text.search(this.php_js.locales[this.php_js.localeCategories.LC_CTYPE].LC_CTYPE.up)!==-1;},ctype_xdigit:function(text){if(typeof text!=='string'){return false;}

    При беглом просмотре бросился мне тут в глаза кусочек из http://phpjs.org/downloads/php.common.min.js

    3.14159265, 06 Марта 2012

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

    −85

    1. 1
    http://pastebin.com/UaTdN6K2

    А выложу ка я это тут.
    Гуано трёхлетней выдержки. Фрагментации не поддаётся. Ныне отправлено на удобрения.

    krypt, 06 Марта 2012

    Комментарии (10)
  8. JavaScript / Говнокод #9617

    +158

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    function SetCeilingType(Txt) {
    
        if (Txt == "1") {
            document.getElementById("сeilType").value = Txt //"Одноуровневый";
        }
        else {
            document.getElementById("сeilType").value = Txt //"Двухуровневый";
        }
        createLink();
    }

    Сраная школота уходит в буддизм.
    Вот такая сентенция была найдена за flash-кодером, хуже всего что функция глобальна, так как дергается ИЗ ФЛЕША при изменении в нем данных. Творческое прочтение паттерна инверсии зависимости, сцуко!

    Meettya, 06 Марта 2012

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

    +78

    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
    Drawable d = getResources().getDrawable(R.drawable.screen_width);
            int width = d.getMinimumWidth();
            switch (width) {
                case 1024:
                    CAMERA_WIDTH = 1024;
                    CAMERA_HEIGHT = 600;
                    break;
                case 800:
                    CAMERA_WIDTH = 800;
                    CAMERA_HEIGHT = 480;
                    break;
                case 480:
                    CAMERA_WIDTH = 480;
                    CAMERA_HEIGHT = 320;
                    break;
                case 320:
                    CAMERA_WIDTH = 320;
                    CAMERA_HEIGHT = 240;
                    break;
                default:
                    CAMERA_WIDTH = 800;
                    CAMERA_HEIGHT = 480;
                    break;
            }

    Вот так автор определял размер экрана в Android...по размеру загруженной картинки в ресурсах
    Про getResources().getConfiguration().screen Layout наверное он не знал...

    TeknoMatik, 05 Марта 2012

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

    −111

    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
    95. 95
    96. 96
    97. 97
    98. 98
    -(void)handleNotification:(id<INotification>)notification
    {
    	NSLog(@"NOTIFICATION:%@", [notification description]);
    	if ([[notification name] isEqualToString:ShowMetronomeInTab]) 
    	{
    		[self.viewComponent showMetronomeInTab];
    	}
    	else if ([[notification name] isEqualToString:AlertOnScreen]) 
    	{
    		isShowRateAlert = YES;
    	}
    	else if ([[notification name] isEqualToString:NoAlertOnScreen]) 
    	{
    		isShowRateAlert = NO;
    	}
    	else if ([[notification name] isEqualToString: ShowHowToEnter]) 
    	{
    		id body = [notification body];
    		[self.viewComponent showHowToEnter:body];
    	}
    	else if ([[notification name] isEqualToString:ShowResultView]) 
    	{
    		[self.viewComponent showResultView:[notification body] Animated:YES];
    	}
    	else if ([[notification name] isEqualToString:ShowIndicatorView]) 
    	{
            if ([[notification body] isKindOfClass:[NSString class]]) 
            {
                [self.viewComponent showLoadingIndicator:[notification body]];
            }
            else 
            {
                if ([[notification body] isKindOfClass:[NSArray class]]) 
                {
                    [self.viewComponent showLoadingIndicator:[[notification body] objectAtIndex:0] WithSecondString:[[notification body]objectAtIndex:1]];
                }
            }		
    	}
        else if ([[notification name] isEqualToString:ShowBlackIndicatorView]) 
    	{
            [self.viewComponent showBlackLoadingIndicator:[notification body]];	
    	}
    	else if ([[notification name] isEqualToString:RemoveIndicatorView]) 
    	{
    		[self.viewComponent removeLoadingIndicator];
    	}
    	else if ([[notification name] isEqualToString:ShowTimeOutAlert]) 
    	{
    		[self.viewComponent displayAlertOnConnectionTimeOut];
    	}
    	else if ([[notification name] isEqualToString:ShowNetworkUnavailableAlert]) 
    	{
    		[self.viewComponent displayAlertOnNetworkError];
    	}
    	else if ([[notification name] isEqualToString:ShowServiceUnavailableAlert]) 
    	{
    		[self.viewComponent displayAlertOnConnectionError];
    	}
    	else if ([[notification name] isEqualToString:ShowHomeView]) 
    	{
    		[self.viewComponent showHomeView];
    	}
    	else if ([[notification name] isEqualToString:ShowProcessingView]) 
    	{
    		[self.viewComponent showProcessingView:[notification body]];
    	} else if ([[notification name] isEqualToString:ShowResultViewNotAnimated]) 
    	{
    		[self.viewComponent showResultView:[notification body] Animated:NO];
    	} else if ([[notification name] isEqualToString:ShowTimeOutAlertWithParent]) 
    	{
    		[self.viewComponent displayAlertOnConnectionTimeOutWithParent:notification.body];
    	}
    	else if ([[notification name] isEqualToString:ShowNetworkUnavailableAlertWithParent]) 
    	{
    		[self.viewComponent displayAlertOnNetworkErrorWithParent:notification.body];
    	}
    	else if ([[notification name] isEqualToString:ShowServiceUnavailableAlertWithParent]) 
    	{
    		[self.viewComponent displayAlertOnConnectionErrorWithParent:notification.body];
    	} 
        else if ([[notification name] isEqualToString:RotationIndicator]) 
    	{
            [self.viewComponent rotationIndicator];
    	}
    	else if ([[notification name] isEqualToString:StartMusic])
        {
            if (applicationProxy.mediaPlayerWasPlaying)
    		{	
    			applicationProxy.mediaPlayerIsPlaying = YES;
    			[self sendNotification:MediaPlayerChangeState];
    			MPMusicPlayerController *mpPlayer = [MPMusicPlayerController iPodMusicPlayer];
    			[mpPlayer play];
    		}
        }
    	else if ([[notification name] isEqualToString:StopMusic])
        {
            applicationProxy.mediaPlayerIsPlaying  = NO;
    		[self sendNotification:MediaPlayerChangeState];

    И так 50 elseif'ов. И, сцуко, все разные. И в последней трети отформатированы лесенкой.
    Местное видение PureMVC

    krypt, 05 Марта 2012

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