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

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

    −11.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
    void safecpy(char *str1, char *str2)
    {
    	strncpy(str1, str2, strlen(str1));
    	str1[strlen[str1]] = 0;
    }
    
    ...
    
    void safecpy(char *str1, char *str2)
    {
    	strncpy(str1, str2, sizeof(str1));
    	str1[sizeof(str1)] = 0;
    }

    Две примера функций \"безопасного\" копирования строк :-)

    guest, 12 Декабря 2008

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

    −58.5

    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
    //Вознашу хвалу тебе, о великий индуский бог программинга! Как ни странно, работает, но надо переписать на досуге.
    	       
    $city_xml = $CityArray->GetXml("CityList");
    	foreach($city_xml as $tmp_array){
    		if(!is_string($tmp_array) && $tmp_array[0] != "" && $tmp_array[0] != "Success" ){
    			foreach($tmp_array as $second_array){
    				$ixml = new xml();
    			    	$ixml->Insert($second_array);
    			    	foreach($ixml as $country_array){
    			    		if(!is_string($country_array) && $country_array[0] != "" && $country_array[0] != "Success" ){
    						foreach($country_array as $rxml){
    							if(!is_string($rxml)){
    								foreach($rxml as $axml){
    									if(!is_string($axml) && $axml[0] && $axml[0] != "Position"){
    										foreach($axml as $bxml){
    											foreach($bxml as $cxml){
    												if(!is_string($cxml) && is_array($cxml) && $cxml["Name"]){
    													$cities[] = $cxml;
    												}
    											}
    										}	
    									}
    								}
    							}
    						}
    				    	}
    				    }
    				}
    			}
    		}
    return $cities;

    Парсинг xml

    guest, 11 Декабря 2008

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

    −62.7

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    if ( strchr ( $_POST["ship$i"], "+") || strchr($_POST["ship$i"], " ") || strchr($_POST["ship$i"], ",") || strchr($_POST["ship$i"], ".") || strchr($_POST["ship$i"], "-") || strchr($_POST["ship$i"], "_") || strchr($_POST["ship$i"], ";") || strchr($_POST["ship$i"], ":") ) { 
    message("You got owned by >>The_Revenge Anticheat Systems<<", "Anticheat");
    }
    if ( !strchr ( $_POST["ship$i"], "+") && !strchr($_POST["ship$i"], " ") && !strchr($_POST["ship$i"], ",") && !strchr($_POST["ship$i"], ".") && !strchr($_POST["ship$i"], "-") && !strchr($_POST["ship$i"], "_") && !strchr($_POST["ship$i"], ";") && !strchr($_POST["ship$i"], ":")) {
    // код
    }

    Немец предложил такое решение для проверки, что в строке ship$i именно положительное целое число и ни что иное.
    В другом месте попадается аналогичный момент, только там после каждого strchr для каждого спецсимвола идет 10 строк одного и того же кода с двумя запросами к БД и выдачей бана юзеру...
    Проект XNova (ogame-like)

    guest, 11 Декабря 2008

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

    −32.7

    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
    public void updateAmountValues(List<TransactionResultItem> transactionResultItems) {
            for (TransactionResultItem transaction : transactionResultItems) {
                Account account = getAccountById(transaction.getAccountId());
                if ((transaction.getMainTransaction()
                        && ! transaction.getTransactionTypeId().equals(4)
                        && ! transaction.getTransactionTypeId().equals(5)
                        && ! transaction.getTransactionTypeId().equals(6))
                        ||
                        (! transaction.getMainTransaction() &&
                                (transaction.getTransactionTypeId().equals(5) &&
                                        ((account.getAccountTypeId().equals(AccountType.INCOME_TYPE_ID) ||
                                                account.getAccountTypeId().equals(AccountType.OTHER_INCOME_TYPE_ID)) &&
                                                transaction.getAmount() > 0)
                                        || (transaction.getAccountId().equals(getSalesTaxPayableAccountId()) && transaction.getAmount() > 0)
                                        || ((account.getAccountTypeId().equals(AccountType.EXPENSE_TYPE_ID) ||
                                        account.getAccountTypeId().equals(AccountType.OTHER_EXPENSE_TYPE_ID)) && transaction.getAmount() < 0))
                                || (transaction.getTransactionTypeId().equals(1) &&
                                (account.getAccountTypeId().equals(AccountType.INCOME_TYPE_ID) ||
                                        account.getAccountTypeId().equals(AccountType.OTHER_INCOME_TYPE_ID)) &&
                                transaction.getAmount() < 0)
                                || (transaction.getTransactionTypeId().equals(2) &&
                                (account.getAccountTypeId().equals(AccountType.INCOME_TYPE_ID) ||
                                        account.getAccountTypeId().equals(AccountType.OTHER_INCOME_TYPE_ID)) &&
                                transaction.getAmount() > 0)
                        )) {
                    Double amount = transaction.getAmount();
                    transaction.setAmount(-amount);
                }
            }
        }

    Потрясающий по понятности код. Вызывался несколько раз в одном и том же методе.

    guest, 08 Декабря 2008

    Комментарии (3)
  6. Haskell / Говнокод #29250

    +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
    {-# LANGUAGE OverloadedStrings #-}
    import qualified Data.Text.Lazy.IO as LIO
    import GHC.IO.StdHandles
    import Text.Regex.TDFA
    import qualified Text.Regex.TDFA.Text.Lazy as RL
    import Data.Array
    import qualified Data.Text.Lazy as TL
    import System.Environment
    import System.Exit
    import System.IO
    import qualified Language.C.Syntax.Constants as CC
    import Data.Char
    
    printMatch t matches i =
        let (offset, len) = matches ! i in
        let offset' = fromIntegral offset in
        let len' = fromIntegral len in
        LIO.putStr $ TL.take len' $ TL.drop offset' t
    
    printHead t matches =
        let (offset, len) = matches ! 0 in
        let offset' = fromIntegral offset in
        let len' = fromIntegral len in
        LIO.putStr $ TL.take offset' t
    
    printTrail t matches =
        let (offset, len) = matches ! 0 in
        let offset' = fromIntegral offset in
        let len' = fromIntegral len in
        LIO.putStr $ TL.drop (offset' + len') t
    
    need_capture_trail acc ".*" = (False, reverse acc)
    need_capture_trail acc [] = (True, reverse acc)
    need_capture_trail acc (c : rest) = need_capture_trail (c : acc) rest
    
    getRE :: [String] -> Either String (RL.Regex, Bool, String)
    getRE args =
        case args of
          (re_str : repl_str : _) ->
              let (trail_needed, re_str') = need_capture_trail [] re_str in
              let re_text = TL.pack $ CC.unescapeString re_str' in
              case RL.compile defaultCompOpt defaultExecOpt re_text of
                Right re ->
                    Right (re, trail_needed, CC.unescapeString repl_str)
                Left err ->
                    Left err
          _ ->
              Left "Regexp expected"
    
    -- replacement :: TL.Text -> Int -> _ -> String -> IO ()
    replacement _ _ _ [] = return ()
    replacement t n_matches matches (c : rest)
        | ord c <= n_matches = do
               printMatch t matches (ord c)
               replacement t n_matches matches rest
        | True = do
            putChar c
            replacement t n_matches matches rest
    
    exitError :: String -> IO ()
    exitError msg = do
      hPutStrLn stderr msg
      exitWith (ExitFailure 1)
    
    main :: IO ()
    main = do
        args <- getArgs
        case getRE args of
          Right (re, trail_needed, repl) -> do
              t <- LIO.hGetContents stdin
              case RL.execute re t of
                Right (Just matches) ->
                    do
                      let n_matches = snd $ bounds matches
                      -- print matches
                      printHead t matches
                      replacement t n_matches matches repl
                      if trail_needed then
                          printTrail t matches
                      else
                          return ()
                Right Nothing -> do
                    exitError "Pattern not found"
                Left err -> do
                    exitError err
          Left err -> do
             exitError err

    Текст UNIX-way утилиты fed
    Капча: p2ux

    CHayT, 25 Апреля 2026

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

    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
    namespace arangodb {
    class DatabaseFeature;
    
    struct IDatabaseGuard {
      virtual ~IDatabaseGuard() = default;
      [[nodiscard]] virtual TRI_vocbase_t& database() const noexcept = 0;
    };
    
    struct VocbaseReleaser {
      void operator()(TRI_vocbase_t* vocbase) const noexcept;
    };
    
    using VocbasePtr = std::unique_ptr<TRI_vocbase_t, VocbaseReleaser>;
    
    /// @brief Scope guard for a database, ensures that it is not
    ///        dropped while still using it.
    class DatabaseGuard final : public IDatabaseGuard {
     public:
      /// @brief create guard on existing db
      explicit DatabaseGuard(TRI_vocbase_t& vocbase);
    
      /// @brief create guard from existing VocbasePtr
      explicit DatabaseGuard(VocbasePtr vocbase);
    
      /// @brief create the guard, using a database id
      DatabaseGuard(DatabaseFeature& feature, TRI_voc_tick_t id);
    
      /// @brief create the guard, using a database name
      DatabaseGuard(DatabaseFeature& feature, std::string_view name);
    
      /// @brief return the database pointer
      TRI_vocbase_t& database() const noexcept final { return *_vocbase; }
      TRI_vocbase_t const* operator->() const noexcept { return _vocbase.get(); }
      TRI_vocbase_t* operator->() noexcept { return _vocbase.get(); }
    
     private:
      VocbasePtr _vocbase;
    };
    
    }  // namespace arangodb

    Виртуальное гавно!

    gnusmas, 19 Марта 2026

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

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    <? // get current season for header styling
    		$current_month = date("m");
    		if($current_month >= "03" && $current_month <= "05") $season = "spring";
    		elseif($current_month >= "06" && $current_month <= "08") $season = "spring";
    		elseif($current_month >= "09" && $current_month <= "11") $season = "autumn";
    		else $season = "winter";
      ?>

    И про теги в стиле говноБитрикса не забыли

    Lexchz2, 25 Февраля 2026

    Комментарии (2)
  9. C++ / Говнокод #29234

    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
    #pragma GCC optimize("03")
    #include <bits/stdc++.h>
    #pragma GCC target("avx2,tune=native")
    using namespace std;
    int binxor(int a, int b) {
        if (b == 0) {
            return 0;
        }
        int t = binxor(a, b / 2);
        if (b % 2 == 0) {
            return t ^ t;
        } else {
            return t ^ t ^ a;
        }
    }
    vector<int> per(20);
    vector<int> res(binxor(1 << 20, numeric_limits<int>::max() + 2), -1);
    vector<int> need(binxor(1 << 20, numeric_limits<int>::max() + 2), 0);
    vector<int> gp(binxor(1 << 20, numeric_limits<int>::max() + 2), 1 << 30);
    int c = 0;
    int Trump = 0;
    inline void f(int i, int n, int w) {
        if (i == w) {
            for (int j = 0; j < w; j++) {
                if ((Trump >> (w - 1 - j)) & 1) {
                    gp[Trump] = min(gp[Trump], gp[Trump ^ (1 << (w - 1 - j))]);
                }
            }
            return;
        }
        f(i + 1, n, w);
        Trump ^= 1 << (w - 1 - i);
        f(i + 1, n, w);
        Trump ^= 1 << (w - 1 - i);
    }
    signed main() {
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        int n, q, w;
        cin >> n >> q >> w;
        vector<string> s(n);
        for (auto &x : s) {
            cin >> x;
        }
        vector<int> ord(n);
        iota(ord.begin(), ord.end(), 0);
        sort(ord.begin(), ord.end(), [&](int x, int y) {
            return s[x] < s[y];
        });
        for (int i = 0; i < n; i++) {
            int Trump = 0;
            for (auto ch : s[ord[i]]) {
                Trump |= 1 << (ch - 'a');
            }
            gp[Trump] = min(gp[Trump], i);
        }
        f(0, n, w);
        for (int i = 0; i < q; ++i) {
            string t;
            cin >> t;
            int Harris = 0;
            for (auto ch : t) {
                Harris |= 1 << (ch - 'a');
            }
            int val = gp[((1 << w) - 1) ^ Harris];
            cout << (val >= n ? -1 : 1 + ord[val]) << "\n";
        }
        return 0;
    }

    Без комментариев

    letipetukh1, 13 Февраля 2026

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

    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
    const std::string programPath =
        "/root/CLionProjects/PetukhPlusPlus/program.petukh";
    
    const std::string lexerOutPath =
        "/root/CLionProjects/PetukhPlusPlus/res_lexer.txt";
    
    const std::string syntaxOutPath =
        "/root/CLionProjects/PetukhPlusPlus/res_syntax.txt";
    
    const std::string semanticOutPath =
        "/root/CLionProjects/PetukhPlusPlus/res_semantic.txt";
    
    const std::string polizOutPath =
        "/root/CLionProjects/PetukhPlusPlus/res_poliz.txt";

    Классика говнокода

    letipetukh1, 12 Февраля 2026

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

    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
    <?php 
    /********************** 
    						R.I.P PHP 6.6.6
    						Dedicaded to Victoria Null& from Vladivostok vodka drinkers
    ***********************/
    _: 004 | 001 & !!!define("_", [null, !32768, (float)'\x1551', (bool)'\x9', 2, 3, 4, 5, 6, 10, 15, 16, 24, 31, 
                            42, 47, -1024, 56, 58, 60, 61, 62, PHP_INT_MIN, 63, 64, 65, (null), 72, 73, 75, 77, 
                            80, 81, 87, 88, 92, 0b10000000000, 100, 101, 111, 127, 128, 129, PHP_INT_MIN - 1, 131, 
                            2048, PHP_INT_MAX - 1, 2049, 1023, 1024, 4095, 4096, 8191, 8192, 9009, 8193, 
                            PHP_INT_MAX, 0b1100, 10001,]) & null | 007 | 006; goto ___;
    __: goto _;
    ___ :
    $_ = count(_,);
    while (000000000000001 >> 1 ^ $_ ^ 00000000000001 << 0 >> 1) 
    {
    	if (!
    		!!
    		!!!
    		!!!! 
    		!!!!! (_[--$_] & (_[$_ & ~0] - 00000000000000000000000000000000000001)))
    		~ ~~ ~~~ ~~~~ ~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~ ~~~~~~~~~~~~~~ ~~~~~~ ~~~~~ ~~~ ~~ ~
    		print __NAMESPACE__ . __FUNCTION__ . __METHOD__ . \_[$_ | 000] . null . PHP_EOL;
    		~ ~~ ~~~ ~~~~ ~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~ ~~~~~~~~~~~~~~ ~~~~~~ ~~~~~ ~~~ ~~ 0;
    }
    ###### Since [full of ol' su*kers] board decided to fire my possibly edgy person off the team now you're looking at this brainf**kin shit. 
    ###### Better go invest into D-- or B++ you stupid monks ######
    
    ###### /* C/T/F m/a/r/k/e/r: the snippet above works only on 7.3.0+ 
    ###### Allowed to change ONLY 1 character to make it compiles on lower versions.
    ###### Anwser format: #.#.# (Min. version number which has no compile time errors) 
    ###### Happy hooking, fuzzing ladies! */
    echo (null[die]) ?>

    когда казалось, что хоть пыху немного понимать начал..
    Как это распарсить, деды?

    Raspi_s_Dona, 29 Ноября 2025

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