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

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

    +157

    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
    switch(resp.error_code)
    			{
    				case 0:
    				{
    					new URI('/account/success/').go();
    					return;
    				}
    				case BAD_CAPTCHA:
    				{					
    					var c = $('fRegistration').getElement(".captcha");
    					c.innerHTML = '<br />' + resp.error_message;
    					break;
    				}
    				case BAD_EMAIL:
    				{
    					var c = $('fRegistration').getElement(".email");
    					c.innerHTML = '<br />' + resp.error_message;
    					break;
    				}
    				case BAD_PASSWORD:
    				{
    					var c = $('fRegistration').getElement(".passwd");
    					c.innerHTML = resp.error_message + '<br />';
    					break;
    				}
    				case BAD_AGREEMENT:
    				{
    					var c = $('fRegistration').getElement(".agreement");
    					c.innerHTML = resp.error_message + '<br />';
    					break;
    				}
    				default:
    				{
    					var c = $('fRegistration').getElement(".other_errors");
    					c.innerHTML = resp.error_message + '<br />';
    					break;
    				}
    			}

    Классно, да?
    Особенно интересно то, что используется фреймворк mootools и не используются его функции :)

    $$('#fRegistration .other_errors")[0].set('html', resp.error_message + '<br />');

    Вообще считаю избыточным передавать и код и строку ошибки

    rudolff, 06 Августа 2010

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

    +127

    1. 1
    mysql_query("update users set prod0=$prod0 , prod1=$prod1 , prod2=$prod2, prod3=$prod3, prod4=$prod4, prod5=$prod5, prod6=$prod6, prod7=$prod7, prod8=$prod8, prod9=$prod9, prod10=$prod10, prod11=$prod11, prod12=$prod12, prod13=$prod13, prod14=$prod14, prod15=$prod15, prod16=$prod16, prod17=$prod17, prod18=$pro18, prod19=$prod19, prod20=$prod20, prod21=$prod21, prod22=$prod22, prod23=$prod23, prod24=$prod24, prod25=$prod25, prod26=$prod26, prod27=$prod27, prod28=$prod28, prod29=$prod29, prod30=$prod30, prod31=$prod31, prod32=$prod32, prod33=$prod33, prod34=$prod34, prod35=$prod35, prod36=$prod36, prod37=$prod37, prod38=$prod38, prod39=$prod39 WHERE uname='".$_SESSION['uname']."';");

    Vasiliy, 01 Августа 2010

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

    +102

    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
    private static string GetRootedCurrentConfigurationFile(string configurationFile)
    {
    if (string.IsNullOrEmpty(configurationFile))
    {
    throw new ArgumentException(Resources.ExceptionStringNullOrEmpty, "configurationFile");
    }
    if (!File.Exists(configurationFile))
    {
    throw new FileNotFoundException(string.Format(CultureInfo.CurrentCulture, Resources.ExceptionConfigurationLoadFileNotFound, new object[] { configurationFile }));
    }
    if (!Path.IsPathRooted(configurationFile))
    {
    return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, configurationFile);
    }
    return configurationFile;
    }

    Собснно Говнокод by Microsoft (Ent Lib 5.0.414.0)

    TrueLauncher, 30 Июля 2010

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

    +163

    1. 1
    if(in_array($rating,array_keys($ratings))) ...

    ужос средь бела дня)

    xakki, 29 Июля 2010

    Комментарии (12)
  6. bash / Говнокод #3800

    −126

    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
    start() {
      echo "starting Adaptec Storage Manager agent ..."
      kill `ps axwww | grep java | grep StorMan | grep ManagementAgent | cut -b 1-6` 1>/dev/null 2>&1
      sleep 2
      kill -9 `ps axwww | grep java | grep StorMan | grep ManagementAgent | cut -b 1-6` 1>/dev/null 2>&1
      sh /usr/StorMan/StorAgnt.sh >/dev/null 2>&1 &
      sleep 1
      echo
    }
    
                                                                    
    stop() {
      echo "stopping Adaptec Storage Manager agent ..."
      kill `ps axwww | grep java | grep StorMan | grep ManagementAgent | cut -b 1-6` 1>/dev/null 2>&1
      sleep 2
      kill -9 `ps axwww | grep java | grep StorMan | grep ManagementAgent | cut -b 1-6` 1>/dev/null 2>&1
      sleep 1
      echo
    }

    Кусок скрипта для RAID от фирмы Adaptec. Боюсь смотреть, что они там в java накодили.

    icCE, 28 Июля 2010

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

    +159

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    BYTE p1,p2,p3,p4;
    CString p;
    ipa.GetAddress(p1,p2,p3,p4);
    p.Format("%d.", p1);
    s = p;
    p.Format("%d.", p2);
    s += p;
    p.Format("%d.", p3);
    s += p;
    p.Format("%d", p4);
    s += p;
    AfxMessageBox(s);

    книга "Microsoft Visual Studio и MFC", автор Т. Сидорина
    ранее были объявлены
    CIPAddressCtrl ipa;
    CString s;

    s.Format ("%d.%d.%d.%d", p1, p2, p3, p4); //мы не исчем лёгких путей

    daemon_master, 23 Июля 2010

    Комментарии (12)
  8. PHP / Говнокод #3760

    +144

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    void get_tomorrow_date( struct timeval *date ) 
    { 
    sleep( 86400 ); // 60 * 60 * 24 
    gettimeofday( date, 0 ); 
    }

    Программистский шедевр на индусском форуме на тему «как узнать завтрашнюю дату» остался непревзойденным.

    REDNES, 22 Июля 2010

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

    +172

    1. 1
    function getCodeByCode(code)

    хорошее название функции

    mozg_raka, 20 Июля 2010

    Комментарии (12)
  10. Си / Говнокод #3740

    +141

    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
    int AnalizingHeaderLine(char* HeadLine)
    {
    	if(HeadLine==NULL) return -1;
    	if(strlen(HeadLine)==0) return 0;
    
    	if(!strncmp(HeadLine,"HTTP/",5))
    		ProcessStatusHL(HeadLine);
    	else if(!strncmp(strlwr(HeadLine), "date:",5))
    		ProcessDateHL(HeadLine);
    	else if(!strncmp(strlwr(HeadLine), "server:",7))
    		ProcessServerHL(HeadLine);
    	else if(!strncmp(strlwr(HeadLine), "last-modified:",14))
    		ProcessLastModHL(HeadLine);
    	else if(!strncmp(strlwr(HeadLine), "content-type:",13))
    		ProcessContTypeHL(HeadLine);
    	else if(!strncmp(strlwr(HeadLine), "content-length:",15))
    		ProcessContLenHL(HeadLine);
    	else if(!strncmp(strlwr(HeadLine), "pragma:",7))
    		ProcessPragmaHL(HeadLine);
    	else if(!strncmp(strlwr(HeadLine), "Connection",10))
    		ProcessConnectHL(HeadLine);
    	else printf("Unknown header line: %s\n", HeadLine);
    	return strlen(HeadLine);
    }
    
    int ProcessStatusHL(char* HeadLine)
    {
    	short MinVer, MajVer;
    	char ResultStr[32];
    	char Num;
    	short Code;
    	Num = sscanf(HeadLine, "HTTP/%d.%d %d %s", &MinVer, &MajVer, &Code, ResultStr);
    	if(Num!=3 && Num!=4) 
    	{	printf("Error status string\n");
    		return -1;
    	}
    	return Code;
    }
    
    int ProcessDateHL(char* HeadLine)
    {
    	printf("%s\n",HeadLine);
    	return 0;
    }
    
    int ProcessServerHL(char* HeadLine)
    {
    	printf("%s\n",HeadLine);
    	return 0;
    }
    
    int ProcessLastModHL(char* HeadLine)
    {
    	printf("%s\n",HeadLine);
    	return 0;
    }
    
    int ProcessContTypeHL(char* HeadLine)
    {
    	printf("%s\n",HeadLine);
    	return 0;
    }
    
    int ProcessContLenHL(char* HeadLine)
    {
    	printf("%s\n",HeadLine);
    	return 0;
    }
    
    int ProcessPragmaHL(char* HeadLine)
    {
    	printf("%s\n",HeadLine);
    	return 0;
    }
    
    int ProcessConnectHL(char* HeadLine)
    {
    	printf("%s\n",HeadLine);
    	return 0;
    }

    CGI. Обработка HTTP-заголовков. Rev. 1.0

    absolut, 20 Июля 2010

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

    +152

    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
    Map = function() {
        this._entries = new Array();
    }
    
    Map.prototype.containsKey = function(key) {
        return this.getEntry(key)!=null;
    }
    
    Map.prototype.get = function(key) {
        var entry = this.getEntry(key);
        return entry!=null ? entry.value : null;
    }
    
    Map.prototype.put = function(key, value) {
        var entry = this.getEntry(key);
        if (entry!=null) {
            entry.value = value;
        } else {
            entry = new Map.Entry(key, value);
            this._entries[this._entries.length] = entry;
        }
    }
    
    Map.prototype.size = function() {
        return this._entries.length;
    }
    
    Map.prototype.getEntry = function(key) {
        for (var i=0; i<this._entries.length; i++) {
            if (this._entries[i].key==key)
                return this._entries[i];
        }
        return null;
    }
    
    Map.prototype.entries = function() {
        return this._entries;
    }
    
    Map.prototype.keys = function() {
        var result = new Array();
        for (var i=0; i<this._entries.length; i++) {
            result[result.length] = this._entries[i].key;
        }
        return result;
    }
    
    Map.prototype.values = function() {
        var result = new Array();
        for (var i=0; i<this._entries.length; i++) {
            result[result.length] = this._entries[i].value;
        }
        return result;
    }
    
    Map.prototype.addAll = function(map) {
        if (map==null)
            return;
        var oe = map.entries();
        for (var i=0; i<oe.length; i++) {
            this.put(oe[i].key, oe[i].value);
        }
    }
    
    Map.prototype.toString = function() {
        return "[Map{size:"+this._entries.length+", entries:"+this._entries+"}]";
    }
    
    Map.Entry = function(key, value) {
        if (arguments.length==0)
            return;
        this.key = key;
        this.value = value;
    }
    
    Map.Entry.prototype.toString = function() {
        return "[Entry{key:"+this.key+", value:"+this.value+"}]";
    }

    То что любой объект и так работает как Map автор видимо не знал.
    Можно было бы предположить, что автор это знал, но написал этот Map для того чтобы использовать произвольные объекты как ключи, однако во всех обнаруженных использованиях этой Map ключами были строки.

    borka, 17 Июля 2010

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