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

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

    +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
    $vv = $_GET['new'];
    $v1 = $_GET['1'];
    $v2 = $_GET['2'];
    $v3 = $_GET['3'];
    $v4 = $_GET['4'];
    $v5 = $_GET['5'];
    $v6 = $_GET['6'];
    $v7 = $_GET['7'];
    $v8 = $_GET['8'];
    $v9 = $_GET['9'];
    $v10 = $_GET['10'];
    $v11 = $_GET['11'];
    $v12 = $_GET['12'];
    if (mb_strlen($vv) >= 1) {
    	mysql_query ("INSERT INTO vote (title, votes) VALUES ('$vv', '0')");
    	header('Location: /index.php');
    	exit;
    }
    if (mb_strlen($v1) >= 1 or mb_strlen($v2) >= 1 or mb_strlen($v3) >= 1 or mb_strlen($v4) >= 1 or mb_strlen($v5) >= 1 or mb_strlen($v6) >= 1 or mb_strlen($v7) >= 1 or mb_strlen($v8) >= 1 or mb_strlen($v9) >= 1 or mb_strlen($v10) >= 1 or mb_strlen($v11) >= 1 or mb_strlen($v12) >= 1) {
    	mysql_query ("UPDATE vote SET title='$v1' WHERE id='1'");
    	mysql_query ("UPDATE vote SET title='$v2' WHERE id='2'");
    	mysql_query ("UPDATE vote SET title='$v3' WHERE id='3'");
    	mysql_query ("UPDATE vote SET title='$v4' WHERE id='4'");
    	mysql_query ("UPDATE vote SET title='$v5' WHERE id='5'");
    	mysql_query ("UPDATE vote SET title='$v6' WHERE id='6'");
    	mysql_query ("UPDATE vote SET title='$v7' WHERE id='7'");
    	mysql_query ("UPDATE vote SET title='$v8' WHERE id='8'");
    	mysql_query ("UPDATE vote SET title='$v9' WHERE id='9'");
    	mysql_query ("UPDATE vote SET title='$v10' WHERE id='10'");
    	mysql_query ("UPDATE vote SET title='$v11' WHERE id='11'");
    	mysql_query ("UPDATE vote SET title='$v12' WHERE id='12'");
    	header('Location: /');
    	exit;
    }

    Сохранение вопросов в опроснике.

    slowpoke59rus, 27 Апреля 2016

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

    +2

    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
    function plays(){
    var snd = new Audio("http://boobooka.com/wp-content/uploads/2013/02/33bells33.mp3");   
    snd.preload = "auto";   
    snd.play();
    }
    
    function showTime()
    {
    var dat = new Date();
    var ch = dat.getDate();
    var montha = new Array();
    montha[0] = "января";
    montha[1] = "февраля";
    montha[2] = "марта";
    montha[3] = "апреля";
    montha[4] = "мая";
    montha[5] = "июня";
    montha[6] = "июля";
    montha[7] = "августа";
    montha[8] = "сентября";
    montha[9] = "октября";
    montha[10] = "ноября";
    montha[11] = "декабря";
    var mon = montha[dat.getMonth()];
    var ye = dat.getYear()+ 1900;
    var ned = dat.getDay();
    var day = new Array();
    day[1] = "Понедельник";
    day[2] = "Вторник";
    day[3] = "Среда";
    day[4] = "Четверг";
    day[5] = "Пятница";
    day[6] = "Суббота";
    day[0] = "Воскресенье";
    var nedel = day[dat.getDay()];
    var H = '' + dat.getHours();
    H = H.length<2 ? '0' + H:H;
    var M = '' + dat.getMinutes();
    M = M.length<2 ? '0' + M:M;
    var S = '' + dat.getSeconds();
    S =S.length<2 ? '0' + S:S;
    var clock = H + ':' + M + ':' + S;
    var cl = H + M + S;
    var chislo = ch+" "+mon;
    var chisl = ye+" года";
    document.getElementById('time_div').innerHTML=clock;
    document.getElementById('ned_div').innerHTML=nedel;
    document.getElementById('chi_div').innerHTML=chislo;
    document.getElementById('chis_div').innerHTML=chisl;
    if(clock == '09:00:00'){if(1<=ned && ned<=6){plays();}}
    if(clock == '09:40:00'){if(1<=ned && ned<=6){plays();}}
    if(clock == '09:50:00'){if(1<=ned && ned<=6){plays();}}
    if(clock == '10:30:00'){if(1<=ned && ned<=6){plays();}}
    if(clock == '10:40:00'){if(1<=ned && ned<=6){plays();}}
    if(clock == '11:20:00'){if(1<=ned && ned<=6){plays();}}
    if(clock == '11:40:00'){if(1<=ned && ned<=6){plays();}}
    if(clock == '12:20:00'){if(1<=ned && ned<=6){plays();}}
    if(clock == '12:30:00'){if(1<=ned && ned<=6){plays();}}
    if(clock == '13:10:00'){if(1<=ned && ned<=6){plays();}}
    if(clock == '13:20:00'){if(1<=ned && ned<=6){plays();}}
    if(clock == '14:00:00'){if(1<=ned && ned<=6){plays();}}
    if(clock == '14:20:00'){if(1<=ned && ned<=6){plays();}}
    if(clock == '15:00:00'){if(1<=ned && ned<=6){plays();}}
    if(clock == '15:10:00'){if(1<=ned && ned<=6){plays();}}
    if(clock == '15:50:00'){if(1<=ned && ned<=6){plays();}}
    if(clock == '16:00:00'){if(1<=ned && ned<=6){plays();}}
    if(clock == '16:40:00'){if(1<=ned && ned<=6){plays();}}
    if(clock == '16:45:00'){if(1<=ned && ned<=6){plays();}}
    if(clock == '17:25:00'){if(1<=ned && ned<=6){plays();}}
    if(clock == '17:30:00'){if(1<=ned && ned<=6){plays();}}
    if(clock == '18:10:00'){if(1<=ned && ned<=6){plays();}}
    if(clock == '18:15:00'){if(1<=ned && ned<=6){plays();}}
    if(clock == '18:55:00'){if(1<=ned && ned<=6){plays();}}
    setTimeout(showTime,1000);
    if(1<=ned && ned<=6)
    {
        if(cl >= 090000 && cl < 094000) {document.getElementById('mes_div').innerHTML="Идет 1-й урок (09:00-09:40)";}
        if(cl >= 094000 && cl < 095000) {document.getElementById('mes_div').innerHTML="ПЕРЕМЕНА!!! (09:40-09:50)";}
        if(cl >= 095000 && cl < 103000) {document.getElementById('mes_div').innerHTML="Идет 2-й урок (09:50-10:30)";}
        if(cl >= 103000 && cl < 104000) {document.getElementById('mes_div').innerHTML="ПЕРЕМЕНА!!! (10:30-10:40)";}
        if(cl >= 104000 && cl < 112000) {document.getElementById('mes_div').innerHTML="Идет 3-й урок (10:40-11:20)";}
        if(cl >= 112000 && cl < 114000) {document.getElementById('mes_div').innerHTML="ПЕРЕМЕНА!!! (11:20-11:40)";}
        if(cl >= 114000 && cl < 122000) {document.getElementById('mes_div').innerHTML="Идет 4-й урок (11:40-12:20)";}
        if(cl >= 122000 && cl < 123000) {document.getElementById('mes_div').innerHTML="ПЕРЕМЕНА!!! (12:20-12:30)";}
        if(cl >= 123000 && cl < 131000) {document.getElementById('mes_div').innerHTML="Идет 5-й урок (12:30-13:10)";}
        if(cl >= 131000 && cl < 132000) {document.getElementById('mes_div').innerHTML="ПЕРЕМЕНА!!! (13:10-13:20)";}
        if(cl >= 132000 && cl < 140000) {document.getElementById('mes_div').innerHTML="Идет 6-й урок (13:20-14:00)";}
        if(cl >= 140000 && cl < 142000) {document.getElementById('mes_div').innerHTML="ПЕРЕМЕНА!!! (14:00-14:20)";}
        if(cl >= 142000 && cl < 150000) {document.getElementById('mes_div').innerHTML="Идет 7-й урок (14:20-15:00)";}
        if(cl >= 150000 && cl < 151000) {document.getElementById('mes_div').innerHTML="ПЕРЕМЕНА!!! (15:00-15:10)";}
        if(cl >= 151000 && cl < 155000) {document.getElementById('mes_div').innerHTML="Идет 8-й урок (15:10-15:50)";}
        if(cl >= 155000 && cl < 160000) {document.getElementById('mes_div').innerHTML="ПЕРЕМЕНА!!! (15:50-16:00)";}
        if(cl >= 160000 && cl < 164000) {document.getElementById('mes_div').innerHTML="Идет 9-й урок (16:00-16:40)";}
        if(cl >= 164000 && cl < 164500) {document.getElementById('mes_div').innerHTML="ПЕРЕМЕНА!!! (16:40-16:45)";}
        if(cl >= 164500 && cl < 172500) {document.getElementById('mes_div').innerHTML="Идет 10-й урок (16:45-17:25)";}
        if(cl >= 172500 && cl < 173000) {document.getElementById('mes_div').innerHTML="ПЕРЕМЕНА!!! (17:25-17:30)";}
        if(cl >= 173000 && cl < 181000) {document.getElementById('mes_div').innerHTML="Идет 11-й урок (17:30-18:10)";}
        if(cl >= 181000 && cl < 181500) {document.getElementById('mes_div').innerHTML="ПЕРЕМЕНА!!! (18:10-18:15)";}
        if(cl >= 181500 && cl < 185500) {document.getElementById('mes_div').innerHTML="Идет 12-й урок (18:15-18:55)";}
    if(cl >= 185500 && cl < 235959) {document.getElementById('mes_div').innerHTML="  ";}

    Исходный код из "научно-практической" работы школьника.
    Прихватил с конференции. (Не всё влезло)

    RigFox, 27 Апреля 2016

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

    +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
    <select tabindex="8" id="inputBirthMonth" class="input-small form-control" name="month">
                            <option value="0">--</option>
                            <option
                                value="1" <?php $month = 0;
                            if (isset($specificdata['month'])) {
                                $month = @$specificdata['month'];
                            }
                            if (1 == $month) {
                                echo "selected";
                            }
                            ?»<?php echo lang('Main:january'); ?></option>
                            <option
                                value="2" <?php if (2 == @$month) {
                                echo "selected";
                            }
                            ?»<?php echo lang('Main:february'); ?></option>
                            <option
                                value="3" <?php if (3 == @$month) {
                                echo "selected";
                            }
                            ?»<?php echo lang('Main:march'); ?></option>
                            <option
                                value="4" <?php if (4 == @$month) {
                                echo "selected";
                            }
                            ?»<?php echo lang('Main:april'); ?></option>
                            <option
                                value="5" <?php if (5 == @$month) {
                                echo "selected";
                            }
                            ?»<?php echo lang('Main:may'); ?></option>
                            <option
                                value="6" <?php if (6 == @$month) {
                                echo "selected";
                            }
                            ?»<?php echo lang('Main:june'); ?></option>
                            <option
                                value="7" <?php if (7 == @$month) {
                                echo "selected";
                            }
                            ?»<?php echo lang('Main:july'); ?></option>
                            <option
                                value="8" <?php if (8 == @$month) {
                                echo "selected";
                            }
                            ?»<?php echo lang('Main:august'); ?></option>
                            <option
                                value="9" <?php if (9 == @$month) {
                                echo "selected";
                            }
                            ?»<?php echo lang('Main:september'); ?></option>
                            <option
                                value="10" <?php if (10 == @$month) {
                                echo "selected";
                            }
                            ?»<?php echo lang('Main:october'); ?></option>
                            <option
                                value="11" <?php if (11 == @$month) {
                                echo "selected";
                            }
                            ?»<?php echo lang('Main:november'); ?></option>
                            <option
                                value="12" <?php if (12 == @$month) {
                                echo "selected";
                            }
                            ?»<?php echo lang('Main:december'); ?></option>
                        </select>

    Month dropdown select in registration form

    tatocaster, 25 Апреля 2016

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

    +2

    1. 1
    2. 2
    3. 3
    4. 4
    int a = -1;
    while(+a){
        if(a == 0) break;
    }

    puksus, 22 Апреля 2016

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

    +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
    public function get($userId = null, $advense = false) {
            
            if ($userId === null) $userId = $this->currentId;
            
            $user = DB::table('users')
                    ->select(
                            '*',
                            DB::raw('IF(email IS NOT NULL AND email_confirm IS NULL, 1, 0) AS email_confirm'),
                            DB::raw('IF(phone IS NOT NULL AND phone_confirm IS NULL, 1, 0) AS phone_confirm'),
                            DB::raw('IF(birthday IS NOT NULL, TIMESTAMPDIFF(YEAR,birthday,CURDATE()), NULL) AS age'),
                            DB::raw('IF(phone IS NOT NULL AND phone_confirm IS NULL AND email IS NOT NULL AND email_confirm IS NULL AND (new_first_name IS NOT NULL OR new_last_name IS NOT NULL OR new_status_text IS NOT NULL OR new_image_url IS NOT NULL), 1, 0) AS on_moderate'))
                    ->where('id', $userId)->first();
            
            if ($user === null) throw new Exception ('User is not found', 404);
            unset($user->password);
            $user->locality           = Geo::get($user->locality_id);
            $rating = $this->rating($userId);
            $user->rating           = (float)$rating->avg;
            $user->rating_counter   = (int)$rating->cnt;
            $user->counters        = $this->getCounters($userId);
    
            
            $contact = $this->contacts->isMyContact($userId);
            if ($userId != $this->currentId) {
                $user->created = null;
                $user->updated = null;
                $user->birthday = null;
                $user->email_confirm = null;
                $user->phone_confirm = null;
                $user->subscribed = null;
                $user->organizations = null;
                $contact = $this->contacts->isMyContact($userId);
                // Если пользователь не контакт авторизованного, сотрем контактную информацию
                if ( $contact === null || $contact === 'declined') {
                    $user->phone = null;
                    $user->email = null;
                    $user->last_name = mb_substr($user->last_name, 0, 1, 'UTF-8');
                }
                
            } else {
                if($user->new_first_name !== null) {
                    $user->first_name = $user->new_first_name;
                }
                if($user->new_last_name !== null) {
                    $user->last_name = $user->new_last_name;
                }
                if($user->new_image_url !== null) {
                    $user->image_url = $user->new_image_url;
                }
                if($user->new_status_text !== null) {
                    $user->status_text = $user->new_status_text;
                }
                $user->organizations = Organizations\Organizations::getByUserId($userId);
                $user->is_followed     = null;
                $user->is_my_contact   = null;
                $user->has_my_contact  = null;
                $user->has_my_opinion  = null;
            }
            unset($user->new_status_text);
            unset($user->new_image_url);
            unset($user->new_last_name);
            unset($user->new_first_name);
            unset($user->reset_code);
    
            
            $user->is_followed     = $this->followers->isFollowed($userId);
            $user->is_my_contact   = $this->contacts->isMyContact($userId);
            $user->has_my_contact  = $this->contacts->hasMyContact($userId);
            return $user;
            
        }

    Тыдыдыдыдыыыц, laravel code О_О
    Что же тут вообще происходит?

    lemax, 20 Апреля 2016

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

    +2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    static void DelayNZOKParse(string filename)
    {
        ThreadPool.QueueUserWorkItem(new WaitCallback(startNZOKParseFile), filename);
    }
    static void startNZOKParseFile(object state)
    {
        Thread.Sleep(1000);
        startNZOKParseFile(state as string);
    }

    вот это

    apostolovd, 14 Апреля 2016

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

    +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
    function op_v($n0 = NULL,$n1 = NULL,$n2 = NULL,$n3 = NULL,$n4 = NULL,$n5 = NULL,$n6 = NULL,$n7 = NULL,$n8 = NULL,$n9 = NULL, $sql) {
    //быдлокод гг
    if ($sql==0){
     if(!empty($n0)) $x0 = '<option value="0">'.$n0.'</option>';
     if(!empty($n1)) $x1 = '<option value="1">'.$n1.'</option>';
     if(!empty($n2)) $x2 = '<option value="2">'.$n2.'</option>';
     if(!empty($n3)) $x3 = '<option value="3">'.$n3.'</option>';
     if(!empty($n4)) $x4 = '<option value="4">'.$n4.'</option>';
     if(!empty($n5)) $x5 = '<option value="5">'.$n5.'</option>';
     if(!empty($n6)) $x6 = '<option value="6">'.$n6.'</option>';
     if(!empty($n7)) $x7 = '<option value="7">'.$n7.'</option>';
     if(!empty($n8)) $x8 = '<option value="8">'.$n8.'</option>';
     if(!empty($n9)) $x9 = '<option value="9">'.$n9.'</option>';
    
     $res = $x0.$x1.$x2.$x3.$x4.$x5.$x6.$x7.$x8.$x9;
     }
     if ($sql==1){
     if(!empty($n1)) $x0 = '<option value="1">'.$n1.'</option>';
     if(!empty($n0)) $x1 = '<option value="0">'.$n0.'</option>';
     if(!empty($n2)) $x2 = '<option value="2">'.$n2.'</option>';
     if(!empty($n3)) $x3 = '<option value="3">'.$n3.'</option>';
     if(!empty($n4)) $x4 = '<option value="4">'.$n4.'</option>';
     if(!empty($n5)) $x5 = '<option value="5">'.$n5.'</option>';
     if(!empty($n6)) $x6 = '<option value="6">'.$n6.'</option>';
     if(!empty($n7)) $x7 = '<option value="7">'.$n7.'</option>';
     if(!empty($n8)) $x8 = '<option value="8">'.$n8.'</option>';
     if(!empty($n9)) $x9 = '<option value="9">'.$n9.'</option>';
    
     $res = $x0.$x1.$x2.$x3.$x4.$x5.$x6.$x7.$x8.$x9;
     }
     
     if ($sql==2){
     if(!empty($n2)) $x0 = '<option value="2">'.$n2.'</option>';
     if(!empty($n0)) $x1 = '<option value="0">'.$n0.'</option>';
     if(!empty($n1)) $x2 = '<option value="1">'.$n1.'</option>';
     if(!empty($n3)) $x3 = '<option value="3">'.$n3.'</option>';
     if(!empty($n4)) $x4 = '<option value="4">'.$n4.'</option>';
     if(!empty($n5)) $x5 = '<option value="5">'.$n5.'</option>';
     if(!empty($n6)) $x6 = '<option value="6">'.$n6.'</option>';
     if(!empty($n7)) $x7 = '<option value="7">'.$n7.'</option>';
     if(!empty($n8)) $x8 = '<option value="8">'.$n8.'</option>';
     if(!empty($n9)) $x9 = '<option value="9">'.$n9.'</option>';
     
     $res = $x0.$x1.$x2.$x3.$x4.$x5.$x6.$x7.$x8.$x9;
     }
    
    if ($sql==3){
     if(!empty($n3)) $x0 = '<option value="3">'.$n3.'</option>';
     if(!empty($n0)) $x1 = '<option value="0">'.$n0.'</option>';
     if(!empty($n1)) $x2 = '<option value="1">'.$n1.'</option>';
     if(!empty($n2)) $x3 = '<option value="2">'.$n2.'</option>'; 
     if(!empty($n4)) $x4 = '<option value="4">'.$n4.'</option>';
     if(!empty($n5)) $x5 = '<option value="5">'.$n5.'</option>';
     if(!empty($n6)) $x6 = '<option value="6">'.$n6.'</option>';
     if(!empty($n7)) $x7 = '<option value="7">'.$n7.'</option>';
     if(!empty($n8)) $x8 = '<option value="8">'.$n8.'</option>';
     if(!empty($n9)) $x9 = '<option value="9">'.$n9.'</option>';
    
     $res = $x0.$x1.$x2.$x3.$x4.$x5.$x6.$x7.$x8.$x9;
     }
    
    if ($sql==4){
     if(!empty($n4)) $x0 = '<option value="4">'.$n4.'</option>';
     if(!empty($n0)) $x1 = '<option value="0">'.$n0.'</option>';
     if(!empty($n1)) $x2 = '<option value="1">'.$n1.'</option>';
     if(!empty($n2)) $x3 = '<option value="2">'.$n2.'</option>';
     if(!empty($n3)) $x4 = '<option value="3">'.$n3.'</option>';
     if(!empty($n5)) $x5 = '<option value="5">'.$n5.'</option>';
     if(!empty($n6)) $x6 = '<option value="6">'.$n6.'</option>';
     if(!empty($n7)) $x7 = '<option value="7">'.$n7.'</option>';
     if(!empty($n8)) $x8 = '<option value="8">'.$n8.'</option>';
     if(!empty($n9)) $x9 = '<option value="9">'.$n9.'</option>';
    
     $res = $x0.$x1.$x2.$x3.$x4.$x5.$x6.$x7.$x8.$x9;
     }
    
    if ($sql==5){
     if(!empty($n5)) $x0 = '<option value="5">'.$n5.'</option>';
     if(!empty($n0)) $x1 = '<option value="0">'.$n0.'</option>';
     if(!empty($n1)) $x2 = '<option value="1">'.$n1.'</option>';
     if(!empty($n2)) $x3 = '<option value="2">'.$n2.'</option>';
     if(!empty($n3)) $x4 = '<option value="3">'.$n3.'</option>';
     if(!empty($n4)) $x5 = '<option value="4">'.$n4.'</option>';
     if(!empty($n6)) $x6 = '<option value="6">'.$n6.'</option>';
     if(!empty($n7)) $x7 = '<option value="7">'.$n7.'</option>';
     if(!empty($n8)) $x8 = '<option value="8">'.$n8.'</option>';
     if(!empty($n9)) $x9 = '<option value="9">'.$n9.'</option>';
    и так далее...

    привет из wap'а

    odoviez, 10 Апреля 2016

    Комментарии (13)
  9. 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)
  10. PHP / Говнокод #19762

    +2

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

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

    Sh1tM4ker, 06 Апреля 2016

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