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

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

    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
    public function format_phone($phone) {
            $phone       = preg_replace("/\D/", "", $phone);
            $first_digit = substr($phone, 0, 1);
            if ($first_digit == "7" || $first_digit == "8") {
                $phone = substr($phone, 1);
            }
            if ($first_digit == "+") {
                $phone = substr($phone, 2);
            }
            $p     = str_split($phone);
            $phone = "(" . $p[0] . $p[1] . $p[2] . ") " . $p[3] . $p[4] . $p[5] . "-" . $p[6] . $p[7] . "-" . $p[8] . $p[9];
            return $phone;
    }

    dgkj, 17 Мая 2016

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

    +7

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    private function checkPlaces(){
        $popups = array();
        foreach($this->popups as $popup){
            if($popup->showOnThisPage()){
                $popups[] = $popup;
            }
        }
        $this->popups = $popups;
    }
    
    private function checkExcludes(){
        $popups = array();
        foreach($this->popups as $popup){
            if(!$popup->excludeOnThisPage()){
                $popups[] = $popup;
            }
        }
        $this->popups = $popups;
    }
    
    private function checkPage(){
        $popups = array();
        foreach($this->popups as $popup){
            if($popup->checkPageCount($this->user_info['popup_page'])){
                $popups[] = $popup;
            }
        }
        $this->popups = $popups;
    }
    private function checkReferer(){
        $popups = array();
        foreach($this->popups as $popup){
            if($popup->checkReferer()){
                $popups[] = $popup;
            }
        }
        $this->popups = $popups;
    }
    private function checkGETParams(){
        $popups = array();
        foreach($this->popups as $popup){
            if($popup->checkGETParams()){
                $popups[] = $popup;
            }
        }
        $this->popups = $popups;
    }
    private function checkVisitCount(){
        $popups = array();
        foreach($this->popups as $popup){
            if($popup->checkVisitCount($this->user_info['visit_count'])){
                $popups[] = $popup;
            }
        }
        $this->popups = $popups;
    }
    private function checkFirstVisitDate(){
        $popups = array();
        foreach($this->popups as $popup){
            if($popup->checkFirstVisitDate()){
                $popups[] = $popup;
            }
        }
        $this->popups = $popups;
    }
    private function checkLastVisitDate(){
        $popups = array();
        foreach($this->popups as $popup){
            if($popup->checkLastVisitDate()){
                $popups[] = $popup;
            }
        }
        $this->popups = $popups;
    }
    private function checkCustom(){
        $popups = array();
        foreach($this->popups as $popup){
            if($popup->checkCustom()){
                $popups[] = $popup;
            }
        }
        $this->popups = $popups;
    }
    private function checkDate(){
        $popups = array();
        foreach($this->popups as $popup){
            if($popup->checkDate()){
                $popups[] = $popup;
            }
        }
        $this->popups = $popups;
    }
    private function checkDevice(){
        $popups = array();
        foreach($this->popups as $popup){
            if($popup->checkDevice()){
                $popups[] = $popup;
            }
        }
        $this->popups = $popups;

    Скилл Ctrl+C - Ctrl+V прокачан до 80го уровня.

    strax, 09 Мая 2016

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

    +2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    $sql = "SELECT COUNT(`user_id`) FROM `link_empl_tf` WHERE `sched_date` >= " . $DB->
        F(substr($startDate, 6, 4) . "-" . substr($startDate, 3, 2) . "-" . substr($startDate,
                0, 2)) . " AND `sched_date` <= " . $DB->F(substr($endDate, 6, 4) . "-" . substr
            ($endDate, 3, 2) . "-" . substr($endDate, 0, 2)) . " AND `user_id`=" . $DB->F($uParam[0]) .
        ";";

    Date formatting by ©senior shaurma developer

    pahhan, 05 Мая 2016

    Комментарии (2)
  5. JavaScript / Говнокод #19925

    0

    1. 1
    var routers = new (R(views))();

    Чет по другому не придумал как в роутер view передать

    arny, 04 Мая 2016

    Комментарии (2)
  6. JavaScript / Говнокод #19883

    +3

    1. 1
    2. 2
    3. 3
    setTimeout(function() {
        $('#kostyl').click().click();
    }, 2000);

    Применить сортировку по этому столбцу в таблице после её подгрузки и отработки жс, который строит эту таблицу.

    deep, 26 Апреля 2016

    Комментарии (2)
  7. JavaScript / Говнокод #19839

    +3

    1. 1
    2. 2
    3. 3
    4. 4
    var pricerawjson = "%7B%22price%22%3A%226973.00%22%2C%22status%22%3A%22active%22%2C%22sell_status%22%3A%22available%22%2C%22old_price%22%3A%227607.0000%22%2C%22price_formatted%22%3A%226%20973%22%2C%22old_price_formatted%22%3A%227%20607%22%7D";
    if (pricerawjson.length == 0) {
          pricerawjson = '%7B%22price%22%3A%226973%22%2C%22price_formatted%22%3A%226%20973%22%2C%22old_price%22%3A7607%2C%22old_price_formatted%22%3A%227%20607%22%2C%22status%22%3A%22active%22%2C%22sell_status%22%3A%22available%22%7D';
    }

    kyzi007, 18 Апреля 2016

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

    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
    .container .additional-item{display: block;width:100%;}
    .container .additional-item thead{display: block;width:100%;}
    .container .additional-item thead tr td{font-weight: bold;}
    .container .additional-item tbody{display: block;width:100%;}
    .container .additional-item tr{display: block;width:100%;padding:10px 0px;}
    .container .additional-item tr td{display: inline-block;text-align: center;}
    .container .additional-item tr td:nth-child(1){width:3%;}
    .container .additional-item tr td:nth-child(2){width:3%;}
    .container .additional-item tr td:nth-child(3){width:3%;}
    .container .additional-item tr td:nth-child(4){width:15%;}
    .container .additional-item tr td:nth-child(5){width:5%;}
    .container .additional-item tr td:nth-child(6){width:5%;overflow: hidden;}
    .container .additional-item tr td:nth-child(7){width:20%;overflow: hidden;}
    .container .additional-item tr td:nth-child(8){width:3%;overflow: hidden;}
    .container .additional-item tr td:nth-child(9){width:3%;overflow: hidden;}
    .container .additional-item tr td:nth-child(10){width:5%;overflow: hidden;}
    
    .container .additional-item tbody tr td:nth-child(11){font-weight: bold;color:rgb(138, 43, 23);}
    .container .additional-item tr td:nth-child(11){width:10%;overflow: hidden;}
    .container .additional-item tr td:nth-child(12){width:7.5%;overflow: hidden;}
    .container .additional-item tr td:nth-child(12) input{width:50%;margin:auto;text-align: center;}
    .container .additional-item tr td:nth-child(13){width:12%;overflow: hidden;}
    .container .additional-item tr td:nth-child(13) a{display: block;width: 95%;margin-left: 5%;height: 30px;line-height: 15px;font-size: 100%;}

    lscin, 12 Апреля 2016

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