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

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

    +1

    1. 1
    https://www.google.com/search?q=%D0%B2%D0%BE%D1%80%D0%B5%D1%86%D0%B8%D0%B8

    Насрали так, что все ссылки ведут на говнокод.
    Как эта херомантия называется в науке?
    3.14159265359, это ты придумал слово "вореции"?

    3_dar, 12 Апреля 2016

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

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    if (collection == null) collection = Rows.Where(r => r.ParentId == 0);
    foreach (var row in collection.Where(r => r.ParentId > 0))
    {
         //немного кода
    }

    Сам писал. Вчера. Трезвый.
    Сейчас вот думаю, а чо эта оно не работает?

    kerman, 11 Апреля 2016

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

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    // 1188 references
    internal static string CombinePaths(string firstPath, string secondPath)
    {
        return Path.Combine(firstPath, secondPath);
    }

    - Шо это было?!!
    - Cэкономили точку. 1188 раз )))))

    RadChand, 08 Апреля 2016

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

    +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
    public class FileStorage {
            public FileStorage() {
                try {
                    if (String.IsNullOrEmpty(Common.GlobalVariables.FileStorage)) {
                        throw new Exception(Common.GuiHelper.ShowErrorMessage("FileStorage", String.Empty));
                    }
    
                    if (!Directory.Exists(Common.GlobalVariables.FileStorage)) {
                        DirectoryInfo di = Directory.CreateDirectory(Common.GlobalVariables.FileStorage);
                        if (!di.Exists) {
                            throw new Exception(Common.GuiHelper.ShowErrorMessage("FileStorageDir", String.Empty));
                        }
                    }
                } catch (Exception er) {
                    throw new Exception(er.Message);
                }
            }
    
            public String CreateFileDirectory() {
                try {
                    int iIdx = 0;
                    Boolean bIsCreated = false;
                    while (!bIsCreated && iIdx < 10) {
                        String sDir = Guid.NewGuid().ToString("N").ToLower();
                        sDir = sDir.Substring(0, 2);
                        if (!Directory.Exists(Common.GlobalVariables.FileStorage + sDir + @"\")) {
                            DirectoryInfo di = Directory.CreateDirectory(Common.GlobalVariables.FileStorage + sDir + @"\");
                            if (di.Exists) {
                                return Common.GlobalVariables.FileStorage + sDir + @"\";
                            }
                        }
    
                        iIdx++;
                    }
    
                    return null;
                } catch (Exception er) {
                    throw new Exception(er.Message);
                }
            }
        }

    может я чего не понимаю, но зачем?

    Lokich, 08 Апреля 2016

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

    +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
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    <?php if($this->config->get('UniversumControl_status') == '1'){ ?>
    <style type="text/css">
    body {
    <?php if(( $this->config->get('UniversumControl_body_bg_pattern') != null) && ($this->config->get('UniversumControl_body_bg_pattern') != 'pattern0.png')){ ?>
     background:url("catalog/view/theme/<?php echo $this->config->get('config_template'); ?>/image/backgrounds/<?php echo  $this->config->get('UniversumControl_body_bg_pattern');?>") top center repeat;
     <?php } ?>
     background-color:#<?php echo $this->config->get('UniversumControl_body_bg_color') ?>;
     font-family:<?php echo $this->config->get('UniversumControl_body_font') ?>;
     color:#<?php echo $this->config->get('UniversumControl_text_color') ?>;
    }
    h1,h2,h3,h4,h5,h6, #menu ul li a, #column-left .box .box-heading, #column-right .box .box-heading, .htabs a, .product-info .price-old, .product-info .price-new, .product-info .cart .button, .offer_title, div.prod_hold .prod-info-fly .name a, .accordeonHolder .name a, .prod_hold .name a, #content .boxPlain .box-heading { 
    <?php if(($this->config->get('UniversumControl_status') == '1') && ( $this->config->get('UniversumControl_custom_font') != null)){	?>
    font-family: '<?php echo  $this->config->get('UniversumControl_custom_font_family');?>';
    <?php } elseif (($this->config->get('UniversumControl_status') == '1') && ( $this->config->get('UniversumControl_custom_font') == null) && ( $this->config->get('UniversumControl_header_font') != 'Arial')){ ?>
    <?php $headerFont = $this->config->get('UniversumControl_headings_font');
    $font = str_replace("+", " ", $headerFont);
    ?> font-family: '<?php echo $font; ?>';
    <?php } else { ?>
    font-family: 'Ubuntu Condensed';
    <?php } ?>
    }
    <?php if(($this->config->get('UniversumControl_status') == '1') && ( $this->config->get('UniversumControl_headings_color') != null)){	?>
    h1, h2, h2.heading_title, h3, h4, h5, h6, #column-left .box .box-heading, #column-right .box .box-heading {
    color:#<?php echo $this->config->get('UniversumControl_headings_color') ?>;
    }
    <?php } ?>
    <?php if(($this->config->get('UniversumControl_status') == '1') && ( $this->config->get('UniversumControl_headings1_size') != null)){	?>
    h1 {
    font-size:<?php echo $this->config->get('UniversumControl_headings1_size') ?>px;
    }
    <?php } ?>
    <?php if(($this->config->get('UniversumControl_status') == '1') && ( $this->config->get('UniversumControl_headings2_size') != null)){	?>
    h2, #content .boxPlain .box-heading {
    font-size:<?php echo $this->config->get('UniversumControl_headings2_size') ?>px;
    }
    <?php } ?>
    <?php if(($this->config->get('UniversumControl_status') == '1') && ( $this->config->get('UniversumControl_headings3_size') != null)){	?>
    h3 {
    font-size:<?php echo $this->config->get('UniversumControl_headings3_size') ?>px;
    }
    <?php } ?>
    <?php if(($this->config->get('UniversumControl_status') == '1') && ( $this->config->get('UniversumControl_headings4_size') != null)){	?>
    h4 {
    font-size:<?php echo $this->config->get('UniversumControl_headings4_size') ?>px;
    }
    <?php } ?>
    <?php if(($this->config->get('UniversumControl_status') == '1') && ( $this->config->get('UniversumControl_price_size') != null)){	?>
    .product-info .price {
    font-size:<?php echo $this->config->get('UniversumControl_price_size') ?>px;
    }
    <?php } ?>
    <?php if(($this->config->get('UniversumControl_status') == '1') && ( $this->config->get('UniversumControl_module_title_size') != null)){	?>
    #content h2.heading_title span {
    font-size:<?php echo $this->config->get('UniversumControl_module_title_size') ?>px;
    }
    <?php } ?>
    <?php if(($this->config->get('UniversumControl_status') == '1') && ( $this->config->get('UniversumControl_column_title_size') != null)){	?>
    #column-left .box .box-heading, #column-right .box .box-heading {
    font-size:<?php echo $this->config->get('UniversumControl_column_title_size') ?>px;
    }

    И такого кода там еще на 1000 строк.

    Интернет-магазин на опенкарте. Видимо кто то сделал систему настраивания css через админку))

    IKARUS, 08 Апреля 2016

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

    +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
    <?php
    class Controller_Messages extends Controller {
        
        function __construct() {
            $this->log = new Log;
            if(!defined('SECURITY_CONST')) {
                $this->log->log('[controller_messages.php:'.__LINE__.'] SECURITY_CONST is undefined');
                exit;
            }
            $this->user = new User;
            $this->lang = new Lang;
            $this->view = new View;
            $this->model = new Model_Messages;
    
            if(!$this->user->isAuth()) {
                header('Location: /not_auth');
            }
            $this->user_lang = $this->user->getLang();
            $this->lang->setLang($this->user_lang);
        }

    Открыл исходник и тут такое....

    Dev_18, 04 Апреля 2016

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

    +1

    1. 1
    Что за мемчик про вореции?

    Желательно со ссылками на лурк.

    kurwa, 02 Апреля 2016

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

    +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
    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
    private int GetSroOper(MiscTransactionParams param)
    		{
    			if (param.ExpenseItem != null)
    			{
    				switch (param.ContractType)
    				{
    					case Entities.AT.ContractType.Undefined:
    					case Entities.AT.ContractType.TimeAndMaterials:
    					case Entities.AT.ContractType.Retainer:
    						switch ((int)param.ExpenseItem.ExpenseCategory)
    						{
    							case 2:
    							case 3:
    							case 29684252:
    							case 29684285:
    							case 29684805:
    								return param.BillingItem.IsNonBillable() ? Helper.SLServiceOrderOperation600 : Helper.SLServiceOrderOperation900;
    							default:
    								throw new InvalidOperationException("Unsupported Expense Category value");
    						}
    					case Entities.AT.ContractType.RecurringService:
    						switch ((int)param.ExpenseItem.ExpenseCategory)
    						{
    							case 2:
    							case 3:
    							case 29684252:
    							case 29684285:
    							case 29684805:
    								return param.BillingItem.IsNonBillable() ? Helper.SLServiceOrderOperation550 : Helper.SLServiceOrderOperation950;
    							default:
    								throw new InvalidOperationException("Unsupported Expense Category value");
    						}
    					case Entities.AT.ContractType.FixedPrice:
    						switch ((int)param.ExpenseItem.ExpenseCategory)
    						{
    							case 2:
    							case 3:
    							case 29684252:
    							case 29684285:
    							case 29684805:
    								return param.BillingItem.IsNonBillable() ? Helper.SLServiceOrderOperation500 : Helper.SLServiceOrderOperation950;
    							default:
    								throw new InvalidOperationException("Unsupported Expense Category value");
    						}
    					case Entities.AT.ContractType.Incident:
    						switch ((int)param.ExpenseItem.ExpenseCategory)
    						{
    							case 2:
    							case 3:
    							case 29684252:
    							case 29684285:
    							case 29684805:
    								return param.BillingItem.IsNonBillable() ? Helper.SLServiceOrderOperation600 : Helper.SLServiceOrderOperation950;
    							default:
    								throw new InvalidOperationException("Unsupported Expense Category value");
    						}
    					default:
    						throw new InvalidOperationException("Unsupported ContractType value");
    				}
    			}
    			else
    			{
    				switch (param.ContractType)
    				{
    					case Entities.AT.ContractType.Undefined:
    					case Entities.AT.ContractType.TimeAndMaterials:
    					case Entities.AT.ContractType.Retainer:
    						return param.BillingItem.IsNonBillable() ? Helper.SLServiceOrderOperation600 : Helper.SLServiceOrderOperation900;
    					case Entities.AT.ContractType.RecurringService:
    						return param.BillingItem.IsNonBillable() ? Helper.SLServiceOrderOperation550 : Helper.SLServiceOrderOperation950;
    					case Entities.AT.ContractType.FixedPrice:
    					case Entities.AT.ContractType.Incident:
    						int sroOper = (int)param.OrderOperation.EntityRow()[Constants.ServiceOrderOperation.Field.SroOper];
    						switch (sroOper)
    						{
    							case 500:
    							case 600:
    							case 800:
    							case 850:
    							case 950:
    								return sroOper;
    							default:
    								throw new InvalidOperationException("Unsupported Operation value");
    						}
    					default:
    						throw new InvalidOperationException("Unsupported ContractType value");
    				}
    			}
    		}

    Это наш сеньор написал

    kagetoki, 30 Марта 2016

    Комментарии (19)
  10. C# / Говнокод #19700

    +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
    [DllImport("quickusb.dll", CharSet = CharSet.Ansi)]
    static extern int QuickUsbWriteData(IntPtr Handle, byte[] outData, int length);
    
    // ...
    
     public bool Write(byte[] data)
        {
        // ...
            int result = QuickUsbWriteData(handle, data, data.Length);
    
            if (result != 0)
                return true;
            else if (result == 0)
            {
                LastError =  "QUSB returned 0";
                return false;
            }
            else
            {
                LastError = "Unknown error inside WriteData";
                return false;
            }
        // ...
      }

    Видимо, последняя ветка - на случай зомби-апокалипсиса или особо сильных глюков после передоза.

    yamamoto, 25 Марта 2016

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

    +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
    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
    template < typename CType >
        void list < CType >::sorted_push(CType val, long int key)
    {
    	if (head) {
    		// Создаём контейнер и помещаем в него полученное значение
    		container < CType > *new_cont;
    		container < CType > *tmp = head;
    
    		new_cont = new container < CType >;
    		new_cont->set_key(key);
    		new_cont->set_cargo(val);
    
    		while ((tmp != tail) && (key > (tmp->get_key())))
    			tmp = tmp->get_next();
    
    		if ((tmp == tail) && (key > (tmp->get_key()))) {	// Если выполнились одновременно два условия в цикле
    			new_cont->set_next(tmp->get_next());	// Вставляем в самый конец
    			new_cont->set_past(tmp);
    			tmp->set_next(new_cont);
    			tail = new_cont;
    		} else {
    			new_cont->set_next(tmp);
    			new_cont->set_past(tmp->get_past());
    			if ((tmp->get_past()) != NULL)
    				tmp->get_past()->set_next(new_cont);
    			if (tmp == head)
    				head = new_cont;
    			tmp->set_past(new_cont);
    		}
    
    		if (empty) {
    			empty = false;
    			tail = head;
    		}
    	} else {
    		container < CType > *new_cont;
    
    		new_cont = new container < CType >;
    		new_cont->set_key(key);
    		new_cont->set_cargo(val);
    
    		new_cont->set_next(head);
    		tail = head = new_cont;
    		empty = false;
    	}
    }
    
    template < typename CType > CType queue < CType >::pop()
    {
    	container < CType > *tmp = list<CType>::head;
    
    	if (tmp == NULL) {
    		std::cerr <<
    		    "Стек пуст! Стек возвращает мусор! ";
    		list<CType>::empty = true;
    	} else {
    		CType tmpval = list<CType>::head->get_cargo();
    		// Переходим к следующему элементу
    		list<CType>::head = list<CType>::head->get_next();
    		if (list<CType>::head == NULL)
    			list<CType>::empty = true;
    		delete tmp;
    		return tmpval;
    	}
    }
    
    template < typename CType > CType stack < CType >::pop()
    {
    	container < CType > *tmp = list<CType>::tail;
    
    	if (tmp == NULL) {
    		std::cerr <<
    		    "Очередь пуста! Возвращается мусор! ";
    		list<CType>::empty = true;
    	} else {
    		CType tmpval = list<CType>::tail->get_cargo();
    
    		// Переходим к предыдущему элементу
    
    		if (list<CType>::tail != list<CType>::head)
    			list<CType>::tail = list<CType>::tail->get_past();
    		else
    			list<CType>::empty = true;
    		delete tmp;
    		return tmpval;
    	}
    }

    пострелял себе в ногу

    viktorokh96, 25 Марта 2016

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