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

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

    +7

    1. 1
    http://miryanka.ru/frame.js

    Интернет-магазин православной одежды Мирянка. Православный скрипт и конструкции вида
    function ПреобразоватьМесяцИзСХислаВСтроку(Месяц)

    loki90, 24 Марта 2016

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

    −1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    ..........................
    //ДА ЧТО ЗА ЧЕЛОВЕК... КТО ЭТОТ КОД ПИСАЛ?! ПУСТЬ ОН/ОНА БОЛЬШЕ НИКОГДА НЕ ПИШЕТ КОД, А ЧИСТИТ КАЛОШИ... 2К++ запросов - это что за нах?!
    // если рефакторить гавно, получится гавно, но запахом получше. Гавна есть запах ли хорош?
    if(!$smarty->is_cached('output.tpl', $template_key)){
        $xml='<document>';
    ..........................

    Нашел на одном сайте, который делали очень давно и самые разные "программисты" )

    AndreDev, 21 Октября 2015

    Комментарии (53)
  4. Куча / Говнокод #18687

    +1

    1. 1
    [\s\S]+?

    3_14dar, 08 Сентября 2015

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

    +5

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    float data1[16];
    float data2[16];
    
    for (unsigned i = 0; i < 4; ++i)
        for (unsigned j = 0; j < 4; ++j)
            *(data1 + 4 * i + j) = *(data2 + 4 * i + j);

    jangolare, 26 Августа 2015

    Комментарии (53)
  6. SQL / Говнокод #18252

    −161

    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
    CREATE TABLE [dbo].[Images](
    	[id] [int] IDENTITY(1,1) NOT NULL,
    	[category] [int] NOT NULL,
    	[tag] [nvarchar](16) NOT NULL,
    	[description] [nvarchar](128) NOT NULL,
    	[comment] [nvarchar](1024) NULL,
    	[code01] [nvarchar](max) NULL,
    	[code02] [nvarchar](max) NULL,
    	[code03] [nvarchar](max) NULL,
    	[code04] [nvarchar](max) NULL,
    	[code05] [nvarchar](max) NULL,
    	[code06] [nvarchar](max) NULL,
    	[code07] [nvarchar](max) NULL,
    	[code08] [nvarchar](max) NULL,
    	[code09] [nvarchar](max) NULL,
    	[code10] [nvarchar](max) NULL,
    	[code]  AS (rtrim(((((((((((((((((((((((((((((rtrim(replace(replace(coalesce([code01],''),char((13)),' '),char((10)),' '))+char((13)))+char((10)))+rtrim(replace(replace(coalesce([code02],''),char((13)),' '),char((10)),' ')))+char((13)))+char((10)))+rtrim(replace(replace(coalesce([code03],''),char((13)),' '),char((10)),' ')))+char((13)))+char((10)))+rtrim(replace(replace(coalesce([code04],''),char((13)),' '),char((10)),' ')))+char((13)))+char((10)))+rtrim(replace(replace(coalesce([code05],''),char((13)),' '),char((10)),' ')))+char((13)))+char((10)))+rtrim(replace(replace(coalesce([code06],''),char((13)),' '),char((10)),' ')))+char((13)))+char((10)))+rtrim(replace(replace(coalesce([code07],''),char((13)),' '),char((10)),' ')))+char((13)))+char((10)))+rtrim(replace(replace(coalesce([code08],''),char((13)),' '),char((10)),' ')))+char((13)))+char((10)))+rtrim(replace(replace(coalesce([code09],''),char((13)),' '),char((10)),' ')))+char((13)))+char((10)))+rtrim(replace(replace(coalesce([code10],''),char((13)),' '),char((10)),' ')))+char((13)))+char((10))))
    )

    10 нормальная форма (_*_)

    drup, 28 Мая 2015

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

    +153

    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
    if(!empty($this->aActions))
    			$sMenuItems = htmlspecialcharsbx(CAdminPopup::PhpToJavaScript($this->aActions));
    ?>
    <tr class="adm-list-table-row<?=(isset($this->aFeatures["footer"]) && $this->aFeatures["footer"] == true? ' footer':'')?><?=$this->bEditMode?' adm-table-row-active' : ''?>"<?=($sMenuItems <> ""? ' oncontextmenu="return '.$sMenuItems.';"':'');?><?=($sDefAction <> ""? ' ondblclick="'.$sDefAction.'"'.(!empty($sDefTitle)? ' title="'.GetMessage("admin_lib_list_double_click").' '.$sDefTitle.'"':''):'')?>>
    <?
    
    		if(count($this->pList->arActions)>0 || $this->pList->bCanBeEdited):
    			$check_id = RandString(5);
    ?>
    	<td class="adm-list-table-cell adm-list-table-checkbox adm-list-table-checkbox-hover<?=$this->bReadOnly? ' adm-list-table-checkbox-disabled':''?>"><input type="checkbox" class="adm-checkbox adm-designed-checkbox" name="ID[]" id="<?=$this->table_id."_".$this->id."_".$check_id;?>" value="<?=$this->id?>" autocomplete="off" title="<?=GetMessage("admin_lib_list_check")?>"<?=$this->bReadOnly? ' disabled="disabled"':''?><?=$this->bEditMode ? ' checked="checked" disabled="disabled"' : ''?> /><label class="adm-designed-checkbox-label adm-checkbox" for="<?=$this->table_id."_".$this->id."_".$check_id;?>"></label></td>
    <?
    		endif;
    
    		if($this->pList->bShowActions):
    			if(!empty($this->aActions)):
    ?>
    	<td class="adm-list-table-cell adm-list-table-popup-block" onclick="BX.adminList.ShowMenu(this.firstChild, this.parentNode.oncontextmenu(), this.parentNode);"><div class="adm-list-table-popup" title="<?=GetMessage("admin_lib_list_actions_title")?>"></div></td>
    <?
    			else:
    ?>
    	<td class="adm-list-table-cell"></td>
    <?
    			endif;
    		endif;

    bitrix

    Лапша PHP кода, с подливкой из HTML. Присутствуют специи из альтернативного синтаксиса оператора if для шаблонов

    memclutter, 29 Августа 2014

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

    +156

    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
    $query_result = mysql_query("SELECT parking FROM `cat_info` WHERE is_sold = 0");
       
            $numpark = array();
            $numpark[2]=0;
            $numpark[3]=0;
            $numpark[5]=0;
            $numpark[6]=0;
        if($query_result)
      {
         
          while ($row = mysql_fetch_array($query_result)) 
        {
            switch ($row["parking"]){
           
            case 2:
            $numpark[2]++;
            break;
            case 3:
            $numpark[3]++;
            break;
            case 5:
            $numpark[5]++;
            break;
            case 6:
            $numpark[6]++;
            break;
            }
        }
      }

    Этот код считает количество записей в таблице, в зависимости от числа в колонке parking.

    bashtannik, 05 Августа 2014

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

    +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
    <?php
    	$month = date("m", strtotime($model->order->created));
    	
    	if($month==01){
    		$month = "января";
    	}elseif($month==02){
    		$month = "февраля";
    	}elseif($month==03){
    		$month = "марта";
    	}elseif($month==04){
    		$month = "апреля";
    	}elseif($month==05){
    		$month = "мая";
    	}elseif($month==06){
    		$month = "июня";
    	}elseif($month==07){
    		$month = "июля";
    	}elseif($month==08){
    		$month = "августа";
    	}elseif($month==09){
    		$month = "сентября";
    	}elseif($month==10){
    		$month = "октября";
    	}elseif($month==11){
    		$month = "ноября";
    	}elseif($month==12){
    		$month = "декабря";
    	}
    ?>

    Это facepalm!

    jonasas, 08 Апреля 2014

    Комментарии (53)
  10. JavaScript / Говнокод #15656

    +140

    1. 1
    $('img.avatar').attr("src", "http://upload.wikimedia.org/wikipedia/commons/a/a4/Human_penis_2_by_Yiyi1394.jpg")

    = http://prntscr.com/36l35i

    gost, 03 Апреля 2014

    Комментарии (53)
  11. C++ / Говнокод #15383

    +27

    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
    95. 95
    96. 96
    97. 97
    98. 98
    99. 99
    #include <iostream>
    #include <iterator>
    #include <algorithm>
    #include <vector>
    #include <utility>
    #include <sstream>
    #include <assert.h>
    using namespace std;
    
    struct PeriodDescription{
    	size_t length, repeat_amount, last_items_amount;
    	/*friend ostream& operator<<(ostream& os, const PeriodDescription& s){
    		os<<" (PeriodDescription){"<<s.length<<", "<<s.repeat_amount<<", "<<s.last_items_amount<<"} ";
    		return os;
    	}*/
    };
    
    /*template<class C>
    string co(C&& c){
    	ostringstream r;
    	r<<" (C) {";
    	copy(c.begin(), c.end(), ostream_iterator<typename C::value_type>(r, ", "));
    	r<<"}; ";
    	return move(r.str());
    }*/
    
    vector<PeriodDescription> find_repeat_sequences_since_begin(const string& sequence){
    	vector<PeriodDescription> result;
    	if(sequence.empty())
    		return result;
    	auto position_at_last_period=sequence.begin();
    	const char first_item = *position_at_last_period;
    	const auto after_last=sequence.end();
    	auto position_at_current_period = position_at_last_period;
    	while(true){
    		position_at_last_period=sequence.begin();
    		position_at_current_period = find(next(position_at_current_period), after_last, first_item);
    		PeriodDescription new_period {size_t(distance(position_at_last_period, position_at_current_period)), 1, 0};
    		while(position_at_current_period!=after_last && *position_at_last_period==*position_at_current_period){
    			++position_at_last_period; ++position_at_current_period;
    			if(++new_period.last_items_amount>=new_period.length){
    				new_period.last_items_amount = 0;
    				++new_period.repeat_amount;
    			}
    		}
    		if(new_period.repeat_amount==1 && new_period.last_items_amount==0)
    			return result;
    		result.push_back(new_period);
    		if(position_at_current_period==after_last)
    			return result;
    	}
    }
    
    vector<size_t> generate_FSM_failJumpIndices(const vector<PeriodDescription>& periodDescriptions, const size_t stringLength){
    	vector<size_t> r(stringLength+1);
    	for(const auto& pd : periodDescriptions){
    		for(size_t periodIndex=1; periodIndex<pd.repeat_amount; ++periodIndex)
    			for(size_t indexAtPeriod=0; indexAtPeriod<pd.length; ++indexAtPeriod)
    				r[(periodIndex*pd.length)+indexAtPeriod]=(periodIndex-1)*pd.length + indexAtPeriod;
    		for(size_t indexAtAfterPeriods=0; indexAtAfterPeriods<pd.last_items_amount; ++indexAtAfterPeriods)
    			r[pd.length*pd.repeat_amount+indexAtAfterPeriods]=pd.length*(pd.repeat_amount-1)+indexAtAfterPeriods;
    	}
    	return r;
    }
    
    vector<size_t> make_FSM_failJumpIndices(const string& sequence){
    	return generate_FSM_failJumpIndices(find_repeat_sequences_since_begin(sequence), sequence.size());
    }
    
    class FSM_for_find_equal_ranges{
    	size_t state;
    	vector<size_t> failJumpIndices;
    	string sequence;
    	string::const_iterator find_next(string::const_iterator checkPosition, const string::const_iterator last){
    		struct atReturn{
    			size_t& state;
    			~atReturn(){state = 0;}
    		}nullify{state};
    		if(checkPosition==last)
    			return last;
    		if(sequence.empty())
    			return next(checkPosition);
    		if(size_t(distance(checkPosition, last))<sequence.size())
    			return last;
    		while(true){
    			if(checkPosition==last)
    				return last;
    			if(*checkPosition==sequence[state])
    				++state;
    			else
    				state=failJumpIndices[state];
    			++checkPosition;
    			if(state>=sequence.size())
    				return prev(checkPosition, sequence.size());
    		}
    	}
    public:
    	template<class T>
    	FSM_for_find_equal_ranges(T&& sequence):

    Очередное собеседование. Пригласили на должность дельфина. Но оп отказался проходить собеседование на дельфи.
    http://ideone.com/zp5CRb

    USB, 07 Марта 2014

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