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

    В номинации:
    За время:
  2. Куча / Говнокод #27746

    0

    1. 1
    Время вечерней молитвы.

    Примите положение А1. Постарайтесь сосредоточиться, соберитесь с мыслями. Прочтите молитву.
    Инициализируйте процедуру-коллбек.

    nPOnOBeDHuK, 15 Октября 2021

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

    0

    1. 1
    Application was halted by an exception.

    Error 520
    Ray ID: 69e3d61cfd95169b •
    2021-10-14 21:18:17 UTC
    Web server is returning an unknown error
    You
    Browser Working
    Moscow
    Cloudflare Working
    govnokod.ru
    Host Error
    What happened?

    There is an unknown connection issue between Cloudflare and the origin web server. As a result, the web page can not be displayed.
    What can I do?

    If you are a visitor of this website:

    Please try again in a few minutes.

    If you are the owner of this website:

    There is an issue between Cloudflare's cache and your origin web server. Cloudflare monitors for these errors and automatically investigates the cause. To help support the investigation, you can pull the corresponding error log from your web server and submit it our support team. Please include the Ray ID (which is at the bottom of this error page). Additional troubleshooting resources.
    Cloudflare Ray ID: 69e3d61cfd95169b
    Your IP: 91.197.11.236
    Performance & security by Cloudflare

    OCETuHCKuu_nemyx, 15 Октября 2021

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

    +2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    if($response == null){
        echo "<pre>";
        var_dump($response);
        echo "</pre>";
        die();
    }

    Таким способом выводится на экран надпись NULL

    govnokoder2, 17 Сентября 2021

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

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    #define MAKE(a1, a2, m1, m2) if(arg1s == a1 && arg2s == a2)\
    	sprintf_s(opcode_buffer, format.c_str(), opcodeToString((Opcode)opcode.opcode).c_str(), m1, m2)
    
    	MAKE(I, I, iarg1       ,  iarg2       );
    	MAKE(S, I, arg1.c_str(),  iarg2       );
    	MAKE(I, S, iarg1       ,  arg2.c_str());
    	MAKE(S, S, arg1.c_str(),  arg2.c_str());
    #undef MAKE

    да что вы знаете о форматировании.

    digitalEugene, 09 Мая 2021

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

    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
    // Define the man site module
    define(function(require) {
        // Require function that runs when button is clicked
        var run = require('./run').run;
    
        // Where the application starts its work
        var genTextButton = document.getElementById("button-gen-text");
        genTextButton.onclick = run;
    });
    
    define(function(require) {
      // Require value error
      var ValueError = require('./errors/value_errors').ValueError;
    
      // Require EmptyListError
      var EmptyListError = require('./errors/property_errors').EmptyListError;
    
      // Require functions that returns data for text generation
      var getData = require('./utils/get_data');
      var getTextLength = getData.getTextLength;
      var getTemplateList = getData.getTemplateList;
      var getWordList = getData.getWordList;
      var getStyleOption = getData.getStyleOption;
    
      // Require function for setting output text
      var makeText = require('./utils/set_text');
    
      // Require function for validating form and validate form
      var validateForm = require('./utils/validateForm');
      validateForm({
        formId : 'form-text-gen',
        inputErrorClass : 'input-error',
        formInvalidClass : 'form-invalid'
      });
    
      // Runs tasks for text generation
      var run = function() {
        try {
          var textLength = getTextLength();
          var templateList = getTemplateList();
          var wordList = getWordList();
          var styleOption = getStyleOption();
    
          makeText({
            styleOption : styleOption,
            textLength : textLength,
            templateList : templateList,
            wordList : wordList
          });
        } catch (error) {
           if (error instanceof ValueError) {
             console.log(error.stack);
           } else if (error instanceof EmptyListError)  {
              console.log(error.stack);
           } else {
             throw error;
           }
        }
      }
    
      return {
        run : run
      }
    });

    Божественная кнопка

    JaneBurt, 08 Мая 2021

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

    +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
    private List<CellControl[]> ComposeLines(List<CellControl[]> vertical, List<CellControl[]> horizontal)
            {
                List<CellControl[]> result = new List<CellControl[]>();
    
                foreach (var vLine in vertical)
                {
                    var cellsCount = vLine.Length;
                    List<CellControl[]> linesToCompose = new List<CellControl[]>();
                    foreach (var vCell in vLine)
                    {
                        foreach (var hLine in horizontal)
                        {
                            foreach (var hCell in hLine)
                            {
                                if (hCell.X == vCell.X && hCell.Y == vCell.Y)
                                {
                                    linesToCompose.Add(hLine);
                                    cellsCount += hLine.Length;
                                    break;
                                }
                            }
    
                            if (linesToCompose.Count == 0)
                            {
                                result.Add(hLine);
                            }
                        }
                    }
    
                    if (linesToCompose.Count == 0)
                    {
                        result.Add(vLine);
                    }
                    else
                    {
                        linesToCompose.Add(vLine);
                        var newLine = new CellControl[cellsCount];
                        var i = 0;
                        foreach (var line in linesToCompose)
                        {
                            foreach (var cellControl in line)
                            {
                                newLine[i] = cellControl;
    
                                cellControl.Selected = true;
                                i++;
                            }
                        }
                        
                        result.Add(newLine);
                    }
                }
                
                return result;
            }

    mdd-inbox, 20 Апреля 2021

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

    +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
    using System;
    
    namespace MainNamespace
    {
        class MainClass
        {
            static string str, sep;
            static void Sep()
            {
                int k = 0;
                while (k < str.Length * 2 - 5)
                {
                    if (sep.Length * (k + 1) > str.Length * 2 - 5)
                        break;
                    Console.Write(sep);
                    k++;
                }
                for (int l = 0; l < ((str.Length * 2 - 5) - (k * sep.Length)) ; l++)
                    Console.Write(sep[l]);
            }
            static void Main(string[] args)
            {
                Console.Write("str: ");
                str = Console.ReadLine();
                Console.Write("sep: ");
                sep = Console.ReadLine();
                for (int i = 0; i < str.Length-1; i++)
                    Console.Write(str[i] + " ");
                Console.Write(str[str.Length-1] + "\n\n");
                for (int j = 0; j < str.Length - 2; j++)
                {
                    Console.Write(str[j + 1] + " ");
                    Sep();
                    Console.WriteLine(" " + str[str.Length - j - 2]);
                    Console.Write("  ");
                    if(j < str.Length - 3)
                    {
                        Sep();
                        Console.WriteLine("  ");
                        continue;
                    }
                    Console.WriteLine();
                }
                for (int m = str.Length-1; m >= 1; m--)
                    Console.Write(str[m] + " ");
                Console.WriteLine(str[0]);
                Console.ReadKey();
            }
        }
    }

    Переписал код http://govnokod.ru/27324 на Шарп с небольшими улучшениями.

    BelCodeMonkey, 10 Апреля 2021

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

    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
    -define(snk_int_match_arg(ARG),
            fun(__SnkArg) ->
                case __SnkArg of
                  ARG -> true;
                  _   -> false
                end
            end).
    
    -define(snk_int_match_arg2(M1, M2, GUARD),
            fun(__SnkArg1, __SnkArg2) ->
                case __SnkArg1 of
                  M1 ->
                    case __SnkArg2 of
                      M2 -> (GUARD);
                      _  -> false
                    end;
                  _ -> false
                end
            end).
    
    
    ....
    
    -spec maybe_delay(map()) -> ok.
    maybe_delay(Event) ->
      [{_, Delays}] = ets:lookup(?DELAY_TAB, ?SINGLETON_KEY),
      [snabbkaffe_collector:block_until( fun(WU) -> ContP(Event, WU) end
                                       , infinity
                                       , infinity
                                       )
       || #delay{ continue_predicate = ContP
                , delay_predicate    = DelayP
                } <- Delays, DelayP(Event)],
      ok.

    Наметушил.

    CHayT, 02 Марта 2021

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

    0

    1. 1
    2. 2
    3. 3
    if @OWNER_PHONE <> @OLD_PHONE set @PHONE = @OWNER_PHONE
          if @PHONE <> @OLD_PHONE set @OWNER_PHONE = @PHONE
          set @PHONE = @OWNER_PHONE

    tucvbif, 05 Февраля 2021

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

    −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
    <?php
    header ('Access-Control-Allow-Origin: *');//Разрешили кроссдоменные запросы
     
    $mysql_host = "хост";
    $mysql_database = "Бд";
    $mysql_user = "Юзернейм";
    $mysql_password = "пОроль";
     
    $link = mysql_connect($mysql_host, $mysql_user, $mysql_password) or die("Ошибка при подключении MySQL" );
    mysql_select_db($mysql_database, $link) or die ('Ошибка при подключении к БД');
     
        if (isset($_POST['login'])) { $login = $_POST['login']; if ($login == '') { unset($login);} }
        if (isset($_POST['password'])) { $password=$_POST['password']; if ($password =='') { unset($password);} }
        if (isset($_POST['email'])) { $email=$_POST['email']; if ($email =='') { unset($email);} }
        if (isset($_POST['silvercoin'])) { $silvercoin=$_POST['silvercoin']; if ($silvercoin =='') { unset($silvercoin);} }
        if (isset($_POST['goldcoin'])) { $goldcoin=$_POST['goldcoin']; if ($goldcoin =='') { unset($goldcoin);} }
    if (empty($login) or empty($password) or empty($email))
        {
        echo ("Вы ввели не всю информацию, заполните все поля!");
        exit();
        }
        $login = stripslashes($login);
        $login = htmlspecialchars($login);
        $password = stripslashes($password);
        $password = htmlspecialchars($password);
        $email = stripslashes($email);
        $email = htmlspecialchars($email);
        $silvercoin = stripslashes($silvercoin);
        $silvercoin = htmlspecialchars($silvercoin);
        $goldcoin = stripslashes($goldcoin);
        $goldcoin = htmlspecialchars($goldcoin);
        $login = trim($login);
        $password = trim($password);
        $email = trim($email);
        $silvercoin = trim($silvercoin);
        $goldcoin = trim($goldcoin);
        $q1 = mysql_query("SELECT login FROM `accounts` WHERE `login`='".$login."'");
        $loginb = mysql_fetch_array($q1);
        $loginbd=$loginb['login'];
        if($loginbd == $login){
        echo("Извините, введённый вами логин уже зарегистрирован.");
        exit();
        }
         else
        $result2 = mysql_query ("INSERT INTO accounts (login,password,email) VALUES('$login','$password','$email')");
        if ($result2=='TRUE')
        {
        echo "Вы успешно зарегистрированы!";
        }
    else {
        echo "Ошибка! Вы не зарегистрированы.";
        }
    ?>

    Использование бредо-заголовок в 2 строке
    Использование Инструмента в 2к21, который в PHP5.5.0 20 июня 2013 Объявлен как устаревший, а в PHP 7.0.0 удален
    Нет задающей кодировки подключения к БД
    Глупая, дешевая валидация данных начиная с 12 и заканчивая 46 строкой
    SQL-injection привет!
    46 строка - невероятно проверять boolean тип
    37 - 39 строка - юзер не найден - лови ошибку!

    Чуть не забыл... скрипт не в кодировке UTF-8 no BOM

    https://php.ru/forum/threads/pomogite-ispravit-oshibku-cannot-modify-header-information-headers-already-sent-by.90359/

    Привет 2010 году !

    MouseZver, 25 Января 2021

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