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

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

    +163

    1. 1
    2. 2
    3. 3
    4. 4
    foreach($_REQUEST as $_ind => $_val) { $_REQUEST[$_ind] = mysql_real_escape_string($_REQUEST[$_ind]); }
    foreach($_POST as $_ind => $_val) { $_POST[$_ind] = mysql_real_escape_string($_POST[$_ind]); }
    foreach($_GET as $_ind => $_val) { $_GET[$_ind] = mysql_real_escape_string($_GET[$_ind]); }
    foreach($_COOKIE as $_ind => $_val) { $_COOKIE[$_ind] = mysql_real_escape_string($_COOKIE[$_ind]); }

    Защита от инъекций

    ReckO, 22 Января 2012

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

    +145

    1. 1
    Эй, Хренкин, блять твою мать, ты мне так и не ответил, что ты выбираешь мир или войну. Я объясню что тебе предстоит пережить для начала нашествие школоты с лучемётами(решается с помощью каптчи, но при этом потеряешь больше 50% посетителей так как им будет неудобно общаться) далее бесконечные звонки даже среди ночи полный дефейс сайта и как крайняя мера досс-атака(денег на неё у меня хватит не переживай, твой гамна сайт вылетит из индекса и постить тут будут только 3-4 долбоёба), да и ещё пока не буду сообщать будет для тебя сюрпризом(после этого ты повесишься на своих шнурках). Что скажижь Хренкин? Жду ответа. Кому нужен лучемет пишите на [email protected] объясню как работает и т.д.

    Ггг этот мудак удалил мой аккаунт, а я все ещё могу тут постить

    KomprendaTerrorSquad, 25 Декабря 2010

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

    +158

    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
    if (count ( $tag_array )) {
    
    				$tag_array = "(" . implode ( ",", $tag_array ) . ")";
    
    			} else {
    
    				$tag_array = "('undefined')";
    
    			}
    
    			$db->free ();
    
    			$sql_select = "SELECT id, autor, date, short_story, SUBSTRING(full_story, 1, 15) as full_story, xfields, title, category, alt_name, comm_num, allow_comm, allow_rate, rating, vote_num, news_read, approve, flag, editdate, editor, reason, view_edit, tags FROM " . PREFIX . "_post where {$stop_list} AND approve" . $where_date . " ORDER BY " . $news_sort_by . " " . $news_direction_by . " LIMIT " . $cstart . "," . $config['news_number'];
    			$sql_count = "SELECT COUNT(*) as count FROM " . PREFIX . "_post where {$stop_list} AND approve" . $where_date;
    			$allow_active_news = true;
    
    			$tag_array = array ();
    			unset ( $tag_array );

    Все классно... а что в конце.. убило..

    Aios, 20 Ноября 2010

    Комментарии (98)
  5. SQL / Говнокод #3546

    −857

    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
    procedure xxx_procedure
    is
    --   lngIDVidPP Number;
       sSQL       varchar2(4000);
    begin
    sSQL := '';
    sSQL := sSQL || ' Declare ';
    sSQL := sSQL || '    lngIDVidPP Number; ';
    sSQL := sSQL || '    lngColRec  Number; ';
    sSQL := sSQL || '    strTypeProc Varchar2(255); ';
    sSQL := sSQL || ' BEGIN ';
    sSQL := sSQL || ' for rec in (select f.param2 , A.idpp, pp.crastr, pp.cvector, a.param1, a.et, a.tet ';
    sSQL := sSQL || '  from table1 e, T_IDPP@' || 'app' || '_' ||'xxx' || ' a, table2 f, ';
    sSQL := sSQL || '   t_pp_card@' || 'app' || '_' || 'xxx' || ' pp,  refitem r';
    sSQL := sSQL || '  where ';
    sSQL := sSQL || '   e.param1 = a.param1 ';
    sSQL := sSQL || '   and e.id_building = F.ID_BUILDING ';
    sSQL := sSQL || '   and F.FLOOR_NUMBER = a.et ';
    sSQL := sSQL || '   and R.REFERENCEID = 2019 and R.ITEMID = F.ID_FLOOR_TYPE';
    sSQL := sSQL || '   and R.CODE = a.tet';
    sSQL := sSQL || '   and a.idpp = pp.cidpp)';
    sSQL := sSQL || '  loop ';
    sSQL := sSQL || '     lngColRec := 0; ';
    sSQL := sSQL || '     lngIDVidPP := 0; ';
    sSQL := sSQL || '     SELECT COUNT(*) INTO lngColRec FROM T_PROCESS_PP@' || 'app' || '_' || 'xxx || ' Z ';
    sSQL := sSQL || '                     WHERE Z.PPP_UNOM = rec.param1 AND Z.PPP_ET = rec.et AND Z.PPP_TET = rec.tet; ';
    sSQL := sSQL || '     if lngColRec = 0 then ';
    sSQL := sSQL || '        if BITAND(rec.crastr, 8) <> 0 and BITAND(rec.cvector, 8) <> 0 then ';
    sSQL := sSQL || '           lngIDVidPP := 50868; ';
    sSQL := sSQL || '        else ';
    sSQL := sSQL || '           if BITAND(rec.crastr, 8) <> 0 then ';
    sSQL := sSQL || '              lngIDVidPP := 50866; ';
    sSQL := sSQL || '           else ';
    sSQL := sSQL || '              lngIDVidPP := 50867; ';
    sSQL := sSQL || '           end if; ';
    sSQL := sSQL || '        end if; ';
    sSQL := sSQL || '        update table2 f ';
    sSQL := sSQL || '            set f.xx      = rec.idpp, ';
    sSQL := sSQL || '                f.xxx   = lngIDVidPP, ';
    sSQL := sSQL || '                f.xxxx = 54554 ';
    sSQL := sSQL || '          where f.xxxxx = rec.id_floor; ';
    sSQL := sSQL || '     else  '; --if lngColRec > 0 then
    sSQL := sSQL || '          strTypeProc := Null; ';
    sSQL := sSQL || '          SELECT Y.PH_ACTION_KEY INTO strTypeProc ';
    sSQL := sSQL || '            FROM T_PROCESS_HEAD@' || 'app' || '_' || 'SGP' || ' Y ';
    sSQL := sSQL || '            WHERE ';
    sSQL := sSQL || '                 Y.PHID IN (SELECT X.PPP_PHID ';
    ...... 10 строк вырезано из-за ограничения 4000символов
    sSQL := sSQL || '               if BITAND(rec.crastr, 8) <> 0 and BITAND(rec.cvector, 8) <> 0 then ';
    sSQL := sSQL || '                  lngIDVidPP := 50868; ';
    sSQL := sSQL || '               else ';
    sSQL := sSQL || '                  if BITAND(rec.crastr, 8) <> 0 then ';
    sSQL := sSQL || '                     lngIDVidPP := 50866; ';
    sSQL := sSQL || '                  else ';
    sSQL := sSQL || '                     lngIDVidPP := 50867; ';
    sSQL := sSQL || '                  end if; ';
    sSQL := sSQL || '               end if; ';
    sSQL := sSQL || '                  update table3 f ';
    sSQL := sSQL || '                     set f.ID_PLANE_G = rec.idpp, ';
    sSQL := sSQL || '                     f.id_plane_scan = lngIDVidPP, ';
    sSQL := sSQL || '                     f.id_status_plane = 54552 ';
    sSQL := sSQL || '               where f.param1 = rec.param1; ';
    sSQL := sSQL || '           ELSE ';
    sSQL := sSQL || '                  update table3 f ';
    sSQL := sSQL || '                 set f.id_status_plane = 54552 ';
    sSQL := sSQL || '               where f.param1 = rec.param1; ';
    sSQL := sSQL || '           END IF; ';
    sSQL := sSQL || '     end if; ';  --if lngColRec > 0 then
    sSQL := sSQL || '   end loop;';
    sSQL := sSQL || '  null;';
    sSQL := sSQL || '  end;';
    
    EXECUTE IMMEDIATE sSQL;
            dbms_output.put_line ('Процедура xxx_procedure успешно создана');
    EXCEPTION
      WHEN OTHERS THEN dbms_output.put_line('Ошибка создания xxx_procedure. ' || SQLERRM);
    end;

    В связи с NDA названия изменены.

    kamapcuc, 23 Июня 2010

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

    +184

    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
    function reverse_string(str, len) {
    	if (len == 1) {
    		return str.charAt(0);
    	}
    	if (len == 2) {
    		return str.charAt(1) + str.charAt(0);
    	}
    	if (len == 3) {
    		return str.charAt(2) + str.charAt(1) + str.charAt(0);
    	}
    	if (len == 4) {
    		return str.charAt(3) + str.charAt(2) + str.charAt(1) + str.charAt(0);
    	}
    	if (len == 5) {
    		return str.charAt(4) + str.charAt(3) + str.charAt(2) + str.charAt(1) + str.charAt(0);
    	}
    	if (len == 6) {
    		return str.charAt(5) + str.charAt(5) + str.charAt(3) + str.charAt(2) + str.charAt(1) + str.charAt(0);
    	}
    	if (len == 7) {
    		return str.charAt(6) + str.charAt(5) + str.charAt(4) + str.charAt(3) + str.charAt(2) + str.charAt(1) + str.charAt(0);
    	}
    	if (len == 8) {
    		return str.charAt(7) + str.charAt(6) + str.charAt(5) + str.charAt(4) + str.charAt(3) + str.charAt(2) + str.charAt(1) + str.charAt(0);
    	}
    	if (len == 9) {
    		return str.charAt(8) + str.charAt(7) + str.charAt(6) + str.charAt(5) + str.charAt(4) + str.charAt(3) + str.charAt(2) + str.charAt(1) + str.charAt(0);
    	}
    	if (len == 10) {
    		return str.charAt(9) + str.charAt(8) + str.charAt(7) + str.charAt(6) + str.charAt(5) + str.charAt(4) + str.charAt(3) + str.charAt(2) + str.charAt(1) + str.charAt(0);
    	}
    };

    Переворачивание строки при помощи новейших технологий. Также ожидается движок (по содержанию конечно кусок говна, но по размерам похож), который позволит переворачивать строки любой длины (таким же методом). В-общем, прогноз неутешительный.

    eval, 11 Июня 2010

    Комментарии (98)
  7. Куча / Говнокод #2942

    +51.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
    .....
    <table width=100% border=1>
    <colgroup .....>
    .....
    <tr>
      <td colspan=2>(тут шапка)</td>
    </tr>
    <tr>
      <td width=60% colspan>(слева)</td>
      <td width=40% colspan>(справа)</td>
    </tr>
    .....
    </table> 
    .....

    Нету раздела html, поэтому решил наговнокодить тут :) Будет ли это говнокодом если верстать сайты так? Вообщем за и против div'ой и табличной верстки.. примеры данного куска с оптимальным содержанием..

    antigovnokoder, 06 Апреля 2010

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

    −9

    1. 1
    2. 2
    Is there PHP mysql_real_escape_string for postgresql?
    pg_escape_string

    https://www.php.net/manual/en/function.pg-escape-string.php

    real_escape_string, 23 Декабря 2021

    Комментарии (97)
  9. Си / Говнокод #27807

    +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
    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
    // https://github.com/j123123/sexpr_parse/blob/584fc23de71bebe02545214f819e16b720a2c1e2/my_struct_utils.c#L119
    
    blob *
    blob_scan_fromstream
    (
      FILE *stream
    )
    {
      size_t st_len = 0;
      size_t st_alloc;
      uint8_t *st = NULL;
    
      while(true)
      {
        const int fg = getc(stream);
        if(fg == EOF)
        {
          PRV_ERR_MACRO();
        }
        uint8_t c = fg;
        if(!isprint(fg))
        {
          PRV_ERR_MACRO();
        }
        switch(c)
        {
          case '\\':
            {
              int c2 = getc(stream);
              switch(c2)
              {
                case 'x':
                  {
                    int c3[2] =
                    {
                      getc(stream),
                      getc(stream)
                    };
                    uint8_t tmp[2];
    
                    for(size_t i = 0; i < 2; ++i)
                    {
                      switch(c3[i])
                      {
                        case '0' ... '9':
                          tmp[i] = c3[i]-'0';
                          break;
                        case 'a' ... 'f':
                          tmp[i] = c3[i]+10-'a';
                          break;
                        case 'A' ... 'F':
                          tmp[i] = c3[i]+10-'A';
                          break;
                        default:
                          PRV_ERR_MACRO();
                      }
                    }
                    M_PUSH(tmp[1] | tmp[0] << 4);
                  }
                  break;
                case '\\':
                  M_PUSH('\\');
                  break;
                case 't':
                  M_PUSH('\t');
                  break;
                case 'n':
                  M_PUSH('\n');
                  break;
                case '"':
                  M_PUSH('"');
                  break;
                default:
                  PRV_ERR_MACRO();
              }
            }
            break;
    //      case '\t':
    //      case '\n':
    //        PRV_ERR_MACRO();
    //        break;
          case '"':
            goto end;
          default:
            M_PUSH(c);
        }
      }
    
    end:
      ;
      blob *tmp = blob_init(st_len, st);
      PRV_FREE(st);
      return tmp;
    }

    Эта вот хрень вычитывает из "FILE *" одно "слово".

    j123123, 09 Ноября 2021

    Комментарии (97)
  10. Python / Говнокод #27244

    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
    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
    import datetime, random, time, os, vk_api
    import sqlite3 as sl
    from vk_api.exceptions import Captcha
    from vk_api.longpoll import VkEventType, VkLongPoll
    from functions import *
    from settings import *
    vk_session = vk_api.VkApi(token=token, api_version=5.126)
    longpoll = VkLongPoll(vk_session)
    vk = vk_session.get_api()
    now = datetime.datetime.now()
    
    for event in longpoll.listen():
        try:
            def send_msg(msg='', chat=False, prefix=True, attach=''):
                if chat:
                    vk.messages.send(chat_id=event.chat_id,message=msg,attachment=attach)
                else:
                    vk.messages.send(user_id=event.user_id,message=msg,attachment=attach)
        except Captcha:
            time.sleep(1)
            send_msg('Ошибка. Слишком частые запросы.')
        except Exception as e:
            time.sleep(1)
            send_msg(f'Неизвестная ошибка при отправке сообщения.\n{e}')
        try:
            if event.type == VkEventType.MESSAGE_NEW and event.to_me:
                user_get = vk.users.get(user_ids=event.user_id)
                first_name = user_get[0]['first_name']
                last_name = user_get[0]['last_name']
                if event.from_chat and event.chat_id and (event.message == '!meme' or event.message == '!мем'):
                    meme_create()
                    upload = vk_api.VkUpload(vk_session)
                    try:
                        a = upload.photo_messages(photos=os.path.dirname(__file__) + '/random_meme.jpg', peer_id=event.user_id)
                        send_msg(attach=f'photo{a[0]["owner_id"]}_{a[0]["id"]}',chat=True, prefix=False)
                    except:
                        send_msg("Ошибка. Попробуйте снова.")
                elif event.from_chat and event.chat_id and (event.message == '!info' or event.message == '!инфо'):
                    response = requests.get(f'https://vk.com/foaf.php?id={event.user_id}')
                    soup = BeautifulSoup(response.text, 'lxml')
                    created = soup.find('ya:created').get('dc:date')
                    created1 = datetime.datetime.strptime(created, '%Y-%m-%dT%H:%M:%S%z').replace(tzinfo=None)
                    diff = datetime.datetime.now()-created1
                    modified = soup.find('ya:modified').get('dc:date')
                    modified1 = datetime.datetime.strptime(modified, '%Y-%m-%dT%H:%M:%S%z').replace(tzinfo=None)
                    send_msg(f'''https://vk.com/id{event.user_id}\nИмя пользователя: {first_name} {last_name}\nАккаунт существует {diff.days} дней.\nДата регистрации: {created1.month} {months[created1.month-1]} {created1.year} в {created1.time()}\nПоследнее обновление информации: {modified1.month} {months[modified1.month-1]} {modified1.year} в {modified1.time()}''', chat=True)
                elif event.from_user and event.user_id and (event.message == '!info' or event.message == '!инфо'):
                    response = requests.get(f'https://vk.com/foaf.php?id={event.user_id}')
                    soup = BeautifulSoup(response.text, 'lxml')
                    created = soup.find('ya:created').get('dc:date')
                    created1 = datetime.datetime.strptime(created, '%Y-%m-%dT%H:%M:%S%z').replace(tzinfo=None)
                    diff = datetime.datetime.now()-created1
                    modified = soup.find('ya:modified').get('dc:date')
                    modified1 = datetime.datetime.strptime(modified, '%Y-%m-%dT%H:%M:%S%z').replace(tzinfo=None)
                    send_msg(f'''https://vk.com/id{event.user_id}\nИмя пользователя: {first_name} {last_name}\nАккаунт существует {diff.days} дней.\nДата регистрации: {created1.month} {months[created1.month-1]} {created1.year} в {created1.time()}\nПоследнее обновление информации: {modified1.month} {months[modified1.month-1]} {modified1.year} в {modified1.time()}''')
                elif event.from_user and event.user_id and event.message == '!coin':
                    coin = 'Орёл' if random.randint(0, 1) == 1 else 'Решка'
                    send_msg(f'{coin}')
                elif event.from_user and event.user_id and (event.message == '!anek' or event.message == '!анек'):
                    send_msg(f'{get_anek()}', prefix=False)
                elif event.from_user and event.user_id:
                    con = sl.connect(os.path.dirname(__file__) + '/users.db')
                    count = 0
                    with con:
                                con.execute("""
                                    CREATE TABLE IF NOT EXISTS USER (
                                        user_id INTEGER NOT NULL PRIMARY KEY,
                                        name TEXT,
                                        permission_lvl INTEGER
                                    );
                                """)
                    with con:
                        data = con.execute("SELECT * FROM USER")
                        for row in data:
                            if event.user_id in row:
                                count += 1
                        if count == 0:
                            send_msg(f'''Привет, это сообщение отправлено автоматически.\nПока я добавляю информацию о тебе в базу данных, ты можешь ознакомиться с командами написав !help\nКоманд не так много, но в будущем их станет больше ;)''')
                            sql = 'INSERT INTO USER (user_id, name, permission_lvl) values(?, ?, ?)'
                            data = [(event.user_id, f'{first_name} {last_name}', 1)]
                            with con:
                                con.executemany(sql, data)
                if event.attachments:
                    print(
                        f"{now}\nuser_id: {event.user_id} | {first_name} {last_name}\nmessage: {event.message}\nattach: {event.attachments}\n")
                else:
                    print(
                        f"{now}\nuser_id: {event.user_id} | {first_name} {last_name}\nmessage: {event.text}\n")
        except Captcha:
            time.sleep(1)
            send_msg('Ошибка. Слишком частые запросы.')
        except Exception as e:
            time.sleep(1)
            send_msg(f'Упс. Произошла неизвестная ошибка.\n{e}')

    Каким образом можно улучшить этот ссаный говнокод?

    TupoyChel, 09 Февраля 2021

    Комментарии (97)
  11. C++ / Говнокод #25991

    0

    1. 1
    2. 2
    3. 3
    4. 4
    char (&getArray())[11] {
      static char arr[] = "1234567890";
      return arr;
    }

    Как вернуть массив из функции в C/C++

    На самом деле нет: возвращается ссылка

    Elvenfighter, 24 Октября 2019

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