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

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

    +154

    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
    <?php 
    function crypt_apr1_md5($plainpasswd) { 
        $salt = substr(str_shuffle("abcdefghijklmnopqrstuvwxyz0123456789"), 0, 8); 
        $len = strlen($plainpasswd); 
        $text = $plainpasswd.'$apr1$'.$salt; 
        $bin = pack("H32", md5($plainpasswd.$salt.$plainpasswd)); 
        for($i = $len; $i > 0; $i -= 16) { $text .= substr($bin, 0, min(16, $i)); } 
        for($i = $len; $i > 0; $i >>= 1) { $text .= ($i & 1) ? chr(0) : $plainpasswd{0}; } 
        $bin = pack("H32", md5($text)); 
        for($i = 0; $i < 1000; $i++) { 
            $new = ($i & 1) ? $plainpasswd : $bin; 
            if ($i % 3) $new .= $salt; 
            if ($i % 7) $new .= $plainpasswd; 
            $new .= ($i & 1) ? $bin : $plainpasswd; 
            $bin = pack("H32", md5($new)); 
        } 
        for ($i = 0; $i < 5; $i++) { 
            $k = $i + 6; 
            $j = $i + 12; 
            if ($j == 16) $j = 5; 
            $tmp = $bin[$i].$bin[$k].$bin[$j].$tmp; 
        } 
        $tmp = chr(0).chr(0).$bin[11].$tmp; 
        $tmp = strtr(strrev(substr(base64_encode($tmp), 2)), 
        "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", 
        "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"); 
        return "$"."apr1"."$".$salt."$".$tmp; 
    } 
    ?>

    Кручу-верчу, запутать хочу!

    7ion, 30 Августа 2011

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

    −119

    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
    standby: function(version) {
            FastChat.destroy();
            curFastChat.standby = true;
            var to = 1,
                cb = function() {
                    if (!curNotifier.is_server) {
                        curFastChat.standbyTO = setTimeout(cb, to * 1000);
                        return;
                    }
                    ajax.post('notifier.php?act=a_get_reload', {
                        version: version
                    }, {
                        onDone: function(navVersion, config) {
                            FastChat.lcSend('gotConfig', {
                                navVersion: navVersion,
                                config: config
                            });
                            FastChat.gotConfig(navVersion, config);
                        },
                        onFail: function() {
                            to *= 2;
                            curFastChat.standbyTO = setTimeout(cb, to * 1000);
                            return true;
                        }
                    });
                };
            cb();
        },
        gotConfig: function(navVersion, config) {
            clearTimeout(curFastChat.standbyTO);
            if (!curFastChat.standby) {
                return;
            }
            setTimeout(function() {
                if (navVersion > stVersions['nav']) {
                    debugLog('appending al loader');
                    headNode.appendChild(ce('script', {
                        type: 'text/javascript',
                        src: '/al_loader.php?act=nav&v=' + navVersion
                    }));
                }
                setTimeout(function() {
                    if (navVersion <= stVersions['nav']) {
                        stManager.add(['notifier.js', 'notifier.css'], function() {
                            FastChat.init(config);
                        })
                        return;
                    }
                    setTimeout(arguments.callee, 100);
                }, 0);
            }, curNotifier.is_server ? 0 : irand(1000, 2000));
        },
        updateVersion: function(version) {
            FastChat.lcSend('standby', {
                version: version
            });
            FastChat.standby(version);
        },
    
        // Local connection: communication between tabs in one browser instanse
        lcSend: function(act, data) {
            // debugLog('fc::lcSend', act, clone(data));
            Notifier.lcSend('fastchat', extend({
                act: act,
                __id: curFastChat.me && curFastChat.me.id || vk.id
            }, data));
        },
        lcRecv: function(data) {
            if (isEmpty(data)) return;
            var act = data.act;
            if (data.__id != (curFastChat.me && curFastChat.me.id || vk.id)) {
                debugLog('drop foreign event', data);
                return;
            }
            delete data.act;
            delete data.__id;
            FastChat.lcFeed(act, data);
        },
        lcFeed: function(act, data) {

    mark, 28 Августа 2011

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

    +134

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    void cmps_genslave(prog src[progs], char slave, char look){	// заполнение списков нелокальных имен
    	int s=0,m=0,l=0;
    	while( src[s].name[0]!=0 && src[s].name[0]!=slave && s<progs)s++;
    	if(!src[s].master) return;
    	if(look==slave){ if(src[s].nonlnum) return; l=s; }else
    		while( src[l].name[0]!=0 && src[l].name[0]!=look && l<progs)l++;
    	if(!src[l].master) return;
    	while(src[m+1].name[0]!=0 && src[l].master==src[m+1].name[0] && m+1<progs)m++;
    	strcpy(src[s].nonlocals+strlen(src[s].nonlocals),src[m].locals);
    	src[s].nonlnum+=src[m].lnum;
    	if(src[m].master) cmps_genslave(src,slave,src[m].name[0]);
    }

    курсовик по проге на втором курсе, изобретаем области видимости

    Venomous, 26 Августа 2011

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

    +163

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    /* allocate memory for the extended format buffer */
      extFormat = new char [ strlen( format ) +
                             strlen( "\n" )   +
                             1 ];
    
      if ( (char*)0 != extFormat )
      {
        /* extend format info */
        sprintf ( extFormat, "%s", format );
        strcat  ( extFormat, "\n" );
      }

    из реализации логгера. просто нет слов.

    Dummy00001, 26 Августа 2011

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

    +147

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    /*Авотризвация*/
    table.authform
    {
      border: 1px solid #899AB2;
    }
    .............

    Интерлайн Про Авотризвирует -_-

    VirtualVoid, 26 Августа 2011

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

    +164

    1. 1
    2. 2
    3. 3
    FrmCabinetFound *frm = new FrmCabinetFound(index.data(Qt::UserRole).toInt());
        ((QMdiArea*)this->parent()->parent()->parent())->addSubWindow(frm);
        frm->show();

    des-1008d, 25 Августа 2011

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

    −97

    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
    i = 0
    t = 12
    r = 0
    g = 0
    while r!=1:
    	i = i + 1
    	if t%i==0:
    		g = g + 1
    	if i==5000:
    		print t, ' - ',g
    		i, g = 0, 0
    		t = t + 1
    	if t==203:
    		r = 1

    Нахождение дилителей.

    Вот так-вот, человек видимо на любит юзать цикл for=)

    KATAJIU3ATOP, 24 Августа 2011

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

    +71

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    @Test
     public void testExecuteNoBean1() {   	
        	try {
                    //...
    		} catch (Exception e) {
    			assertEquals("ActionHandlerDefineDueDate: Error, failed to retrieve ... <over 9000 chars>", e.getMessage());
    		}
     }

    У кого-то явно проблемы с TDD.

    roman-kashitsyn, 23 Августа 2011

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

    −112

    1. 1
    2. 2
    3. 3
    4. 4
    - (void)applicationDidReceiveMemoryWarning:(UIApplication *)application
    {
        [KQCache clearCache];
    }

    memory warning?
    значит надо очистить, и пох какая memory!

    huibla, 22 Августа 2011

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

    +163

    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
    function hideblock(elemid) {
    $('#'+elemid).fadeOut(300);
    setCookie(elemid,'hidden',365);
    $('#i_restore').fadeIn(300);
    }
    
    function restoreblock() {
    $('#i_blog').fadeIn(300);
    $('#i_search').fadeIn(300);
    $('#i_chat').fadeIn(300);
    $('#i_stat').fadeIn(300);
    $('#i_links').fadeIn(300);
    $('#i_tags').fadeIn(300);
    eraseCookie('i_blog');eraseCookie('i_search');eraseCookie('i_chat');eraseCookie('i_stat');eraseCookie('i_links');eraseCookie('i_tags');
    $('#i_restore').fadeOut(300);
    }
    
    
    
    ------------
    
    
    
    
    if (getCookie('i_blog')=='hidden') {$('#i_blog').hide();};
    if (getCookie('i_search')=='hidden') {$('#i_search').hide();};
    if (getCookie('i_chat')=='hidden') {$('#i_chat').hide();};
    if (getCookie('i_stat')=='hidden') {$('#i_stat').hide();};
    if (getCookie('i_links')=='hidden') {$('#i_links').hide();};
    if (getCookie('i_tags')=='hidden') {$('#i_tags').hide();};
    if (!(getCookie('i_links')=='hidden')&&!(getCookie('i_blog')=='hidden')&&!(getCookie('i_stat')=='hidden')&&!(getCookie('i_chat')=='hidden')&&!(getCookie('i_search')=='hidden')&&!(getCookie('i_tags')=='hidden')) {$('#i_restore').hide();};

    Nuff said

    satan, 22 Августа 2011

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