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

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

    +174

    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
    /*
        Собтсвенность ZeroParking,
        скрипт не подлежит частичному или полному 
        копированию, распрастранению, модификации.
    
        Moscow, 2010.
    */
    $doc = document;
    $id = function (r) { return $doc.getElementById(r) };
    $tag = function (r) { return $doc.getElementsByTagName(r); }; 
    $class = function (clsName) {
       ........ // получает все дом-объекты с классом clsName.
    }
    $create = function (r) { return $doc.createElement(r); };
    
    function load(url) {
    .... // подгружает js по url
    }
    $load = load;
    
    function GET(){
    .... // парсит строку запроса
    }
    $get = GET();

    говнокод с копирайтом!!!!! чей-то говнолиб.
    10 строка не везде работать будет.
    за точками ничего интересного, но поверхностно можно определить запах.
    там неудачная пародия на JQuery.
    http://0pk.ru/f/ru/0pk/lib.js
    надеюсь меня не посадят за нарушение авторских прав:)

    Alfred, 23 Августа 2010

    Комментарии (17)
  3. JavaScript / Говнокод #4016

    +151

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    <div id="stat" class="list_menu" onclick="
                            if ($('#stat_sub').is(':hidden')){
                                $('#stat_sub').slideDown('slow');
                            } else {
                                $('#stat_sub').slideUp('slow');
                            }">Статистика</div>

    Тот же автор, что и #4015

    scalar4eblo4no, 17 Августа 2010

    Комментарии (17)
  4. PHP / Говнокод #3806

    +158

    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
    <div class="item" style="padding-bottom:60px">
    	<a class="no-border" href="catalogue/?SECTION_ID=327&arrFilter_pf[PRODUCER]=<?=urlencode('Producer(Турция)')?>&arrFilter_pf[TOPLIVO]=<?=urlencode("Дизельное")?>&set_filter=Y"><img src="/bitrix/templates/producer/i/items/dis-generator.jpg" alt="Дизельные генераторы" title="Дизельные генераторы"/></a>
    	<a href="catalogue/?SECTION_ID=327&arrFilter_pf[PRODUCER]=<?=urlencode('Producer(Турция)')?>&arrFilter_pf[TOPLIVO]=<?=urlencode("Дизельное")?>&set_filter=Y">Дизельные генераторы</a>
    </div>
    <div class="item">
    	<a class="no-border" href="catalogue/?SECTION_ID=327&arrFilter_pf[PRODUCER]=<?=urlencode('Producer(Турция)')?>&arrFilter_pf[TOPLIVO]=<?=urlencode('Бензин А-92(95)')?>&set_filter=Y"><img src="/_producer/i/items/oil-generator.jpg" alt="Бензиновые генераторы" title="Бензиновые генераторы"/></a>
    	<a href="catalogue/?SECTION_ID=327&arrFilter_pf[PRODUCER]=<?=urlencode('Producer(Турция)')?>&arrFilter_pf[TOPLIVO]=<?=urlencode('Бензин А-92(95)')?>&set_filter=Y">Бензиновые генераторы</a>
    </div>
    <div class="item">
    	<a class="no-border" href="catalogue/?SECTION_ID=333"><img src="/bitrix/templates/producer/i/items/generator.jpg" alt="Газовые генераторы" title="Газовые генераторы"/></a>
    	<a href="catalogue/?SECTION_ID=333">Газовые генераторы</a>
    </div>
    <div class="item">
    	<a class="no-border" href="catalogue/?SECTION_ID=326"><img src="/bitrix/templates/producer/i/items/container.jpg" alt="Контейнеры" title="Контейнеры"/></a>
    	<a href="catalogue/?SECTION_ID=326">Контейнеры</a>
    </div>	
    <?
    // тут куча кода
    ?>
    <div class="item" style="padding-top:0px; margin-top:-15px">
    	<? if ($arrFilter_pf[TOPLIVO] != 'Дизельное') { ?><a class="no-border" href="?SECTION_ID=327&arrFilter_pf[PRODUCER]=<?=urlencode('Producer(Турция)')?>&arrFilter_pf[TOPLIVO]=<?=urlencode("Дизельное")?>&set_filter=Y"><? } ?><div class="product_div"><img src="/bitrix/templates/producer/i/items/dis-generator.jpg" alt="Дизельные генераторы" title="Дизельные генераторы"/></div><? if ($arrFilter_pf[TOPLIVO] != 'Дизельное') { ?></a>
    	<a href="?SECTION_ID=327&arrFilter_pf[PRODUCER]=<?=urlencode("Producer(Турция)")?>&arrFilter_pf[TOPLIVO]=<?=urlencode("Дизельное")?>&set_filter=Y"><? } ?>Дизельные генераторы<? if ($arrFilter_pf[TOPLIVO] != 'Дизельное') { ?></a><? } ?>
    </div>
    <div class="item" style="padding-top:0px; margin-top:-15px">
    	<? if ($arrFilter_pf[TOPLIVO] != 'Бензин А-92(95)') { ?><a class="no-border" href="?SECTION_ID=327&arrFilter_pf[PRODUCER]=<?=urlencode('Producer(Турция)')?>&arrFilter_pf[TOPLIVO]=<?=urlencode('Бензин А-92(95)')?>&set_filter=Y"><? } ?><div class="product_div"><img src="/bitrix/templates/producer/i/items/oil-generator.jpg" alt="Бензиновые генераторы" title="Бензиновые генераторы"/></div><? if ($arrFilter_pf[TOPLIVO] != 'Бензин А-92(95)') { ?></a>
    	<a href="?SECTION_ID=327&arrFilter_pf[PRODUCER]=<?=urlencode("Producer(Турция)")?>&arrFilter_pf[TOPLIVO]=<?=urlencode("Бензин А-92(95)")?>&set_filter=Y"><? } ?>Бензиновые генераторы<? if ($arrFilter_pf[TOPLIVO] != 'Бензин А-92(95)') { ?></a><? } ?>
    </div>
    <div class="item" style="padding-top:0px; margin-top:-15px">
    	<? if ($_GET['SECTION_ID'] != '333') { ?><a class="no-border" href="?SECTION_ID=333"><? } ?><div class="product_div"><img src="/bitrix/templates/producer/i/items/generator.jpg" alt="Газовые генераторы" title="Газовые генераторы"/></div><? if ($_GET['SECTION_ID'] != '333') { ?></a>
    	<a href="?SECTION_ID=333"><? } ?>Газовые генераторы<? if ($_GET['SECTION_ID'] != '333') { ?></a><? } ?>
    </div>
    <div class="item" style="padding-top:0px; margin-top:-15px">
    	<? if ($_GET['SECTION_ID'] != '326') { ?><a class="no-border" href="?SECTION_ID=326"><? } ?><div class="product_div"><img src="/bitrix/templates/producer/i/items/container.jpg" alt="Контейнеры" title="Контейнеры"/></div><? if ($_GET['SECTION_ID'] != '326') { ?></a>
    	<a href="?SECTION_ID=326"><? } ?>Контейнеры<? if ($_GET['SECTION_ID'] != '326') { ?></a><? } ?>
    </div>

    Это часть шаблона сайта, сделанного на битриксе. Хотя битрикс тут и не нужен, автор и без него справился бы с задачей. Без него было бы даже проще :)))

    Название сайта я заменил в коде на "Producer", не хочу уже позорить. Жаль что весь код не влез, там в таком же духе дальше.

    alex322, 28 Июля 2010

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

    +171

    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
    function TransInfo($d){
        if(isset($_REQUEST[$d])){
            switch($d){
                case is_integer($d):
                    $p = "/[^0-9$]/";
                break;
                case is_string($d):
                    $p = "/[^a-z$]/";
                break;
            }
            $d = trim(isset($_REQUEST[$d]) ? $_REQUEST[$d] : $_REQUEST[$d]);
            if (preg_match($p, $d)) { Header("Location: index.php");    exit; }
        }else{
            echo "Нет данных";
        }
    }

    как прокомментировал её автор: "небольшая функция по приему данных для get и post"

    administation, 11 Июля 2010

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

    +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
    $(document).ready(function()
    	{
    	var flag=true;
    	$("#reg").click(function()
    		{
    			if(flag==true)
    			{
    				$("#reg2").slideUp();
    				flag=!flag;
    			}
    			else
    			{
    				$("#reg2").slideDown();
    				flag=!flag;
    			}
    	});
    });

    Новейшие технологии позволяют показывать элемент, если он скрыть и скрывать, если показан. Найдено здесь http://javascript.ru/forum/62011-post4.html

    eval, 03 Июля 2010

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

    +120

    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
    protected void GridView1_PreRender(object sender, EventArgs e)
        {         
             System.Drawing.Color OddGridColor = new System.Drawing.Color();
             OddGridColor = System.Drawing.Color.FromArgb(0xD3, 0xDE, 0xEF);
             System.Drawing.Color EvenGridColor = new System.Drawing.Color();
             EvenGridColor = System.Drawing.Color.FromArgb(0xEC, 0xE9, 0xD8);
    
                for (int i = 0; i < GridView1.Rows.Count; i++)
                {
                      if (i % 2 == 1)
                      {
                          GridView1.Rows[i].BackColor = OddGridColor;
                      }
                      else
                      {
                          GridView1.Rows[i].BackColor = EvenGridColor;
                      }
                 }
        }

    the way of change GridView color through one ...
    Why do not use <AlternatingRowStyle> ?!!

    O_O, 23 Июня 2010

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

    +164

    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
    list::list(FILE*f,FILE*f1){
        first=(starosta*)new student;
        rea=first;
        int i=0,j;
        for(j=0;j<5;j++){
            if (i) {
                rea->next=(starosta*)new student;
                rea=rea->next;
            }
            i=1;
            fscanf(f,"%d",&(rea->num));
            fscanf(f,"%s",rea->fam);
            fscanf(f,"%d",&(rea->stip));
            rea->flag=0;
        }
        cur=(starosta*)rea;
        for(j=0;j<3;j++){
            cur->next=new starosta;
            cur=(starosta*)cur->next;
            cur->flag=1;
            fscanf(f1,"%d",&(cur->num));
            fscanf(f1,"%s",cur->fam);
            fscanf(f1,"%d",&(cur->stip));
            fscanf(f1,"%d",&(cur->kolvo));
            cur->next=NULL;
        }
    }

    классный конструктор... тут много приколов

    tony, 22 Июня 2010

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

    +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
    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
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    // ==UserScript==
    // @name           govnokod.ru.user.js
    // @description    highlight for new comments
    // @author         [email protected]
    // @include        http://govnokod.ru/*
    // ==/UserScript==
    
    if(!jQuery.cookie)
    jQuery.cookie = function(name, value, options) {
        if (typeof value != 'undefined') { // name and value given, set cookie
            options = options || {};
            if (value === null) {
                value = '';
                options.expires = -1;
            }
            var expires = '';
            if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
                var date;
                if (typeof options.expires == 'number') {
                    date = new Date();
                    date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
                } else {
                    date = options.expires;
                }
                expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
            }
            var path = options.path ? '; path=' + (options.path) : '';
            var domain = options.domain ? '; domain=' + (options.domain) : '';
            var secure = options.secure ? '; secure' : '';
            document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
        } else { // only name given, get cookie
            var cookieValue = null;
            if (document.cookie && document.cookie != '') {
                var cookies = document.cookie.split(';');
                for (var i = 0; i < cookies.length; i++) {
                    var cookie = jQuery.trim(cookies[i]);
                    // Does this cookie string begin with the name we want?
                    if (cookie.substring(0, name.length + 1) == (name + '=')) {
                        cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                        break;
                    }
                }
            }
            return cookieValue;
        }
    };
    
    var there_href = document.location.href.match(/govnokod\.ru\/(\d+)/);
    if ( there_href ) // in topic
    	$(document).ready(function() {
    		var govnokod_n = there_href[1];
    		var cookiename = 'gk'+govnokod_n
    		var lastvisit = new Date(parseInt($.cookie(cookiename)));
    		var now = new Date();
    		var comments = $(".hcomment abbr").filter(function(index,elem) {
    			var date=new Date(elem.title.replace("T"," ").replace(/\+(\d\d):(\d\d)$/," GMT+$1$2"));
    			return date>lastvisit;
    		});
    		for (var i=0;i<comments.length;i++)
    		{
    			var elem = comments[i];
    			var header = elem.parentElement;
    			var block = elem.parentElement.parentElement;
    			block.style.background = '#FACE8D';
    			var anchor = document.createElement("a");
    			anchor.setAttribute('name','new_'+i);
    			block.insertBefore(anchor,block.firstChild);
    			
    			var prevlink = document.createElement("a");
    			if (i!=0)
    				prevlink.setAttribute('href','#new_'+(i-1));
    			prevlink.appendChild(document.createTextNode('⟵'));
    			header.insertBefore(prevlink,elem.nextSibiling);
    			
    			header.insertBefore(document.createTextNode(' '),elem.nextSibiling);
    			
    			var nextlink = document.createElement("a");
    			if (i!=comments.length-1)
    				nextlink.setAttribute('href','#new_'+(i+1));
    			nextlink.appendChild(document.createTextNode('⟶'));
    			header.insertBefore(nextlink,elem.nextSibiling);
    
    		}
    		
    		var new_comments_count = document.createElement("a");
    		if (comments.length)
    			new_comments_count.setAttribute('href','#new_0');
    		new_comments_count.appendChild(document.createTextNode(''+comments.length+' новых'));
    		var comments_count = $(".enrty-comments-count");
    		comments_count.text(comments_count.text().replace(/\)$/,', '));
    		comments_count.append(new_comments_count);
    		comments_count.append(')');
    		$.cookie(cookiename, now.valueOf(), { 'expires': 3 }); //помним, что имеется ограничение на размер куков.
    	});

    Наговнокодил подсвечивалку новых комментариев для говногод.ру. Смесь из обычного DOM и тутошнего jQuery. Сохранить как govnokod.ru.user.js. Тестировал только в опере.

    legolegs, 06 Июня 2010

    Комментарии (17)
  10. Java / Говнокод #3343

    +86

    1. 1
    2. 2
    int memory = (int)Runtime.getRuntime().freeMemory();
    if (memory < 163840) bydlophone = true;

    Встретил в коде одного мидлета.

    odd, 28 Мая 2010

    Комментарии (17)
  11. Java / Говнокод #3336

    +144

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    if (digitsStr.length() < 7) {
    	return "+" + digitsStr.substring(0, 1) + "-" + digitsStr.substring(1, 2) + "-" + digitsStr.substring(2);
    } else {
    	return "+" + digitsStr.substring(0, 3) + "-" + digitsStr.substring(3, 6) + "-" + digitsStr.substring(6);
    }

    свежий кал коллеги

    Lure Of Chaos, 27 Мая 2010

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