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

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

    +156

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    $query = "INSERT INTO news (title, img_url, subtitle, content, date, time, id) 
    	VALUES (\"" .
    	$_POST["title"] . "\", \"" .
    	$_POST["img_url"] . "\", \"" .
    	$_POST["subtitle"] . "\", \"" .
    	$_POST["content"] . "\", \"" .
    	date("Y-m-d") . "\", \"" .
    	time() . "\", " .
    	DEFAULT . ");";

    только начал php. уверень, есть решение поэлегантнее этого

    artembegood, 05 Января 2015

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

    +156

    1. 1
    document.write('Well, I broke your script');

    Я знаю что document.write это плохо, но использование document.write ломает jsfiddle :D
    http://jsfiddle.net/volter9/x29Lzvu6/

    volter9, 05 Января 2015

    Комментарии (1)
  4. JavaScript / Говнокод #17404

    +156

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    if (!!window.Worker){
        var worker = new Worker('worker.js');
        worker.postMessage('Hellow World');
        worker.onmessage = function (e){
          alert(e.data);
        };
      }

    Из статьи на швабре: /post/132785/

    kingmonstr, 05 Января 2015

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

    +156

    1. 1
    2. 2
    3. 3
    $permissions = Array(
            'add'       => array('custom_order_send', 'send_termin_request'),
    		'insert'    => Array('custom_order_send', 'send_termin_request'),

    Elfet, 29 Декабря 2014

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

    +156

    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
    foreach ($mass AS $productId => $colorsList)
            {
                foreach ($colorsList AS $colorId => $sizesList)
                {
                    foreach ($sizesList AS $sizeId => $options)
                    {
                        $this->setTable('shop_products')
                             ->update(array(
                                    'price' => $options['price']
                                ),
                                $this->getAdapter()->quoteInto('id = ?', $productId)
                             );
                        break;
                    }
                }
            }

    Автор пытается взять первый элемент многомерного массива вот такой конструкцией

    p0p, 26 Декабря 2014

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

    +156

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    router.get('/', function(req, res){
        apis.getApis(function (data, error) {
            res.render('./documentation/index',
                {
                    error: error,
                    apis: data
                });
            });
        }
    );

    Сказали напилить на ноде сайтик, который генерит документацию из ответа сервера с API. Сижу и бомблю с количества лишних действий в контроллере из-за обязательных ФУНКЦИЙ ОБРАТНОГО ВЫЗОВА.

    heyzea1, 26 Декабря 2014

    Комментарии (15)
  8. JavaScript / Говнокод #17358

    +156

    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
    94. 94
    95. 95
    96. 96
    97. 97
    98. 98
    jQuery(document).ready(function(){ 
    jQuery("a.m1_show").click(function(){ 
    jQuery('div#emul_1').addClass('mshow').show();
    jQuery('div#emul_2').addClass('minvis').hide();
    jQuery('div#emul_3').addClass('minvis').hide();
    jQuery('div#emul_4').addClass('minvis').hide();
    jQuery('div#emul_5').addClass('minvis').hide();
    //jQuery('li#emul_6').addClass('minvis').hide();
    });
    });
    
    jQuery(document).ready(function(){ 
    jQuery("a.m2_show").click(function(){ 
    jQuery('div#emul_2').addClass('mshow').show();
    jQuery('div#emul_1').addClass('minvis').hide();
    jQuery('div#emul_3').addClass('minvis').hide();
    jQuery('div#emul_4').addClass('minvis').hide();
    jQuery('div#emul_5').addClass('minvis').hide();
    //jQuery('li#emul_6').addClass('minvis').hide();
    });
    });
    
    jQuery(document).ready(function(){ 
    jQuery("a.m3_show").click(function(){ 
    jQuery('div#emul_3').addClass('mshow').show();
    jQuery('div#emul_1').addClass('minvis').hide();
    jQuery('div#emul_2').addClass('minvis').hide();
    jQuery('div#emul_4').addClass('minvis').hide();
    jQuery('div#emul_5').addClass('minvis').hide();
    //jQuery('li#emul_6').addClass('minvis').hide();
    });
    });
    
    jQuery(document).ready(function(){ 
    jQuery("a.m4_show").click(function(){ 
    jQuery('div#emul_4').addClass('mshow').show();
    jQuery('div#emul_1').addClass('minvis').hide();
    jQuery('div#emul_3').addClass('minvis').hide();
    jQuery('div#emul_2').addClass('minvis').hide();
    jQuery('div#emul_5').addClass('minvis').hide();
    //jQuery('li#emul_6').addClass('minvis').hide();
    });
    });
    
    jQuery(document).ready(function(){ 
    jQuery("a.m5_show").click(function(){ 
    jQuery('div#emul_5').addClass('mshow').show();
    jQuery('div#emul_1').addClass('minvis').hide();
    jQuery('div#emul_3').addClass('minvis').hide();
    jQuery('div#emul_2').addClass('minvis').hide();
    jQuery('div#emul_4').addClass('minvis').hide();
    //jQuery('li#emul_6').addClass('minvis').hide();
    });
    });
    
    function but_1 () {
    jQuery('span#emul_img_1').addClass('img_none').hide();
    jQuery('span#emul_img_2').addClass('img_inline').show();
    jQuery('span#emul_img_3').addClass('img_inline').show();
    jQuery('span#emul_img_4').addClass('img_inline').show();
    jQuery('span#emul_img_5').addClass('img_inline').show();
    
    
    jQuery('span#emul_img_none_1').addClass('img_inline').show();
    jQuery('span#emul_img_none_1').addClass('current_tab').show();
    
    jQuery('span#emul_img_none_2').addClass('img_none').hide();
    jQuery('span#emul_img_none_3').addClass('img_none').hide();
    jQuery('span#emul_img_none_4').addClass('img_none').hide();
    jQuery('span#emul_img_none_5').addClass('img_none').hide();
    }
    
    function but_2 () {
    jQuery('span#emul_img_2').addClass('img_none').hide();
    jQuery('span#emul_img_1').addClass('img_inline').show();
    jQuery('span#emul_img_3').addClass('img_inline').show();
    jQuery('span#emul_img_4').addClass('img_inline').show();
    jQuery('span#emul_img_5').addClass('img_inline').show();
    
    jQuery('span#emul_img_none_2').addClass('img_inline').show();
    jQuery('span#emul_img_none_2').addClass('current_tab').show();
    
    jQuery('span#emul_img_none_1').addClass('img_none').hide();
    jQuery('span#emul_img_none_3').addClass('img_none').hide();
    jQuery('span#emul_img_none_4').addClass('img_none').hide();
    jQuery('span#emul_img_none_5').addClass('img_none').hide();
    
    }
    
    function but_3 () {
    jQuery('span#emul_img_3').addClass('img_none').hide();
    jQuery('span#emul_img_2').addClass('img_inline').show();
    jQuery('span#emul_img_1').addClass('img_inline').show();
    jQuery('span#emul_img_4').addClass('img_inline').show();
    jQuery('span#emul_img_5').addClass('img_inline').show();
    
    jQuery('span#emul_img_none_3').addClass('img_inline').show();
    jQuery('span#emul_img_none_3').addClass('current_tab').show();

    Сегодня наткнулся на такой вот скрипт для табов. Кому нужен - воруйте. Скрипт лаконичный. Работает шустро.

    Serj, 23 Декабря 2014

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

    +156

    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
    <?php
    foreach ($details->result_array() as $row) {
        $name = $row['name'];
        $email = $row['email'];
        $avatar = $row['avatar'];
        $access = $row['access'];
        $notify = $row['notify'];
        $notifysms = $row['notifysms'];
        $mobile = $row['mobile'];
        $signature = $row['signature'];
    
        $address = $row['address'];
        $city = $row['city'];
        $state = $row['state'];
        $zip = $row['zip'];
        $country = $row['country'];
        $phone = $row['phone'];
        $mobile = $row['mobile'];
        
        $external_state = $row['external_state'];
        $external_auth = $row['external_auth'];
    }
    ?>

    Убивает к тому же то, что этот кусок написан в файле представления. Еще спрашивают, почему я решил уволиться :)

    omegascorp, 19 Декабря 2014

    Комментарии (11)
  10. JavaScript / Говнокод #17330

    +156

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    function(loaded) {
        
        var sale=$("#markupz").val();
        var markup=$("#salez").val();
    		
         ...
    								
    });

    утонул в таком коде

    govnokoder2, 18 Декабря 2014

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

    +156

    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
    //prepare ids
    $temp_char = "";
    $temp_id = "";
    $ids_array = array();
    
    for ($i = 0; $i < strlen($ids); $i ++) {
    	$temp_char = substr($ids, $i, 1);
    	
    	if ($temp_char != ",") {
    		$temp_id .= $temp_char;
    		
    		if ($i == (strlen($ids) - 1)) {
    			array_push($ids_array, $temp_id);
    			$temp_id = "";
    		}
    	} else {
    		array_push($ids_array, $temp_id);
    		$temp_id = "";
    	}
    }

    Распарсил строку с айдишниками, разделенными запятыми. Минут 15 точно потратил.

    sbbn, 14 Декабря 2014

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