1. PHP / Говнокод #19784

    0

    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
    <script type="text/javascript">
            var currentLeveler = 0;
            var currentPrefix = 'povorot_';
            var currentPart = 0;
            var partsCount = [];
            var oldPart, oldLeveler;
            languagePrefix = "<?php echo $lang; ?>";
            partsCount[0] = 5;
            partsCount[1] = 4;
            partsCount[2] = 3;
    
            var levelersInfo = [[], [], []];
            var levelerParts = [[], [], []];
            var content = [];
    
            <?php
                while($row = mysql_fetch_array($tmp)){
                    $content[$row['block_id']] = $row['cont'];
                    echo "content[\"" .$row['block_id']. "\"] = '".$row['cont']."';\n";
                }
                for($j = 0; $j < 3; $j++)
                    for($i = 0; $i < 5; $i++){
    
                        $val1 = $content[$lang."_tech_leveler_info_".$j.$i];
                        $val2 = $content[$lang."_tech_part_info_".$j.$i];
                  
                        echo "levelersInfo[".$j."].push('".$val1."');";
                        echo "levelerParts[".$j."].push('".$val2."');";
                    }
            ?>
            $(document).ready(function () {
                $.each($(".changeable"), function () {
                    $(this).html(content[$(this).attr("id")]);
                });
            });
        </script>

    Формируем js код, через PHP на основе данных из базы данных... или в жопку аякс

    perryutkonos, 08 Апреля 2016

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

    +6

    1. 1
    2. 2
    function pageOutput() {
    	foreach($GLOBALS as $var => $val) $$var = &$GLOBALS[$var];

    очередная находка..
    ...для тех, кто не уверен, какие переменные из global scope понадобятся...

    paulrudy, 08 Апреля 2016

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

    −3

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

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

    braun3812, 07 Апреля 2016

    Комментарии (17)
  9. 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)
  10. 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)