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

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

    +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
    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
    require_once(HTML2PS_DIR.'utils_array.php');
    require_once(HTML2PS_DIR.'utils_graphic.php');
    require_once(HTML2PS_DIR.'utils_url.php');
    require_once(HTML2PS_DIR.'utils_text.php');
    require_once(HTML2PS_DIR.'utils_units.php');
    require_once(HTML2PS_DIR.'utils_number.php');
    require_once(HTML2PS_DIR.'value.color.php');
    require_once(HTML2PS_DIR.'config.parse.php');
    require_once(HTML2PS_DIR.'flow_context.class.inc.php');
    require_once(HTML2PS_DIR.'flow_viewport.class.inc.php');
    require_once(HTML2PS_DIR.'output._interface.class.php');
    require_once(HTML2PS_DIR.'output._generic.class.php');
    require_once(HTML2PS_DIR.'output._generic.pdf.class.php');
    require_once(HTML2PS_DIR.'output._generic.ps.class.php');
    require_once(HTML2PS_DIR.'output.pdflib.old.class.php');
    require_once(HTML2PS_DIR.'output.pdflib.1.6.class.php');
    require_once(HTML2PS_DIR.'output.fpdf.class.php');
    require_once(HTML2PS_DIR.'output.fastps.class.php');
    require_once(HTML2PS_DIR.'output.fastps.l2.class.php');
    require_once(HTML2PS_DIR.'output.png.class.php');
    // require_once(HTML2PS_DIR.'output.pcl.class.php');
    
    require_once(HTML2PS_DIR.'stubs.common.inc.php');
    require_once(HTML2PS_DIR.'media.layout.inc.php');
    require_once(HTML2PS_DIR.'box.php');
    require_once(HTML2PS_DIR.'box.generic.php');
    require_once(HTML2PS_DIR.'box.generic.formatted.php');
    require_once(HTML2PS_DIR.'box.container.php');
    require_once(HTML2PS_DIR.'box.generic.inline.php');
    require_once(HTML2PS_DIR.'box.inline.php');
    require_once(HTML2PS_DIR.'box.inline.control.php');
    require_once(HTML2PS_DIR.'font.class.php');
    require_once(HTML2PS_DIR.'font_factory.class.php');
    
    require_once(HTML2PS_DIR.'box.br.php');
    require_once(HTML2PS_DIR.'box.block.php');
    require_once(HTML2PS_DIR.'box.page.php');
    require_once(HTML2PS_DIR.'box.page.margin.class.php');
    require_once(HTML2PS_DIR.'box.body.php');
    require_once(HTML2PS_DIR.'box.block.inline.php');
    require_once(HTML2PS_DIR.'box.button.php');
    require_once(HTML2PS_DIR.'box.button.submit.php');
    require_once(HTML2PS_DIR.'box.button.reset.php');
    require_once(HTML2PS_DIR.'box.checkbutton.php');
    require_once(HTML2PS_DIR.'box.form.php');
    require_once(HTML2PS_DIR.'box.frame.php');
    require_once(HTML2PS_DIR.'box.iframe.php');
    require_once(HTML2PS_DIR.'box.input.text.php');
    require_once(HTML2PS_DIR.'box.input.textarea.php');
    require_once(HTML2PS_DIR.'box.input.password.php');
    require_once(HTML2PS_DIR.'box.legend.php');
    require_once(HTML2PS_DIR.'box.list-item.php');
    require_once(HTML2PS_DIR.'box.null.php');
    require_once(HTML2PS_DIR.'box.radiobutton.php');
    require_once(HTML2PS_DIR.'box.select.php');
    require_once(HTML2PS_DIR.'box.table.php');
    require_once(HTML2PS_DIR.'box.table.cell.php');
    require_once(HTML2PS_DIR.'box.table.cell.fake.php');
    require_once(HTML2PS_DIR.'box.table.row.php');
    require_once(HTML2PS_DIR.'box.table.section.php');
    
    require_once(HTML2PS_DIR.'box.text.php');
    require_once(HTML2PS_DIR.'box.text.string.php');
    require_once(HTML2PS_DIR.'box.field.pageno.php');
    require_once(HTML2PS_DIR.'box.field.pages.php');
    ........
    и так до 284й строки включительно...

    в самописном модуле к Drupal нашел сий шедевр

    kemerov4anin, 27 Апреля 2010

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

    +165

    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
    function month($n){
    	switch ($n) {
    		case  1: $m = "сiчнi"  ; break;
    		case  2: $m = "лютому"   ; break;    
    		case  3: $m = "березнi"; break;                                                            
    		case  4: $m = "квiтнi" ; break;
    		case  5: $m = "травнi" ; break;
    		case  6: $m = "червнi"  ; break;
    		case  7: $m = "липнi" ; break;
    		case  8: $m = "серпнi" ; break;
    		case  9: $m = "вереснi"; break;
    		case 10: $m = "жовтнi" ; break;
    		case 11: $m = "листопадi"; break;
    		case 12: $m = "груднi" ; break;
    	}
    return $m;
    }
    function month2($n)
    {
    switch ($n) 
    	{
    		case  1: $m = "сiчень"  ; break;
    		case  2: $m = "лютий"   ; break;    
    		case  3: $m = "березень"; break;                                                            
    		case  4: $m = "квiтень" ; break;
    		case  5: $m = "травень" ; break;
    		case  6: $m = "червень"  ; break;
    		case  7: $m = "липень" ; break;
    		case  8: $m = "серпень" ; break;
    		case  9: $m = "вересень"; break;
    		case 10: $m = "жовтень" ; break;
    		case 11: $m = "листопад"; break;
    		case 12: $m = "грудень" ; break;
    	}
    return $m;
    }
    /*... всяко разно ...*/
    if($month==1)$month="сiчнi";
    if($month==2)$month="лютому";
    if($month==3)$month="березнi";
    if($month==4)$month="квiтнi";
    if($month==5)$month="травнi";
    if($month==6)$month="червнi";
    if($month==7)$month="липнi";
    if($month==8)$month="серпнi";
    if($month==9)$month="вереснi";
    if($month==10)$month="жовтнi";
    if($month==11)$month="листопадi";
    if($month==12)$month="груднi";
    // дебажный комментарий тут был
    if($month1==1)$month1="сiчнi";
    if($month1==2)$month1="лютому";
    if($month1==3)$month1="березнi";
    if($month1==4)$month1="квiтнi";
    if($month1==5)$month1="травнi";
    if($month1==6)$month1="червнi";
    if($month1==7)$month1="липнi";
    if($month1==8)$month1="серпнi";
    if($month1==9)$month1="вереснi";
    if($month1==10)$month1="жовтнi";
    if($month1==11)$month1="листопадi";
    if($month1==12)$month1="груднi";
    /*...еще немного...*/
    if($month==1)$month1="сiчнi";
    if($month==2)$month1="лютому";
    if($month==3)$month1="березнi";
    if($month==4)$month1="квiтнi";
    if($month==5)$month1="травнi";
    if($month==6)$month1="червнi";
    if($month==7)$month1="липнi";
    if($month==8)$month1="серпнi";
    if($month==9)$month1="вереснi";
    if($month==10)$month1="жовтнi";
    if($month==11)$month1="листопадi";
    if($month==12)$month1="груднi";

    Werdn, 26 Апреля 2010

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

    +73.6

    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
    package psorter;
    
    import java.util.Vector;
    
    public class CArray extends Vector {
        String type="";
    
        /**
         * constructor of /array/
         * @param i set capacity increment
         */
        public CArray(int i) {
    	this.capacityIncrement=i;
        }
    
        /**
         * add object to end of vector with check of type
         * if type same as @ first added - add this object
         * safer than add
         * @param o object to add
         */
        public void append(Object o) {
    	if ( this.type.equals("") )
    	    this.type=o.getClass().toString();
    
    	if ( o.getClass().toString().equals(this.type) ){
    	    this.add(o);
    	} else {
    	    if ( this.type.contains("Float") && o.getClass().toString().contains("Integer") )
    		this.add( Float.valueOf(o.toString()) );
    
    	    if ( this.type.contains("Double") && o.getClass().toString().contains("Integer") )
    		this.add( Double.valueOf(o.toString()) );
    	    if ( this.type.contains("Double") && o.getClass().toString().contains("Float") )
    		this.add( Double.valueOf(o.toString()) );
    
    	    if ( this.type.contains("String") && o.getClass().toString().contains("Char") )
    		this.add( o.toString() );
    	}
        }
    
        public byte compare(int i, int j) throws Exception {
    	if (type.contains("Integer")) {
    	    if ((Integer) (this.get(i)) > (Integer) (this.get(j)))
    		return 1;
    	    if ((Integer) (this.get(i)) < (Integer) (this.get(j)))
    		return -1;
    	    return 0;
    	}
    
    	if (type.contains("Float")) {
    	    if ((Float) (this.get(i)) > (Float) (this.get(j)))
    		return 1;
    	    if ((Float) (this.get(i)) < (Float) (this.get(j)))
    		return -1;
    	    return 0;
    	}
    
    	if (type.contains("Double")) {
    	    if ((Double) (this.get(i)) > (Double) (this.get(j)))
    		return 1;
    	    if ((Double) (this.get(i)) < (Double) (this.get(j)))
    		return -1;
    	    return 0;
    	}
    
    	if (type.contains("Char")) {
    	    if ((Character) (this.get(i)) > (Character) (this.get(j)))
    		return 1;
    	    if ((Character) (this.get(i)) < (Character) (this.get(j)))
    		return -1;
    	    return 0;
    	}
    
    	if (type.contains("String")) {
    	    if ( this.get(i).toString().compareTo(this.get(j).toString())>0 )
    		return 1;
    	    if ( this.get(i).toString().compareTo(this.get(j).toString())<0 )
    		return -1;
    	    return 0;
    	}
    
    	return 0;
        }
    }

    сел писать 3 лабы естественно в последнюю ночь. начал в 11. эта была около 3х. самому потом стыдно было нести такое

    ilardm, 17 Апреля 2010

    Комментарии (15)
  5. JavaScript / Говнокод #3016

    +159.8

    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
    function AbstractControl_getProperty (propertyName) {
    	var targetElement = this.getTargetPath(propertyName);
    	var result = null;
    	
    	if (this.isTargetAttribute(propertyName)) {
    		eval("result = targetElement." + this.getAttributeName(propertyName));
    	} else {
    		var getter = this.getGetterName(propertyName);
    		var expression = "result = targetElement." + getter + "();";
    		eval(expression);
    	}
    	return result;
    }

    Вот так наши "суровые челябинские" программисты, не имеющие представления об интроспективности javascript-а, повсюду злоупотребляют eval-ом, усложняя отладку и понимание кода.
    По хорошему, вместо первого eval-а должно бы быть:
    result = targetElement[this.getAttributeName(propertyName)];
    а вместо второго:
    result = targetElement[this.getGetterName(propertyName)]();

    Andronix, 15 Апреля 2010

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

    +157.8

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    function dayTimestamp($t=null) {
    	if (!$t) $t = time();
    	$t = explode('-',date('Y-m-d',$t));
    	$t = mktime(0,0,0,$t[1],$t[2],$t[0]);
    	return $t;
    }

    TWINc, 12 Апреля 2010

    Комментарии (15)
  7. Pascal / Говнокод #2952

    +82.6

    1. 1
    if IntToStr(n) = '2' then

    чудо-программисты, еклмн

    timurrv, 07 Апреля 2010

    Комментарии (15)
  8. Java / Говнокод #2937

    +77.6

    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
    public void run()
        {
            try
            {            
                startExport();
            }
            catch (Throwable _t)
            {
                sendEvent(""+_t.getMessage(), true);
                logger.log(Level.SEVERE, charset, _t);
            }
            finally
            {
                System.gc();
            }
        }

    А ещё этот человек дёргает в одном сервисе gc каждые 4 секунды. Любые попытки ударить по рукам нарываются на отлуп: "так работает же!". Это не студент! Это реальный production код!

    konsoletyper, 06 Апреля 2010

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

    +149.2

    1. 1
    $is_use_newstyle = ($newstyle == 1) ? 1 : 0;

    shureg, 24 Марта 2010

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

    +170.9

    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
    <?php
     $mounths["January"]="01";
     $mounths["February"]="02";
     $mounths["March"]="03";
     $mounths["April"]="04";
     $mounths["May"]="05";
     $mounths["June"]="06";
     $mounths["July"]="07";
     $mounths["August"]="08";
     $mounths["September"]="09";
     $mounths["October"]=10;
     $mounths["November"]=11;
     $mounths["December"]=12;
    
     $m=date("F");
     $d=date("d");
     $Y=date("Y");
     $datetime=date("Y")."-".$mounths[$m]."-".date("d")." ".date("H").":".date("i").":".date("s");
     $date=date("Y")."-".$mounths[$m]."-".date("d");
    ?>

    Ээээ, чо? Нарыл в проекте. Отпаиваюсь чаем.

    azzz, 11 Марта 2010

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

    +170.2

    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
    function is_ie8(){
    var ua = navigator.userAgent.toLowerCase();
    var is_opera = ua.indexOf("opera") != -1;
    var is_opera5 = ua.indexOf("opera/5") != -1 || ua.indexOf("opera 5") != -1;
    var is_opera6 = ua.indexOf("opera/6") != -1 || ua.indexOf("opera 6") != -1;
    var is_opera7 = ua.indexOf("opera/7") != -1 || ua.indexOf("opera 7") != -1;
    var is_opera8 = ua.indexOf("opera/8") != -1 || ua.indexOf("opera 8") != -1;
    var is_opera9 = ua.indexOf("opera/9") != -1 || ua.indexOf("opera 9") != -1;
    var is_opera95 = ua.indexOf("opera/9.5") != -1 || ua.indexOf("opera 9.5") != -1;
    var is_opera96 = ua.indexOf("opera/9.6") != -1 || ua.indexOf("opera 9.6") != -1;
    var is_opera95up = is_opera95 || is_opera96;
    
    var is_ff = ua.indexOf("firefox") != -1 && !is_opera;
    var is_gecko = ua.indexOf('gecko') != -1 && !is_opera;
    
    var is_chrome = ua.indexOf('chrome') != -1;
    var is_safari = ua.indexOf('applewebkit') != -1 && !is_chrome;
    
        var is_ie = ua.indexOf("msie") != -1  && !is_opera;
        var is_ie4 = is_ie && ua.indexOf("msie 4") != -1;
        var is_ie5 = is_ie && ua.indexOf("msie 5") != -1;
        var is_ie50 = is_ie && ua.indexOf("msie 5.0") != -1;
        var is_ie55 = is_ie && ua.indexOf("msie 5.5") != -1;
        var is_ie5up = is_ie && !is_ie4;
        var is_ie6 = is_ie && ua.indexOf("msie 6") != -1;
        var is_ie6up = is_ie5up && !is_ie55 && !is_ie5;
        var is_ie7 = is_ie && ua.indexOf("msie 7") != -1;
        var is_ie7up = is_ie6up && !is_ie6;
        var is_ie7down = is_ie7 || is_ie6 || is_ie5 || is_ie4;
    
        var is_ie8 = is_ie && ua.indexOf("msie 8") != -1;
        var is_ie8up = is_ie8 && !is_ie7down;
        if (is_ie && !is_ie8up && !is_ie8) {
            return true;
        }else return false;
    }

    Детектим IE8

    deraider, 06 Марта 2010

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