1. Список говнокодов пользователя guest

    Всего: 1419

  2. PHP / Говнокод #784

    +148.3

    1. 1
    2. 2
    3. 3
    4. 4
    if($path != goodPath($path))
    {
      $notfound = true;
    }

    сферический индус в вакууме

    guest, 28 Марта 2009

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

    +136.7

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    if(!connect("call.beeline.ru", "9051234567", "$sound")) { die "Ошибка!";}
    else { 
        echo "Succefully connected!\nTrying to call.."; 
        if(!CallNumber("9051234567")) {die "Cant call number 9051234567!";}
        else { 
           echo "Call to number 9051234567 succefully!";
           play("1.mp3"); play("4.mp3"); play("2.mp3"); 
        } 
    };

    шутка юмора

    guest, 27 Марта 2009

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

    +139.5

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    if(strncmp(I_CUR->E98,"",sizeof("")-1) != 0)
    {
        /** Fehler **/
        ret=create_error(1,1,"",NULL,NULL);
        set_error_msgseg(-1,-1,"CUR",NULL," E98",-1);
        if (ret==FEHLER)
            return ret;
    }

    Генератор сорса для одного проекта в очень крупной конторе дает такой код, который должен сообщать об ошибке.

    Долго я удивлялся, что ошибок не появляется
    if(0 != 0)

    guest, 27 Марта 2009

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

    +112.5

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    public void Log(string pSource, string pMessage, EventLogEntryType pEntryType) {
        try {
            if (!EventLog.SourceExists(pSource)) {
                EventLog.CreateEventSource(pSource, "Application");
            }
    
            EventLog.WriteEntry(pSource, pMessage, pEntryType);
        }
        catch (Exception _ex) {
            Log("", _ex.ToString(), EventLogEntryType.Error);
        }
    }

    Пишем в лог - постоянно...
    Автор находки: http://ayende.com/Blog/archive/2009/03/19/how-not-to-write-a-logger.aspx

    guest, 27 Марта 2009

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

    +139.2

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    fillValuesSelects: function(defaultNStargets, defaultNSgeo, xmlDoc){
    		try{
    			var ageStr = xmlDoc.getElementsByTagName(defaultNStargets+this.profileMessageParamageTagName)[0].childNodes[0].nodeValue;
    			ageStr = (ageStr && ageStr.indexOf("-") != ageStr.lastIndexOf("-"))?ageStr.split("-"):[null, null, null];
    			document.getElementById("yearagept").value = ageStr[0]?ageStr[0]:"";
    			document.getElementById("monthagept").value = ageStr[1]?ageStr[1]:"";
    			document.getElementById("dayagept").value = ageStr[2]?ageStr[2]:"";
    		}
    		catch(ex){}
    	
    		try{
    			for(var i=0; i < document.getElementById("sexpt").childNodes.length; i++){
    				if(document.getElementById("sexpt").childNodes[i].childNodes[0].nodeValue.toLowerCase() ==
    					this.getShortTargetNameValue('sex', xmlDoc.getElementsByTagName(defaultNStargets+this.profileMessageParamsexTagName)[0].childNodes[0].nodeValue.toLowerCase()).toLowerCase()){
    						document.getElementById("sexpt").selectedIndex = i;
    						break;
    				}
    			}
    		}
    		catch(ex){}
    	
    		try{
    			var gid = xmlDoc.getElementsByTagName(defaultNSgeo+this.profileMessageParamGeoIDTagName)[0].childNodes[0].nodeValue;
    			if(gid.indexOf(':') != -1) gid = gid.substring(0, gid.indexOf(':'));
    			this.findGeoLocationById(gid);
    		}
    		catch(ex){}
    	
    		try{
    			for(var i=0; i < document.getElementById("socialpt").childNodes.length; i++){
    				if(document.getElementById("socialpt").childNodes[i].childNodes[0].nodeValue.toLowerCase() ==
    					this.getShortTargetNameValue('socialstatus', xmlDoc.getElementsByTagName(defaultNStargets+this.profileMessageParamSocialStatusTagName)[0].childNodes[0].nodeValue.toLowerCase()).toLowerCase()){
    						document.getElementById("socialpt").selectedIndex = i;
    						break;
    				}
    			}
    		}
    		catch(ex){}
    	
    		try{
    			for(var i=0; i < document.getElementById("familypt").childNodes.length; i++){
    				if(document.getElementById("familypt").childNodes[i].childNodes[0].nodeValue.toLowerCase() ==
    					this.getShortTargetNameValue('maritalstatus', xmlDoc.getElementsByTagName(defaultNStargets+this.profileMessageParamMaritalStatusTagName)[0].childNodes[0].nodeValue.toLowerCase()).toLowerCase()){
    						document.getElementById("familypt").selectedIndex = i;
    						break;
    				}
    			}
    		}
    		catch(ex){}
    	
    		try{
    			for(var i=0; i < document.getElementById("childpt").childNodes.length; i++){
    				if(document.getElementById("childpt").childNodes[i].childNodes[0].nodeValue.toLowerCase() ==
    					this.getShortTargetNameValue('children', xmlDoc.getElementsByTagName(defaultNStargets+this.profileMessageParamchildrenTagName)[0].childNodes[0].nodeValue.toLowerCase()).toLowerCase()){
    						document.getElementById("childpt").selectedIndex = i;
    						break;
    				}
    			}
    		}
    		catch(ex){}
    	
    		try{
    			for(var i=0; i < document.getElementById("edupt").childNodes.length; i++){
    				if(document.getElementById("edupt").childNodes[i].childNodes[0].nodeValue.toLowerCase() ==
    					this.getShortTargetNameValue('education', xmlDoc.getElementsByTagName(defaultNStargets+this.profileMessageParameducationTagName)[0].childNodes[0].nodeValue.toLowerCase()).toLowerCase()){
    						document.getElementById("edupt").selectedIndex = i;
    						break;
    				}
    			}
    		}
    		catch(ex){}
    	
    		try{
    			for(var i=0; i < document.getElementById("worknpt").childNodes.length; i++){
    				if(document.getElementById("worknpt").childNodes[i].childNodes[0].nodeValue.toLowerCase() ==
    					this.getShortTargetNameValue('jobstatus', xmlDoc.getElementsByTagName(defaultNStargets+this.profileMessageParamjobTagName)[0].childNodes[0].nodeValue.toLowerCase()).toLowerCase()){
    						document.getElementById("worknpt").selectedIndex = i;
    						break;
    				}
    			}
    		}
    		catch(ex){}
    	
    		try{
    			for(var i=0; i < document.getElementById("incomept").childNodes.length; i++){
    				if(document.getElementById("incomept").childNodes[i].childNodes[0].nodeValue.toLowerCase() ==
    					this.getShortTargetNameValue('incomestatus', xmlDoc.getElementsByTagName(defaultNStargets+this.profileMessageParamincomeTagName)[0].childNodes[0].nodeValue.toLowerCase()).toLowerCase()){
    						document.getElementById("incomept").selectedIndex = i;
    						break;
    				}
    			}
    		}
    		catch(ex){}
    	
    		try{
    			for(var i=0; i < document.getElementById("inetpt").childNodes.length; i++){
    				if(document.getElementById("inetpt").childNodes[i].childNodes[0].nodeValue.toLowerCase() ==
    					this.getShortTargetNameValue('internetaccessstatus', xmlDoc.getElementsByTagName(defaultNStargets+this.profileMessageParaminternetaccessTagName)[0].childNodes[0].nodeValue.toLowerCase()).toLowerCase()){
    						document.getElementById("inetpt").selectedIndex = i;
    						break;

    Кусочек кода одной системы одной довольно известной IT-компании в Рунете ;-)

    guest, 26 Марта 2009

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

    +143.3

    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
    <select name="wday_finish"/>
                           <?php
                                   if ( $wday_finish == '-' ) { $default = ' selected'; }
                                   else {$default = '';}
                                   echo "<option value=\"-\" $default>-";
    
                                   if ( $wday_finish == 'mon' ) { $default = ' selected'; }
                                    else {$default = '';}
                                   echo "<option value=\"mon\" $default>" . _("Monday");
    
                                    if ( $wday_finish == 'tue' ) { $default = ' selected'; }
                                   else {$default = '';}
                                    echo "<option value=\"tue\" $default>" . _("Tuesday");
    
                                    if ( $wday_finish == 'wed' ) { $default = ' selected'; }
                                   else {$default = '';}
                                    echo "<option value=\"wed\" $default>" . _("Wednesday");
    
                                    if ( $wday_finish == 'thu' ) { $default = ' selected'; }
                                    else {$default = '';}
                                    echo "<option value=\"thu\" $default>" . _("Thursday");
    
                                    if ( $wday_finish == 'fri' ) { $default = ' selected'; }
                                    else {$default = '';}
                                    echo "<option value=\"fri\" $default>" . _("Friday");
    
                                    if ( $wday_finish == 'sat' ) { $default = ' selected'; }
                                    else {$default = '';}
                                    echo "<option value=\"sat\" $default>" . _("Saturday");
    
                                   if ( $wday_finish == 'sun' ) { $default = ' selected'; }
                                    else {$default = '';}
                                    echo "<option value=\"sun\" $default>" . _("Sunday");
                           ?>

    freepbx. timeconditions module.

    guest, 26 Марта 2009

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

    +155.4

    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
    .....
    	double CHTerritory;
    	int CHNextGeneration;
    	int CHPeople;
    	int CHScTurns;
    	int CHDefMin;
    	int CHDefMax;
    	int CHAtMin;
    	int CHAtMax;
    	int CHArmies;
    	int CHGrain;
    	int CHScientist;
    	double CHMoney;
    	int CHUnHP_1;
    	int CHArm;
    	int CHATT;
    	int CHDEFF;
    	int CHUnHP;
    	int CHArm_1;
    	int AtChoice;
    ....
    Begin:	
    	int Choice;
    
    	cout << "\n""Year: ";
    	cout << Year;
    
    	cout << "\n""Money ";
    	cout << Money;
    	cout << " $";
    
    	Tax = People / 2;
    	cout << "\n""Tax: ";
    	cout << Tax;
    	cout << " $";
    
    	cout << "\n""Territory: ";
    	cout << Territory;
    	cout << " KM^2";
    
    	cout << "\n""What do you want?";
    	cout << "\n""Science - 1, Army - 2, Agrarian Production - 3,";
    	cout << "\n""Social Question - 4, Next Year - 5, Spy - 6, Exit - 7: ";
    
    	cin >> Choice;
    	if(Choice == 1)
    	{
    		goto Science;
    	}
    	if(Choice == 2)
    	{
    		goto Army;
    	}
    	if(Choice == 3)
    	{
    		goto AgrarianProduction;
    	}
    	if(Choice == 4)
    	{
    		goto SocialQuestion;
    	}
    	if(Choice == 5)
    	{
    		goto NextYear;
    	}
    	if(Choice == 6)
    	{
    		goto Spy;
    	}
    	if(Choice == 7)
    	{
    		goto Replay;
    	}
    	else
    	{
    		cout << "\n""TbI Tynou ?";
    		cout << "\n";
    		goto Begin;
    	}
    ....
    if(AmUnHP_1 <= 0)
    {
    	AmArmies = AmArmies - 1;
    	goto LKJMNZZA;
    }
    else
    {
    	goto LKJMNZZB;
    }

    Моя одна из первых "серьезных" программ на С++, показывающая, что даже без знаний (главное - желание) можно писать БОЛЬШИЕ программы. Программа - стратегическая консольная игра, исходник в 64 КБ и все в... ОДНОЙ функции main :) также тогда еще не знал о существовании массивов, switch и многого другого:) К сожалению все 4000 строк кода сюда не влезают, так что вот примеры стандартных участков кода.

    guest, 26 Марта 2009

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

    +152.3

    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
    <ul>
            \\\".listQuery(\\\"SELECT Hidden_URL, Subdivision_Name, Subdivision_ID FROM Subdivision WHERE Parent_Sub_ID = \\\$data[Subdivision_ID] and checked=1 order by priority \\\", \\\"
            <li><a href='\\\\\\\$data[Hidden_URL]'>\\\\\\\$data[Subdivision_Name]</a>
    
                <ul>
                    \\\\\\\".listQuery(\\\\\\\"SELECT Hidden_URL, Subdivision_Name, Subdivision_ID FROM Subdivision WHERE Parent_Sub_ID = \\\\\\\$data[Subdivision_ID] and checked=1 order by priority \\\\\\\", \\\\\\\"
                    <li><a href='\\\\\\\\\\\\\\\$data[Hidden_URL]'>\\\\\\\\\\\\\\\$data[Subdivision_Name]</a>
    
                    <ul>
                         \\\\\\\\\\\\\\\".listQuery(\\\\\\\\\\\\\\\"SELECT Hidden_URL, Subdivision_Name, Subdivision_ID FROM Subdivision WHERE Parent_Sub_ID = \\\\\\\\\\\\\\\$data[Subdivision_ID] and checked=1 order by priority \\\\\\\\\\\\\\\", \\\\\\\\\\\\\\\"
                         <li><a href='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\$data[Hidden_URL]'>\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\$data[Subdivision_Name]</a>
    
                         <ul>
                             \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\".listQuery(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"SELECT Hidden_URL, Subdivision_Name, Subdivision_ID FROM Subdivision WHERE Parent_Sub_ID = \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\$data[Subdivision_ID] and checked=1 order by priority \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\", \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"
                             <li><a href='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\$data[Hidden_URL]'>\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\$data[Subdivision_Name]</a>
                             <ul></ul></li>
    
                             \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\").\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"
                         </ul></li>
    
    
                         \\\\\\\\\\\\\\\").\\\\\\\\\\\\\\\"
                    </ul></li>
                    \\\\\\\").\\\\\\\"
    
                </ul></li>
    
            \\\").\\\"
            </ul></li>
    
        \").\"
        </ul></li>
        </li>
        ")."
        </ul>
        </div>

    Вывод меню в главном макете дизайна одного сайта на базе говноCMS Netcat. Можно попроще сделать, но видимо автор торопился ;) И весь этот говнокод редактируется в textarea размерами 700x300px без всякой подсветки.

    guest, 26 Марта 2009

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

    +141.4

    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
    int __fastcall TForm1::iscomm(AnsiString str)
    {
    int i=1;
    while (str[i]==' ')
     i++;
    if (str[i]=='#')
     {
      return 1;
     }
    else
     {
      return 0;
     };
    };

    borland C++.
    Функция определяет, является ли строка комментарием (начинается с #)

    guest, 26 Марта 2009

    Комментарии (14)
  11. Куча / Говнокод #775

    +135.2

    1. 1
    <SPAN style="FONT-SIZE: 8pt; COLOR: #4c4c4c; FONT-FAMILY: Verdana"><FONT face=Arial><FONT size=3><FONT face="Times New Roman" size=2>

    ЦМСка и пользователь сделали

    guest, 26 Марта 2009

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