1. JavaScript / Говнокод #19778

    +4

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    $(document).ready(function() {
    		setInterval(form_check, 10);
    
    		function form_check() {
    			if ($("#main-order-form input[name='car-name']").attr("value") == "") {
    				$("#main-order-form button").attr('disabled', 'disabled');
    			} else {
    				$("#main-order-form button").removeAttr('disabled');
    			}						
    		}
    	});

    Валидация формы)))

    IKARUS, 08 Апреля 2016

    Комментарии (2)
  2. 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)
  3. PHP / Говнокод #19772

    +2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    try {
        $files->load($avatar);
        $this->fail('Fail message');
    } catch (\Exception $ex) {
        //All good
    }

    Это авто тест на метод $files->load
    $this->fail - здесь кидает исключение

    All good - и не важно какое исключение кинет $files->load, а если не кинет, то вызовем fail который наверняка кинет исключение

    Alex89, 07 Апреля 2016

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

    −3

    1. 1
    2. 2
    $this->strQueryText = $strQuery = trim($arParams["QUERY"]);
    $this->strTags = $strTags  = $arParams["TAGS"];

    Из ядра.
    Многобуков не любят.

    braun3812, 07 Апреля 2016

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

    +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
    21. 21
    22. 22
    23. 23
    <ul>
         <?php if($user_comment_rating == '1') { ?>
              <li><span class="icon-star"></span></li>
         <?php } else if($user_comment_rating == '2') { ?>
              <li><span class="icon-star"></span></li>
              <li><span class="icon-star"></span></li>
         <?php } else if($user_comment_rating == '3') { ?>
              <li><span class="icon-star"></span></li>
              <li><span class="icon-star"></span></li>
              <li><span class="icon-star"></span></li>
         <?php } else if($user_comment_rating == '4') { ?>
              <li><span class="icon-star"></span></li>
              <li><span class="icon-star"></span></li>
              <li><span class="icon-star"></span></li>
              <li><span class="icon-star"></span></li>
         <?php } else if($user_comment_rating == '5') { ?>
              <li><span class="icon-star"></span></li>
              <li><span class="icon-star"></span></li>
              <li><span class="icon-star"></span></li>
              <li><span class="icon-star"></span></li>
              <li><span class="icon-star"></span></li>
         <?php } ?>
    </ul>

    Из шаблона одной платной вордпрессовской темы.

    Nekronavt, 06 Апреля 2016

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

    +4

    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
    constexpr Fraction operator+(const Fraction& fraction) const noexcept
        {
            const Fraction max_fraction_by_denominator{denominator > fraction.denominator ? *this : fraction};
            const Fraction min_fraction_by_denominator{denominator < fraction.denominator ? *this : fraction};
            const bool is_sim_denominator = max_fraction_by_denominator.denominator %
                                            min_fraction_by_denominator.denominator == 0;
            int sim_denominator = is_sim_denominator ?
                max_fraction_by_denominator.denominator : (max_fraction_by_denominator.denominator *
                min_fraction_by_denominator.denominator);
            const int nominator1 = is_sim_denominator ? (min_fraction_by_denominator.nominator *
                max_fraction_by_denominator.denominator / min_fraction_by_denominator.denominator) :
                min_fraction_by_denominator.nominator * max_fraction_by_denominator.denominator;
            const int nominator2 = is_sim_denominator ? max_fraction_by_denominator.nominator :
                max_fraction_by_denominator.nominator * min_fraction_by_denominator.denominator;
            int nominators_sum = nominator1 + nominator2;
            int while_parts_sum = while_part + fraction.while_part;
    
            while (nominators_sum >= sim_denominator)
            {
                nominators_sum -= sim_denominator;
                ++while_parts_sum;
            }
    
            if (!nominators_sum)
                sim_denominator = 0;
    
            return {while_parts_sum, nominators_sum, sim_denominator};
        }

    jangolare, 06 Апреля 2016

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

    +5

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    foreach ($this->diafan->select_arr("status_id") as $id => $value)
    {
    	$first_status = $id;
    	break;
    }

    Сниппет для получения первого ключа массива.

    karpen, 06 Апреля 2016

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

    +2

    1. 1
    2. 2
    $table = (object) null;
    $table->fields = array();

    Повышенная хитрость

    Sh1tM4ker, 06 Апреля 2016

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

    +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
    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
    public struct TotalStat
    {
        public int Level { get; set; }
        public int Type { get; set; }
        public string Name { get; set; }
        public string Code { get; set; }
        public int VAL_01_1 { get; set; }
        public int VAL_01_2 { get; set; }
        public int VAL_01_3 { get; set; }
        public int VAL_01_4 { get; set; }
        public int VAL_51_1 { get; set; }
        public int VAL_51_2 { get; set; }
        public int VAL_51_3 { get; set; }
        public int VAL_51_4 { get; set; }
    
        public TotalStat[] Children;
    
    
        public FontWeight FontWeight
        {
            get
            {
                return Type == 2 ? FontWeights.Bold : FontWeights.Normal;
            }
        }
    
        public Thickness Margin
        {
            get
            {
                return new Thickness(this.Level * 10, 0, 0, 0);
            }
        }
    
        public string CNT_01
        {
            get
            {
                var v = VAL_01_1 + VAL_01_2 + VAL_01_3 + VAL_01_4;
                return v.ToString();
            }
        }
        public string CNT_51
        {
            get
            {
                var v = VAL_51_1 + VAL_51_2 + VAL_51_3 + VAL_51_4;
                return v.ToString();
            }
        }
        public string CNT_01_1
        {
            get
            {
                if (Type == 1) return "";
                if (VAL_01_1 == 0) return "-";
                return VAL_01_1.ToString();
            }
        }
        public string CNT_01_2
        {
            get
            {
                if (Type == 1) return "";
                if (VAL_01_2 == 0) return "-";
                return VAL_01_2.ToString();
            }
        }
        public string CNT_01_3
        {
            get
            {
                if (Type == 1) return "";
                if (VAL_01_3 == 0) return "-";
                return VAL_01_3.ToString();
            }
        }
    
    //В том же духе до CNT_51_4
    
        public static TotalStat operator +(TotalStat t, TotalStat c)
        {
            t.VAL_01_1 += c.VAL_01_1;
            t.VAL_01_2 += c.VAL_01_2;
            t.VAL_01_3 += c.VAL_01_3;
            t.VAL_01_4 += c.VAL_01_4;
            t.VAL_51_1 += c.VAL_51_1;
            t.VAL_51_2 += c.VAL_51_2;
            t.VAL_51_3 += c.VAL_51_3;
            t.VAL_51_4 += c.VAL_51_4;
            return t;
        }
    }

    На лабу похоже, да? А вот это не лаба. Сириозный праэкт для суровой организации (продолжение).

    kerman, 06 Апреля 2016

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

    +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
    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
    // TODO: Refactor to one call of 'refineIndexes'
      std::vector<float32_t> *refined_left_1_3 = rec.refineIndexes(LEFT_CHANNEL, std::get<1>(p_l1) * ATT_3dB, INTERP_LINEAR, CROSS_RISE);
      std::vector<float32_t> *refined_right_1_3 = rec.refineIndexes(RIGHT_CHANNEL, std::get<1>(p_r1) * ATT_3dB, INTERP_LINEAR, CROSS_RISE);
      std::vector<float32_t> *refined_left_1_6 = rec.refineIndexes(LEFT_CHANNEL, std::get<1>(p_l1) * ATT_6dB, INTERP_LINEAR, CROSS_FALL);
      std::vector<float32_t> *refined_right_1_6 = rec.refineIndexes(RIGHT_CHANNEL, std::get<1>(p_r1) * ATT_6dB, INTERP_LINEAR, CROSS_FALL);
      std::vector<float32_t> *refined_left_2_3 = rec.refineIndexes(LEFT_CHANNEL, std::get<1>(p_l2) * ATT_3dB, INTERP_PARABOLIC, CROSS_RISE);
      std::vector<float32_t> *refined_right_2_3 = rec.refineIndexes(RIGHT_CHANNEL, std::get<1>(p_r2) * ATT_3dB, INTERP_PARABOLIC, CROSS_RISE);
      std::vector<float32_t> *refined_left_2_6 = rec.refineIndexes(LEFT_CHANNEL, std::get<1>(p_l2) * ATT_6dB, INTERP_PARABOLIC, CROSS_FALL);
      std::vector<float32_t> *refined_right_2_6 = rec.refineIndexes(RIGHT_CHANNEL, std::get<1>(p_r2) * ATT_6dB, INTERP_PARABOLIC, CROSS_FALL);
      
      bool exists_att_3dB = refined_left_1_3->size() > 0 && refined_right_1_3->size() > 0 && refined_left_2_3->size() > 0 && refined_right_2_3->size() > 0;
      bool exists_att_6dB = refined_left_1_6->size() > 0 && refined_right_1_6->size() > 0 && refined_left_2_6->size() > 0 && refined_right_2_6->size() > 0;
    
      if (exists_att_3dB || exists_att_6dB)  {
        float32_t rdTOA_l_3, rdTOA_r_3, rdBW_3, rdSW_3, rdTOA_l_6, rdTOA_r_6, rdBW_6, rdSW_6;
        if (exists_att_3dB && !exists_att_6dB) {
          rdTOA_l_6 = rdTOA_l_3 = refined_left_2_3->back() - refined_left_1_3->front();
          rdTOA_r_6 = rdTOA_r_3 = refined_right_2_3->back() - refined_right_1_3->front();
          rdBW_6 = rdBW_3 = refined_left_2_3->back() - refined_right_2_3->back();
          rdSW_6 = rdSW_3 = refined_left_1_3->front() - refined_right_1_3->front();
        } 
        else if (!exists_att_3dB && exists_att_6dB) {
          rdTOA_l_6 = rdTOA_l_3 = refined_left_2_6->back() - refined_left_1_6->front();
          rdTOA_r_6 = rdTOA_r_3 = refined_right_2_6->back() - refined_right_1_6->front();
          rdBW_6 = rdBW_3 = refined_left_2_6->back() - refined_right_2_6->back();
          rdSW_6 = rdSW_3 = refined_left_1_6->front() - refined_right_1_6->front();
        }
        else {
          rdTOA_l_3 = refined_left_2_3->back() - refined_left_1_3->front();
          rdTOA_r_3 = refined_right_2_3->back() - refined_right_1_3->front();
          rdBW_3 = refined_left_2_3->back() - refined_right_2_3->back();
          rdSW_3 = refined_left_1_3->front() - refined_right_1_3->front();
          rdTOA_l_6 = refined_left_2_6->back() - refined_left_1_6->front();
          rdTOA_r_6 = refined_right_2_6->back() - refined_right_1_6->front();
          rdBW_6 = refined_left_2_6->back() - refined_right_2_6->back();
          rdSW_6 = refined_left_1_6->front() - refined_right_1_6->front();
        }
        float32_t rdTOA_l = (rdTOA_l_3 + rdTOA_l_6) / 2f;
        float32_t rdTOA_r =(rdTOA_r_3 + rdTOA_r_6) / 2f;
        float32_t rdBW = (rdBW_3 + rdBW_6) / 2f;
        float32_t rdSW = (rdSW_3 + rdSW_6) / 2f;
    
        //TODO: Watch for group delay compensation!
        float32_t rdeltaTOA = (rdTOA_l + rdTOA_r - 2 * groupDelay) / (2.0 * AUDIO_SAMPLE_RATE_EXACT);
        float32_t rdeltaBlastWave = rdBW / AUDIO_SAMPLE_RATE_EXACT;
        float32_t rdeltaShockWave = rdSW / AUDIO_SAMPLE_RATE_EXACT;
        //..................................................
      if (sd_init_status == SD_OK && current_settings.log) logFile.close();
    
      refined_left_1_3->clear();
      refined_right_1_3->clear();
      refined_left_2_3->clear();
      refined_right_2_3->clear();
      refined_left_1_6->clear();
      refined_right_1_6->clear();
      refined_left_2_6->clear();
      refined_right_2_6->clear();
    
      delete refined_left_1_3;
      delete refined_right_1_3;
      delete refined_left_2_3;
      delete refined_right_2_3;
      delete refined_left_1_6;
      delete refined_right_1_6;
      delete refined_left_2_6;
      delete refined_right_2_6;

    50 часов без сна... Чувствую я пожалею завтра о том, что сегодня это написал.

    FMB, 06 Апреля 2016

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