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

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

    +139.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
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    <script type="text/javascript">
    var pics=new Array();
    var stat=new Array();
    
    function changepic(i)
    {
    if (stat[i]>0)
    {
    document.getElementById(i).src=pics[i][stat[i]-1];
    //alert(stat[i]);
    stat[i]=stat[i]+1;
    if (stat[i]>pics[i].length) stat[i]=1;
    setTimeout("changepic('"+i+"')",700);
    //alert("changepic('"+i+"')");
    
    }
    
    }

    guest, 24 Марта 2009

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

    +139.4

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    var viewsId = new List<int>(views.Select(v => v.ViewId).Distinct());
    
    var sviewsId = "," + String.Join(",", viewsId.Select(i => i.ToString()).ToArray()) + ",";
    
    _total = (from d in context.TableA
                                      join uvd in context.TableB on d.DocID equals uvd.DocID
                                      join uv in context.TableC on uvd.ID equals uv.ID
                                      where sviewsId.IndexOf("," + uv.ID.ToString() + ",") > 0
                                      select d.DocID)
                                      .Distinct ()
                                      .Count ();

    Оригинальный способ обойти ограничение на 2100 параметров. А как быстро оно будет работать!
    views, разумеется, из того же контекста.

    eval_2009, 16 Декабря 2009

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

    +139.3

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    if (errno==EINTR) while (errno==EINTR)
         {
                fseek(fr,loffset,SEEK_SET);
                fgets(line_buffer,len,fr);
    }

    sacc - система биллинга для squid

    Одной проверки на ошибку - видимо, недостаточно

    fiss, 11 Ноября 2009

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

    +139.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
    <?
    
    $num=2.324;
    $nll=$num%1;
    
    $pnt=234;
    $ine=$pnt*$nll+1;
    
    if($currentstate==$ine){
     $acceptedstate=1;
    }
    else if($currentstate==$nll){
     $acceptedstate=0;
    }
    else return "NaN";
    ?>

    Кусок кода одной из "Мего-ЦМСок", найденной на woweb-e.

    guest, 05 Августа 2009

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

    +139.3

    1. 1
    (bool) $frmchk_user_edit = 0;

    и такое тут сплошь и рядом...
    платный продукт..

    guest, 24 Февраля 2009

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

    +139.2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    Calendar calen = new GregorianCalendar(); 
    calen.setTime(beginDate); 
    while (!calen.equals(endDate)) {
        calen.add(Calendar.DATE,1);
    }

    guest, 30 Марта 2009

    Комментарии (6)
  8. 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)
  9. PHP / Говнокод #1337

    +139.1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    $mem=f(qs("max(id)+1 as nextid from members "));
    	$mid=$mem[nextid];
    	$sql="`members` ( `id`, `login` , `pswd` , `fname` , `lname` , `email` , `street` , `city` , `state` , `country` , `zip` , `phone` , `fax` , `status` , `rdate` ) VALUES ( '$mid', '$login', '$pswd_1', '$fname', '$lname', '$email', '$street', '$city', '$state', '$country', '$zip', '$phone', '$fax', '$mem_default_approval', '$dt1')";
    	
    	qi($sql);

    Вместо auto_increment индекс можно определить вот таким вод способом)))

    guest, 08 Июля 2009

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

    +139.1

    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
    if (isset($_GET["ADD"]))                        {$ADD=$_GET["ADD"];}
    /* вырезано http://govnokod.ru/610 */
    
    if (!isset($ADD))   {$ADD=0;}
    
    if ($ADD=="1")                  {$hh='users';           echo "Add New User";}
    if ($ADD=="1A")                 {$hh='users';           echo "Copy User";}
    if ($ADD==11)                   {$hh='campaigns';       $sh='basic';    echo "Add New Campaign";}
    if ($ADD==12)                   {$hh='campaigns';       $sh='basic';    echo "Copy Campaign";}
    if ($ADD==111)                  {$hh='lists';           echo "Add New List";}
    if ($ADD==121)                  {$hh='lists';           echo "Add New DNC";}
    if ($ADD==1111)                 {$hh='ingroups';        echo "Add New In-Group";}
    if ($ADD==1211)                 {$hh='ingroups';        echo "Copy In-Group";}
    if ($ADD==11111)                {$hh='remoteagent';     echo "Add New Remote Agents";}
    if ($ADD==111111)               {$hh='usergroups';      echo "Add New Users Group";}
    if ($ADD==1111111)              {$hh='scripts';         echo "Add New Script";}
    /* вырезано 200 строк аналогичного содержания */
    
    /* теперь внимание */
    
    if ( ($ADD>9) && ($ADD < 99998) )
            {
            ##### get scripts listing for dynamic pulldown
            $stmt="SELECT script_id,script_name from vicidial_scripts order by script_id";
            $rslt=mysql_query($stmt, $link);
            /* censored ~ 400 lines  */
    }
    if ( ( (strlen($ADD)>4) && ($ADD < 99998) ) or ($ADD==3) or (($ADD>20) and ($ADD<70)) or ($ADD=="4A")  or ($ADD=="4B") or (strlen($ADD)==12) )
            {
            ##### get server listing for dynamic pulldown
            $stmt="SELECT server_ip,server_description from servers order by server_ip";
            /* censored  ~ 1000 lines */
    }
    ######################
    # ADD=99999 display the HELP SCREENS
    ######################
    
    if ($ADD==99999)
    {
    echo "</title>\n";
    echo "</head>\n";
    echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>\n";
    echo "<CENTER>\n";
    echo "<TABLE WIDTH=98% BGCOLOR=#E6E6E6 cellpadding=2 cellspacing=0><TR><TD ALIGN=LEFT><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=4><B>VICIDIAL ADMIN: HELP<BR></B></FONT><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2><BR><BR>\n";
    
    
    ?>
    <B><FONT SIZE=3>VICIDIAL_USERS TABLE</FONT></B><BR><BR>
     <!-- 22Kb help screen here -->

    vicidial. Новый революционный паттерн. МВЦ это прошлый век.
    Читаем каменты, принцип будет понятен.

    guest, 25 Февраля 2009

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

    +139.1

    1. 1
    2. 2
    3. 3
    4. 4
    // Get required auth level
    		$required_auth_level = 0;
    		if ($d["status"] > 1) $required_auth_level = 1;
    		if ($d["status"] > 3) $required_auth_level = 2;

    Магия чисел

    guest, 20 Февраля 2009

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