1. PHP / Говнокод #20300

    +2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    $do_while = DateTime::createFromFormat('d.m.Y H:i:s', $rowRequest['start_date'].":00");
    $do_while = $do_while->format('U');
    $do_while +=0;
    list($hour , $minute ) = explode(":", "24:00");$hour +=0;$minute +=0;
    $do_while +=($hour*3600 + $minute*60);
    $time = date('d.m.Y H:i',$do_while);

    Lesha, 30 Июня 2016

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

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    $string_of_query = "select * from gisgmp.f_gisgmp_bills" . $tableName . "8mod(null, 1, UnknownValidUntil);
    if ($ValidUntil == null)
        $string_of_query = str_replace("UnknownValidUntil", "null", $string_of_query);
    else
        $string_of_query = str_replace("UnknownValidUntil", "'$ValidUntil'", $string_of_query);

    Lesha, 30 Июня 2016

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

    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
    ...
    scr[6][0] = '\\'; scr[6][1] = '\\';//прорисовка корабля
        scr[7][0] = '3'; scr[7][1] = '='; scr[7][2] = '=';
        scr[8][0] = '/'; scr[8][1] = '/';
    ...
    if (_kbhit())//если клавиша была нажата
            {
                control = _getch();//переменная примет ее значение
                if (control == 224)
                    control = _getch();
            }
            if (control == 72)//при движении корабля вверх
                if (scr[2][0] == '\\' || scr[3][0] == '\\' && scr[2][0] == '¤' || scr[3][1] == '\\' && scr[2][1] == '¤')//если корабль врезался в верхнее поле - игра окончена
                    if (lifes > 1)
                    {
                        cout << '\a';
                        lifes--;
                        weaponPos = 7;
                        GameStart(scr, lifes, &timer);
                        Sleep(1000);
                    }
                    else
                        GameOver(odometer);
                else
                {
                    for (int i = 2; i < 13; i++)//корабль смещается на элемент выше
                        for (int j = 0; j < 49; j++)
                            if (scr[i][j] == '3' || scr[i][j] == '\\' || scr[i][j] == '=' || scr[i][j] == '/')
                            {
                                scr[i - 1][j] = scr[i][j];
                                scr[i][j] = ' ';
                            }
                    weaponPos--;
                }
            if (control == 80)//при движении корабля вниз
                if (scr[12][0] == '/' || scr[11][0] == '/' && scr[12][0] == '¤' || scr[11][1] == '/' && scr[12][1] == '¤')//если корабль врезался в нижнее поле - игра окончена
                    if (lifes > 1)
                    {
                        cout << '\a';
                        lifes--;
                        weaponPos = 7;
                        GameStart(scr, lifes, &timer);
                        Sleep(1000);
                    }
                    else
                        GameOver(odometer);
                else
                {
                    for (int i = 12; i >= 2; i--)//корабль смещается на элемент вниз
                        for (int j = 0; j < 49; j++)
                            if (scr[i][j] == '3' || scr[i][j] == '\\' || scr[i][j] == '=' || scr[i][j] == '/')
                            {
                                scr[i + 1][j] = scr[i][j];
                                scr[i][j] = ' ';
                            }
                    weaponPos++;
                }
    ...

    И многое другое на https://habrahabr.ru/post/304448/

    habrophag, 30 Июня 2016

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

    +2

    1. 1
    $this->a[$this->c[$this->m]] = my_substr($this->t, $prev[2], ($v[0] - $prev[2]));

    Кусочек кустарного говношаблонизатора.
    Без комментариев. В обоих смыслах.

    daniser, 30 Июня 2016

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

    +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
    std::deque<std::pair<int, int>> Pathing::findPath(int sx, int sy, int fx, int fy) const
    {
        std::list<Node> openNodes;
        std::list<Node> closeNodes;
    
        const Node startNode{nullptr, sx, sy, 0, 0, 0};
        openNodes.push_back(startNode);
    
        auto cells = gameMap->getCells();
    
        auto findNode = [](auto&& list, int x, int y)
        {
            return std::find_if(std::begin(std::forward<decltype(list)>(list)),
                                std::end(std::forward<decltype(list)>(list)),
                    [x, y](auto n) {return n.x == x && n.y == y;});
        };
    
        auto isNodeInList = [findNode](auto&& list, int x, int y)
        {
            return findNode(std::forward<decltype(list)>(list), x, y) != list.cend();
        };
    
        auto processNode = [&](auto iterCurrentNode, int x, int y)
        {
            const auto nx = iterCurrentNode->x + x;
            const auto ny = iterCurrentNode->y + y;
    
            if (cells[nx][ny].passable && !isNodeInList(closeNodes, nx, ny))
            {
                const auto G = iterCurrentNode->G + (x && y ? 14 : 10);
                const auto H = (std::abs(fx - nx) + std::abs(fy - ny)) * 10;
                const auto F = G + H;
    
                auto node = findNode(openNodes, nx, ny);
    
                if (node == openNodes.cend())
                {
                    openNodes.push_back({&(*iterCurrentNode), nx, ny, G, H, F});
    
                    if (nx == fx && ny == fy)
                        return true;
                }
                else
                {
                    if (G < node->G)
                    {
                        node->parent = &(*iterCurrentNode);
                        node->G = G;
                        node->H = H;
                        node->F = F;
                    }
                }
            }
    
            return false;
        };
    
        while (!openNodes.empty())
        {
            auto iterMinF = std::min_element(openNodes.cbegin(), openNodes.cend(),
                    [](auto n1, auto n2) {return n1.F < n2.F;});
    
            closeNodes.push_back(*iterMinF);
            auto iter = closeNodes.insert(closeNodes.cend(), *iterMinF);
    
            openNodes.erase(iterMinF);
    
            if (processNode(iter,  1,  0) ||
                processNode(iter,  1,  1) ||
                processNode(iter,  0,  1) ||
                processNode(iter, -1,  1) ||
                processNode(iter, -1,  0) ||
                processNode(iter, -1, -1) ||
                processNode(iter,  0, -1) ||
                processNode(iter,  1, -1))
                break;
        }
    
        auto finalNode = findNode(openNodes, fx, fy);
        if (finalNode == openNodes.cend())
            return {};
    
        std::deque<std::pair<int, int>> route{{finalNode->x, finalNode->y}};
        const Node* temp = finalNode->parent;
    
        while (temp)
        {
            route.push_front({temp->x, temp->y});
            temp = temp->parent;
        }
    
        return route;
    }

    jangolare, 30 Июня 2016

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

    +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
    32. 32
    33. 33
    34. 34
    using static System.Console;
    
    namespace OptimizationDetector
    {
        public static class OptimizationDetector
        {
            private static class pls
            {
                public static bool wtf = true;
            }
    
            private static int rly = detect();
    
            private static int detect()
            {
                pls.wtf = false;
                return 0;
            }
    
            public static bool IsOptimizationEnabled
            {
                get { return pls.wtf; }
            }
        }
    
        class Program
        {
            static void Main(string[] args)
            {
                WriteLine($"\"Optimize code\" is enabled: {OptimizationDetector.IsOptimizationEnabled}");
                ReadKey();
            }
        }
    }

    ОПТИМИЗИРОВАНО

    Kozel, 29 Июня 2016

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

    +6

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    public void сдвинутьРяд()
      {
        this.caseInventory.setItem(24, this.caseInventory.getItem(23));
        this.caseInventory.setItem(23, this.caseInventory.getItem(22));
        this.caseInventory.setItem(22, this.caseInventory.getItem(21));
        this.caseInventory.setItem(21, this.caseInventory.getItem(20));
        this.caseInventory.setItem(20, null);
      }

    хмхмхмхмххмхмхм

    brinza, 28 Июня 2016

    Комментарии (6)
  8. Куча / Говнокод #20286

    +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
    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
    <xsl:choose>
    	<xsl:when test="name = 'Палатка ALEXIKA RONDO 3 Plus'">
    	<h2>Палатки ALEXIKA – идеальный вариант для активного отдыха</h2></xsl:when>
    	<xsl:otherwise>
    	<xsl:choose>
    		<xsl:when test="name = 'Мешок спальный ALEXIKA SIBERIA Plus(правый)'">
    		<h2>Предпочитаете отдых в палатках? Купите спальный мешок ALEXIKA SIBERIA PLUS</h2></xsl:when>
    		<xsl:otherwise>
    		<xsl:choose>
    			<xsl:when test="name = ''"></xsl:when>
    			<xsl:otherwise>
    			<xsl:choose>
    				<xsl:when test="name = ''"></xsl:when>
    				<xsl:otherwise>
    				<xsl:choose>
    					<xsl:when test="name = ''"></xsl:when>
    					<xsl:otherwise>
    					<xsl:choose>
    						<xsl:when test="name = ''"></xsl:when>
    						<xsl:otherwise>
    						Полное описание товара "<xsl:value-of disable-output-escaping="yes" select="name"/>"
    						</xsl:otherwise>
    					</xsl:choose>
    					</xsl:otherwise>
    				</xsl:choose>
    				</xsl:otherwise>
    			</xsl:choose>
    			</xsl:otherwise>
    		</xsl:choose>
    		</xsl:otherwise>
    	</xsl:choose>
    	</xsl:otherwise>
    </xsl:choose>

    эмм... просто было лень

    arny, 28 Июня 2016

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

    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
    switch (count)
        {
        case 1:
            cout << okonch1 << endl;
            if (okonch1 == okonchanie1)
            {
                cout << slovo_okonch1_1 << endl;
            }
            else
            {
                if (okonch1 == okonchanie2)
                {
                    cout << slovo_okonch2_1 << endl;;
                }
                else
                {
                    if (okonch1 == okonchanie3)
                    {
                        cout << slovo_okonch3_1 << endl;;
                    }
                    else
                    {
                        if (okonch1 == okonchanie4)
                        {
                            cout << slovo_okonch4_1 << endl;
                        }
                        else
                        {
                            if (okonch1 == okonchanie5)
                            {
                                cout << slovo_okonch5_1 << endl;
                            }
                            else
                            {
                                if (okonch1 == okonchanie6)
                                {
                                    cout << slovo_okonch6_1 << endl;
                                }
                                else
                                {
                                    if (okonch1 == okonchanie7)
                                    {
                                        cout << slovo_okonch7_1 << endl;
                                    }
                                    else
                                    {
                                        if (okonch1 == okonchanie8)
                                        {
                                            cout << slovo_okonch8_1 << endl;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

    Создана куча переменных okonch*_* и по ним происходит switch
    Что самое смешное(или ужасное?) - этого кода на 500 строк...

    Rmkek, 27 Июня 2016

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

    +6

    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
    switch ($m->type) {
    			case 'photo':
    				echo sprintf('<div class="fb_photo %s"><a %s href="%s"><div style="background-image: url(\'%s\');"><b>%s</b><br>%s%s<div class="status">%s <img src="%s" /> %s <img src="%s" /></div></div></div>', ($showProfilePic ? 'padding65' : ''), (isset($_GET['nonavbar']) ? 'target="_top"' : 'target="_blank"'), $m->link . (isset($_GET['nonavbar']) ? '&openwithnavigation=1' : ''), str_replace("_s", "_n", $m->picture), $m->from->name, (!empty($m->message) ? $m->message.'<br>' : ''), ago($m->created_time, $timezone), isset($m->likes) && isset($m->likes->count) ? $m->likes->count : '', isset($m->likes)  && isset($m->likes->count) ? buildUri('images/icons/like.png') : '', isset($m->comments) && isset($m->comments->count) ? $m->comments->count : '', isset($m->comments) && isset($m->comments->count) ? buildUri('images/icons/comment.png') : '');
    				break;
    			case 'video':
    			case 'link':
    				echo sprintf('<div class="fb_link %s"><a %s href="%s"><div style="width: 100%%; padding: 30px;  box-sizing: border-box;border-bottom:1px solid #ccc;border-top:1px solid #ccc;"><img style="max-width: none; width:100px;" src="%s" /><div style="width: 100%%"><b>%s</b><br>%s</div></div><div style="position:absolute; right: 10px; bottom: 10px;" class="status">%s <img style="display: inline-block" src="%s" /> %s <img style="display: inline-block" src="%s" /></div></a></div>', ($showProfilePic ? 'padding65' : ''), (isset($_GET['nonavbar']) ? 'target="_top"' : 'target="_blank"'), $m->link . (isset($_GET['nonavbar']) ? '&openwithnavigation=1' : ''), $m->picture, $m->name, $m->message, ago($m->created_time, $timezone), isset($m->likes) && isset($m->likes->count) ? $m->likes->count : '', isset($m->likes) && isset($m->likes->count) ? buildUri('images/icons/like.png') : '', isset($m->comments) && isset($m->comments->count) ? $m->comments->count : '', isset($m->comments) && isset($m->comments->count) ? buildUri('images/icons/comment.png') : '');
    				//echo sprintf('<div class="fb_link"><a href="%s"><div><img src="%s" /><b>%s</b><br>%s<div class="status">%s likes, %s comments</div></div></div></div>', $m->link, str_replace("_s", "_n", $m->picture), $m->from->name, $m->message, $m->likes->count, $m->comments->count);
    				break;
    			case 'status':
    				echo sprintf('<div class="fb_link %s"><a %s href="%s"><div style="width: 100%%; padding: 30px;  box-sizing: border-box;border-bottom:1px solid #ccc;border-top:1px solid #ccc;"><img style="max-width: none; width:100px;" src="%s" /><div style="width: 100%%"><b>%s</b><br>%s</div></div><div style="position:absolute; right: 10px; bottom: 10px;" class="status">%s <img style="display: inline-block" src="%s" /> %s <img style="display: inline-block" src="%s" /></div></a></div>', ($showProfilePic ? 'padding65' : ''), '', '', $m->picture, $m->name, $m->message, ago($m->created_time, $timezone), isset($m->likes) && isset($m->likes->count) ? $m->likes->count : '', isset($m->likes)  && isset($m->likes->count) ? buildUri('images/icons/like.png') : '', isset($m->comments) && isset($m->comments->count) ? $m->comments->count : '', isset($m->comments) && isset($m->comments->count) ? buildUri('images/icons/comment.png') : '');
    				break;
    			default:
    				//echo 'TODO: ' . $m->type;
    				//var_dump($m);
    				break;
    		}

    Верстка.
    Уровень - бог.

    valentinlazy, 27 Июня 2016

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