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

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

    +122

    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
    else
                    {
                        if ((textBox1.Text == textBox2.Text) | (textBox1.Text == textBox3.Text) | (textBox1.Text == textBox4.Text) | (textBox1.Text == textBox7.Text)) textBox1.ForeColor = Color.Red; else textBox1.ForeColor = Color.Black;
                        if ((textBox2.Text == textBox1.Text) | (textBox2.Text == textBox3.Text) | (textBox2.Text == textBox5.Text) | (textBox2.Text == textBox8.Text)) textBox2.ForeColor = Color.Red; else textBox2.ForeColor = Color.Black;
                        if ((textBox3.Text == textBox1.Text) | (textBox3.Text == textBox2.Text) | (textBox3.Text == textBox6.Text) | (textBox3.Text == textBox9.Text)) textBox3.ForeColor = Color.Red; else textBox3.ForeColor = Color.Black;
                        if ((textBox4.Text == textBox5.Text) | (textBox4.Text == textBox6.Text) | (textBox4.Text == textBox1.Text) | (textBox4.Text == textBox7.Text)) textBox4.ForeColor = Color.Red; else textBox4.ForeColor = Color.Black;
                        if ((textBox5.Text == textBox4.Text) | (textBox5.Text == textBox6.Text) | (textBox5.Text == textBox2.Text) | (textBox5.Text == textBox8.Text)) textBox5.ForeColor = Color.Red; else textBox5.ForeColor = Color.Black;
                        if ((textBox6.Text == textBox4.Text) | (textBox6.Text == textBox5.Text) | (textBox6.Text == textBox3.Text) | (textBox6.Text == textBox9.Text)) textBox6.ForeColor = Color.Red; else textBox6.ForeColor = Color.Black;
                        if ((textBox7.Text == textBox8.Text) | (textBox7.Text == textBox9.Text) | (textBox7.Text == textBox1.Text) | (textBox7.Text == textBox4.Text)) textBox7.ForeColor = Color.Red; else textBox7.ForeColor = Color.Black;
                        if ((textBox8.Text == textBox7.Text) | (textBox8.Text == textBox9.Text) | (textBox8.Text == textBox2.Text) | (textBox8.Text == textBox5.Text)) textBox8.ForeColor = Color.Red; else textBox8.ForeColor = Color.Black;
                        if ((textBox9.Text == textBox7.Text) | (textBox9.Text == textBox8.Text) | (textBox9.Text == textBox3.Text) | (textBox9.Text == textBox6.Text)) textBox9.ForeColor = Color.Red; else textBox9.ForeColor = Color.Black;
                        if ((textBox1.Text == textBox2.Text) | (textBox1.Text == textBox3.Text) | (textBox1.Text == textBox4.Text) | (textBox1.Text == textBox7.Text) |
                            (textBox2.Text == textBox1.Text) | (textBox2.Text == textBox3.Text) | (textBox2.Text == textBox5.Text) | (textBox2.Text == textBox8.Text) |
                            (textBox3.Text == textBox1.Text) | (textBox3.Text == textBox2.Text) | (textBox3.Text == textBox6.Text) | (textBox3.Text == textBox9.Text) |
                            (textBox4.Text == textBox5.Text) | (textBox4.Text == textBox6.Text) | (textBox4.Text == textBox1.Text) | (textBox4.Text == textBox7.Text) |
                            (textBox5.Text == textBox4.Text) | (textBox5.Text == textBox6.Text) | (textBox5.Text == textBox2.Text) | (textBox5.Text == textBox8.Text) |
                            (textBox6.Text == textBox4.Text) | (textBox6.Text == textBox5.Text) | (textBox6.Text == textBox3.Text) | (textBox6.Text == textBox9.Text) |
                            (textBox7.Text == textBox8.Text) | (textBox7.Text == textBox9.Text) | (textBox7.Text == textBox1.Text) | (textBox7.Text == textBox4.Text) |
                            (textBox8.Text == textBox7.Text) | (textBox8.Text == textBox9.Text) | (textBox8.Text == textBox2.Text) | (textBox8.Text == textBox5.Text) |
                            (textBox9.Text == textBox7.Text) | (textBox9.Text == textBox8.Text) | (textBox9.Text == textBox3.Text) | (textBox9.Text == textBox6.Text)) ;
                        else
                        {
                            label1.Visible = true;
                            label2.Visible = true;
                        }

    Удивлению нет границ! Полная версия: http://pastebin.com/S2getyHn

    P4R4, 22 Марта 2012

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

    +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
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    function return_report($new,$do) {
     $dosec = $do - $new;
     $days = floor($dosec / 86400);
     $hour = floor(($dosec - ($days*86400))/3600);
     $min = floor(($dosec - ($days*86400) - ($hour*3600))/60);
     $sec = floor(($dosec - ($days*86400) - ($hour*3600) - ($min*60)));
     switch(substr($days, -2)) { // какое выводить слово
     case 1: case 21: $ost = 'остался '; break;
     default: $ost = 'осталось '; break;
     }
     switch(substr($days, -2)) { // вывод дней
     case 1: case 21: case 31: case 41: $d=' день '; break;
     case 2: case 3: case 4: case 22: case 23: case 24: case 32: case 33: case 34: case 42: case 43: case 44: $d=' дня '; break;
     default: $d=' дней '; 
     }
     switch(substr($hour, -2)) { // вывод часов
     case 1: case 21: $h=' час '; break;
     case 2: case 3: case 4: case 22: case 23: case 24: $h=' часа '; break;
     default: $h=' часов '; 
     }
     switch(substr($min, -2)) { // вывод минут
     case 1: case 21: case 31: case 41: case 51: $m=' минута '; break;
     case 2: case 3: case 4: case 22: case 23: case 24: case 32: case 33: case 34: case 42: case 43: case 44: case 52: case 53: case 54: $m=' минуты '; break;
     default:$m=' минут ';
     }
     switch(substr($sec, -2)) { // вывод секунд
     case 1: case 21: case 31: case 41: case 51: $s=' секунда'; break;
     case 2: case 3: case 4: case 22: case 23: case 24: case 32: case 33: case 34: case 42: case 43: case 44: case 52: case 53: case 54: $s=' секунды'; break;
     default:$s=' секунд';
     }
     if ($dosec > 0) {
     $period = $ost;
     if ($days > 0) $period .= '<b>'.$days.'</b>'
    .$d;
     if ($hour > 0) $period .= '<b>'.$hour.'</b>'
    .$h;
     if ($min > 0) $period .= '<b>'.$min.'</b>'.
    $m;
     if ($sec > 0) $period .= '<b>'.$sec.'</b>'.
    $s;
     return $period;
     }
    return false;
    }

    Человек пытался сделать вывод времени, прошедшего с определенного момента *FACEPALM*

    pro100shureg, 22 Марта 2012

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

    +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
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    <?php
    class User
    {
       protected $_user_id;
       protected $_user_email;
       protected $_user_password;
     
       public function __construct($user_id)
       {
          $user_record = self::_getUserRecord($user_id);
          $this->_user_id = $user_record['id'];
          $this->_user_email = $user_record['email'];
          $this->_user_password = $user_record['password'];
       }
     
       public function __get($value) {}
       public function __set($name, $value) {}
     
       private static function _getUserRecord($user_id)
       {
          $user_record = array();
          switch($user_id) {
             case 1:
                $user_record['id'] = 1;
                $user_record['email'] = '[email protected]';
                $user_record['password'] = 'i like croissants';
                break;
     
             case 2:
                $user_record['id'] = 2;
                $user_record['email'] = '[email protected]';
                $user_record['password'] = 'me too!';
                break;
     
             case 'error':
                throw new Exception('Ошибка библиотеки SQL!');
                break;
          }
     
          return $user_record;
       }
    }
    ?>

    PHP исключения...

    Govnisti_Diavol, 19 Марта 2012

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

    +150

    1. 1
    2. 2
    3. 3
    4. 4
    <?php
    if ($_GET['type']) $link = 'type='.$_GET['type'];
    if ($_GET['cat']) $link = 'cat='.$_GET['cat'];
    if ($_GET['param']) $link = 'param='.$_GET['param'];

    isset, 19 Марта 2012

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

    −112

    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 static function isDynamicObject(obj:Object):Boolean
        {
            try
            {
                // this test for checking whether an object is dynamic or not is 
                // pretty hacky, but it assumes that no-one actually has a 
                // property defined called "wootHackwoot"
                obj["wootHackwoot"];
            }
            catch (e:Error)
            {
                // our object isn't from a dynamic class
                return false;
            }
            return true;
        }

    http://opensource.adobe.com/svn/opensource/flex/sdk/trunk/frameworks/projects/framework/src/mx/utils/ObjectUtil.as

    aquahawk, 16 Марта 2012

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

    −126

    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
    Процедура ОбработкаПроведения(Отказ, РежимПроведения)
    	Для Каждого Строка Из тчПутевыеЛисты Цикл
    		Если Строка.ПринятКУчету = Истина Тогда
    			ПутЛист = Строка.ПутевойЛист.ПолучитьОбъект();
    			ПутЛист.ПринятКУчету = Истина;
    			ПутЛист.ДатаПринятияКУчету = Дата;
    			ПутЛист.Записать(РежимЗаписиДокумента.Проведение, РежимПроведенияДокумента.Неоперативный);
    		КонецЕсли;
    	КонецЦикла;
    	Форма = ЭтотОбъект.ПолучитьФорму("ФормаДокумента");
    	Форма.ЭлементыФормы.тчПутевыеЛисты.Доступность = Ложь;
    	Форма.ЭлементыФормы.тчРаспределениеЗатрат.Доступность = Ложь;
    	Форма.ЭлементыФормы.КоманднаяПанель2.Кнопки.СформироватьДокумент.Доступность = Ложь;
    	Форма.ЭлементыФормы.КоманднаяПанель2.Кнопки.Заполнить.Доступность = Ложь;
    	Форма.ЭлементыФормы.КоманднаяПанель1.Кнопки.ЗаполнитьПоДаннымПоставщика.Доступность = Ложь;
    	Форма.ЭлементыФормы.КоманднаяПанель1.Кнопки.Заполнить.Доступность = Ложь;
    КонецПроцедуры

    ШЕДЕВР!
    Конечно, база данных ведь запоминает, что мы элементы формы сделали недоступными...

    mrbus, 14 Марта 2012

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

    +74

    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
    for (Tm_RecipientConstructor recipient: m_Recipients) {
    	
    	Tm_PHB_Contact m_Contact = recipient.getContact();
    	
    	if ( m_Contact != null) {					
    		if(m_Contact.getMobile()!=null) {						
    			st.setLong(1,recipient.getEntry().getID());//nWebEntryID
    			st.setLong(2,Tm_Registry.getInstance().getAttachementTypes().getID(En_AttachementType.ARGUMENT));//NTYPE
    			st.setString(3,"mobile");//STRNAME
    			st.setLong(4,Tm_Registry.getInstance().getAttributeType().getID(En_AttributeType.STRING));//NDATATYPE
    			st.setString(5,m_Contact.getMobile());//STRVALUE
    			st.addBatch();
        		index++;
        		if (index % 5000 == 0){		    				
        			st.executeBatch();
        			st.clearBatch();				            
        			st = conn.prepareStatement(sql);
        		}
    		}
    		if(m_Contact.getName()!=null) {						
    			st.setLong(1,recipient.getEntry().getID());//nWebEntryID
    			st.setLong(2,Tm_Registry.getInstance().getAttachementTypes().getID(En_AttachementType.ARGUMENT));//NTYPE
    			st.setString(3,"first_name");//STRNAME
    			st.setLong(4,Tm_Registry.getInstance().getAttributeType().getID(En_AttributeType.STRING));//NDATATYPE
    			st.setString(5,m_Contact.getName());//STRVALUE
    			st.addBatch();
        		index++;
        		if (index % 5000 == 0){		    				
        			st.executeBatch();
        			st.clearBatch();				            
        			st = conn.prepareStatement(sql);
        		}
    		}
    		if(m_Contact.getSurName()!=null) {
    			
    			st.setLong(1,recipient.getEntry().getID());//nWebEntryID
    			st.setLong(2,Tm_Registry.getInstance().getAttachementTypes().getID(En_AttachementType.ARGUMENT));//NTYPE
    			st.setString(3,"last_name");//STRNAME
    			st.setLong(4,Tm_Registry.getInstance().getAttributeType().getID(En_AttributeType.STRING));//NDATATYPE
    			st.setString(5,m_Contact.getSurName());//STRVALUE
    			st.addBatch();
        		index++;
        		if (index % 5000 == 0){		    				
        			st.executeBatch();
        			st.clearBatch();				            
        			st = conn.prepareStatement(sql);
        		}
    		}					
    		if(m_Contact.getPatrName()!=null) {
    			
    			st.setLong(1,recipient.getEntry().getID());//nWebEntryID
    			st.setLong(2,Tm_Registry.getInstance().getAttachementTypes().getID(En_AttachementType.ARGUMENT));//NTYPE
    			st.setString(3,"second_name");//STRNAME
    			st.setLong(4,Tm_Registry.getInstance().getAttributeType().getID(En_AttributeType.STRING));//NDATATYPE
    			st.setString(5,m_Contact.getPatrName());//STRVALUE
    			st.addBatch();
        		index++;
        		if (index % 5000 == 0){		    				
        			st.executeBatch();
        			st.clearBatch();				            
        			st = conn.prepareStatement(sql);
        		}
    		}					
    		if(m_Contact.getCompanyName()!=null) {
    			
    			st.setLong(1,recipient.getEntry().getID());//nWebEntryID
    			st.setLong(2,Tm_Registry.getInstance().getAttachementTypes().getID(En_AttachementType.ARGUMENT));//NTYPE
    			st.setString(3,"company");//STRNAME
    			st.setLong(4,Tm_Registry.getInstance().getAttributeType().getID(En_AttributeType.STRING));//NDATATYPE
    			st.setString(5,m_Contact.getCompanyName());//STRVALUE
    			st.addBatch();
        		index++;
        		if (index % 5000 == 0){		    				
        			st.executeBatch();
        			st.clearBatch();				            
        			st = conn.prepareStatement(sql);
        		}
    		}
    		if(m_Contact.getComment()!=null) {
    			
    			st.setLong(1,recipient.getEntry().getID());//nWebEntryID
    			st.setLong(2,Tm_Registry.getInstance().getAttachementTypes().getID(En_AttachementType.ARGUMENT));//NTYPE
    			st.setString(3,"comments");//STRNAME
    			st.setLong(4,Tm_Registry.getInstance().getAttributeType().getID(En_AttributeType.STRING));//NDATATYPE
    			st.setString(5,m_Contact.getComment());//STRVALUE
    			st.addBatch();
        		index++;
        		if (index % 5000 == 0){		    				
        			st.executeBatch();
        			st.clearBatch();				            
        			st = conn.prepareStatement(sql);
        		}
    		}	
    	}
    }

    Функции? Не, не слышал.

    SadKo, 12 Марта 2012

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

    −139

    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
    Если  ЗначениеЗаполнено(ВыслугаЛет) Тогда 
    			Запрос.УстановитьПараметр("ВыслугаЛет",     ВыслугаЛет);
    		КонецЕсли;
    		
    		Если не ЗначениеЗаполнено(ВыслугаЛет) Тогда 
    			Запрос.Текст = СтрЗаменить(Запрос.Текст,"И ПНУ.ВидРасчета <> &ВыслугаЛет","");
    			Запрос.Текст = СтрЗаменить(Запрос.Текст,"И ТабельныйЛист.ВидРасчета <> &ВыслугаЛет","");
    			Запрос.Текст = СтрЗаменить(Запрос.Текст,"И Прекращения.ВидРасчета <> &ВыслугаЛет","");
    		КонецЕсли;
    		
    		Запрос.УстановитьПараметр("Организация",    Организация);
    		Запрос.УстановитьПараметр("ПодразделениеОрганизации",  ПодразделениеОрганизации);
    		
    		Если ПодразделениеОрганизации.Пустая() Тогда
    			Запрос.Текст = СтрЗаменить(Запрос.Текст,"И Подразделение В ИЕРАРХИИ(&ПодразделениеОрганизации)","");
    			Запрос.Текст = СтрЗаменить(Запрос.Текст,"И Прекращения.ПодразделениеОрганизации = &ПодразделениеОрганизации","");
    			Запрос.Текст = СтрЗаменить(Запрос.Текст,"И ТабельныйЛист.Подразделение В ИЕРАРХИИ(&ПодразделениеОрганизации)","");
    		КонецЕсли;
    		
    		Если НЕ ЗначениеЗаполнено(ВыслугаЛет) Тогда 
    			Запрос.Текст = СтрЗаменить(Запрос.Текст,"ГДЕ
    			|	ТабельныйЛист.ВидРасчета <> &ВыслугаЛет
    			|	И","Где ");
    		КонецЕсли;

    Jivchic, 12 Марта 2012

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

    +70

    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
    public boolean getSuccessSubmitted() {
        for (ReportDto report : getReports()) {
           if (!(report.getOrder().getReceiptDate() != null && report.getReportReceived())) {
               return false;
           }
        }
        return !(getReports().isEmpty());
    }
    
    public boolean getUnSuccessSubmitted(){
        for (ReportDto report : getReports()) {
            if (!(report.getOrder().getOrderDate() != null && !(report.getReportReceived()))) {
                return false;
            }
        }
        return !(getReports().isEmpty());
    }

    для классического трио нехватает лишь getFailSubmitted()

    roman-kashitsyn, 11 Марта 2012

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

    +142

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    var trololo = " ";
    $ololo = " ";
    ...
    if ($trololo==$ololo){
    echo "Совпадение первого поля со вторым - не есть хорошо.";
    }

    Зря пишу одновременно и на php и javascript, зря зря зря зря.

    servan, 10 Марта 2012

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