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

    +156

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    $save=$_POST['save'];
    	if ($save == 'yes') {
    		$cont=mysql_real_escape_string_ir($_POST['cont']);
    
    		@mysql_query("DELETE FROM ".$tables['_page']." WHERE id_kat='$id_kat'");
    		@mysql_query("INSERT INTO ".$tables['_page']." (id_kat, txt, dt) VALUES ('$id_kat', '$cont', NOW())");
    
    		deleteCache($id_kat, $cid, $insert_id, 'pages', $cont);
    		insertCache($id_kat, $cid, $insert_id, 'pages', $cont);
    	};

    Код из админки сайта, разработанного студией "Интернет Решения" (IRSite)

    Djiggo, 05 Марта 2015

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

    −119

    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
    {""code"":"""+Строка(Результат.ID)+""","+
    """gender"":"""+Результат.Пол+""","+
    """dob"":"""+Результат.ДатаРождения+""","+
    """passport"":"""+Результат.ПаспортныеДанные+""","+
    """address"":"""+Результат.Адрес+""","+
    """phone"":"""+Результат.Телефон+""","+
    """skype"":"""+Результат.Skype+""","+
    """email"":"""+Результат.Email+""","+
    """last_name"":"""+Фамилия+""","+
    """first_name"":"""+Имя+""","+
    """middle_name"":"""+Отчество+""","+
    """ref_first_name"":"""+ИмяСпонсора+""","+
    """ref_last_name"":"""+ФамилияСпонсора+""","+
    """ref_middle_name"":"""+ОтчествоСпонсора+""","+
    """ref_id"":"""+Строка(Результат.РефералID)+""","+
    """money"":"""+СтрЗаменить(Строка(Результат.БалансРуб),",",".")+
    ""","+"""balls"":"""+СтрЗаменить(Строка(Результат.БалансБалл),",",".")+""","+
    """pack"":"""+Результат.Пакет+""","+
    """password"":"""+Результат.Пароль+""""+"}";

    "Простая библиотека для кодирования JSON"

    Rijen, 05 Марта 2015

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

    +157

    1. 1
    <button type="button" class="btn blue" style="float: left; margin-bottom: 20px; margin-left: 15px;" onclick="window.location = '/cars/car/update/id/<?php echo $model->id; ?>'"></button>

    Проект работает на основе Yii framework. Тут явное пренебрежение всеми концепциями и стандартами: от размещения css в html элементе, до не понимания, как устроен веб в целом -- почему window.location, а не обычный линк, для меня остается тайной. Искренне желаю взглянуть в лицо автору кода.

    creepy-code, 05 Марта 2015

    Комментарии (26)
  4. Java / Говнокод #17732

    +85

    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
    public final class Equality {
        /**
         * @param o an object
         * @param a an object to be compared with {@code o} for equality
         * @return true if the arguments are equal to each other and false otherwise
         */
        public static <O> boolean eq(@Nullable O o, @Nullable O a) {
            return Objects.equals(o, a);
        }
    
        /**
         * @param o an object
         * @param a an object to be compared with {@code o} for equality
         * @return true if the any arguments are equal to each other and false otherwise
         */
        public static <O> boolean eqAny(@Nullable O o, @Nullable O a) {
            return eq(o, a);
        }
    
        /**
         * @param o an object
         * @param a an object to be compared with {@code o} for equality
         * @param b an object to be compared with {@code o} for equality
         * @return true if the any arguments are equal to each other and false otherwise
         */
        public static <O> boolean eqAny(@Nullable O o, @Nullable O a, @Nullable O b) {
            return eq(o, a) || eq(o, b);
        }
    
        /**
         * @param o an object
         * @param a an object to be compared with {@code o} for equality
         * @param b an object to be compared with {@code o} for equality
         * @param c an object to be compared with {@code o} for equality
         * @return true if the any arguments are equal to each other and false otherwise
         */
        public static <O> boolean eqAny(@Nullable O o, @Nullable O a, @Nullable O b, @Nullable O c) {
            return eqAny(o, a, b) || eq(o, c);
        }
    
        /**
         * @param o an object
         * @param a an object to be compared with {@code o} for equality
         * @param b an object to be compared with {@code o} for equality
         * @param c an object to be compared with {@code o} for equality
         * @param d an object to be compared with {@code o} for equality
         * @return true if the any arguments are equal to each other and false otherwise
         */
        public static <O> boolean eqAny(@Nullable O o, @Nullable O a, @Nullable O b, @Nullable O c, @Nullable O d) {
            return eqAny(o, a, b, c) || eq(o, d);
        }
    
    
        /**
         * @param o an object
         * @param a an object to be compared with {@code o} for equality
         * @param b an object to be compared with {@code o} for equality
         * @param c an object to be compared with {@code o} for equality
         * @param d an object to be compared with {@code o} for equality
         * @param e an object to be compared with {@code o} for equality
         * @return true if the any arguments are equal to each other and false otherwise
         */
        public static <O> boolean eqAny(@Nullable O o, @Nullable O a, @Nullable O b, @Nullable O c, @Nullable O d, @Nullable O e) {
            return eqAny(o, a, b, c, d) || eq(o, e);
        }
        
        /**
         * @param o an object
         * @param a an array of objects to be compared
         * @return true if any the arguments are equal to each other and false otherwise
         */
        public static <O> boolean eqAny(@Nullable O o, O... a) {
            for(O e: a)
                if(eq(o, e))
                    return true;
            return false;
        }
    }

    Мой любимый класс.
    Когда на душе становится тяжело, я всегда открываю этот класс, и признаки депрессии улетучиваются.
    И да, комментарии врут, и да, там еще столько же методов eqAll(...)

    stasmarkin, 05 Марта 2015

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

    +62

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    void f(bool *ok = 0)
    {
        //тут возникла ошибка
        if (ok)
            *ok = false;
        return;
    }
    
    //далее в коде
    bool ok = false;
    f(&ok);

    не, ну заебок, чо

    blackhearted, 05 Марта 2015

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

    +51

    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
    #if defined(alignas) /* check C++ keywords */ \ 
    || defined(alignof) \ 
    || defined(asm) \ 
    || defined(auto) \ 
    || defined(bool) \ 
    
    <...snip...>
    
    || defined(virtual) \ 
    || defined(void) \ 
    || defined(volatile) \ 
    || defined(wchar_t) \ 
    || defined(while) 
    #error keyword defined before including C++ standard header 
    #endif /* defined... */

    Из заголовочных файлов VS 2012.

    http://www.viva64.com/en/b/0146/

    someone, 05 Марта 2015

    Комментарии (7)
  7. Python / Говнокод #17729

    −113

    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
    user8@linux ~ $ python
    Python 2.7.5 (default, Feb 10 2014, 02:34:23) 
    [GCC 4.7.3] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import math
    >>> 1-3*(math.exp(1)-2)/math.exp(1)
    0.207276647028654
    >>> 1-4*(1-3*(math.exp(1)-2)/math.exp(1))
    0.17089341188538398
    >>> 1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1)))
    0.14553294057308008
    >>> 1 - 6*(1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1))))
    0.1268023565615195
    >>> 1-7*(1 - 6*(1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1)))))
    0.11238350406936348
    >>> 1-8*(1-7*(1 - 6*(1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1))))))
    0.10093196744509214
    >>> 1-9*(1-8*(1-7*(1 - 6*(1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1)))))))
    0.09161229299417073
    >>> 1-10*(1-9*(1-8*(1-7*(1 - 6*(1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1))))))))
    0.0838770700582927
    >>> 1-11*(1-10*(1-9*(1-8*(1-7*(1 - 6*(1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1)))))))))
    0.07735222935878028
    >>> 1-12*(1-11*(1-10*(1-9*(1-8*(1-7*(1 - 6*(1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1))))))))))
    0.07177324769463667
    >>> 1-13*(1-12*(1-11*(1-10*(1-9*(1-8*(1-7*(1 - 6*(1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1)))))))))))
    0.06694777996972334
    >>> 1-14*(1-13*(1-12*(1-11*(1-10*(1-9*(1-8*(1-7*(1 - 6*(1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1))))))))))))
    0.06273108042387321
    >>> 1-15*(1-14*(1-13*(1-12*(1-11*(1-10*(1-9*(1-8*(1-7*(1 - 6*(1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1)))))))))))))
    0.059033793641901866
    >>> 1-16*(1-15*(1-14*(1-13*(1-12*(1-11*(1-10*(1-9*(1-8*(1-7*(1 - 6*(1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1))))))))))))))
    0.05545930172957014
    >>> 1-17*(1-16*(1-15*(1-14*(1-13*(1-12*(1-11*(1-10*(1-9*(1-8*(1-7*(1 - 6*(1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1)))))))))))))))
    0.05719187059730757
    >>> 1-18*(1-17*(1-16*(1-15*(1-14*(1-13*(1-12*(1-11*(1-10*(1-9*(1-8*(1-7*(1 - 6*(1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1))))))))))))))))
    -0.029453670751536265

    Дано рекуррентное соотношение: x 1 = 1 e , x k = 1 − kx k−1 , k = 2, 3, 4, . . .
    Напишите программу, которая вычисляет первые 15 чисел с точностью float и выводит их на экран

    xXx_KaKaXa2002_xXx, 05 Марта 2015

    Комментарии (7)
  8. VisualBasic / Говнокод #17728

    −121

    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
    If ((ind_imit_gun = 0) And _
                ((input_B_LA2 And shop) = shop) And _
                ((input_B_LA2 And loading) = loading) And _
                ((input_B_LA2 And lonely) = lonely) And _
                (input_A_LA48 And choice_k) = choice_k) _
                Or ((ind_imit_gun = 0) And _
                ((input_B_LA2 And shop) = shop) And _
                ((input_B_LA2 And loading) = loading) And _
                ((input_B_LA2 And mashin) = mashin) And _
                (input_A_LA48 And choice_k) = choice_k) _
                Or ((ind_imit_gun = 1) And _
                ((input_B_LA2 And shop) = shop) And _
                ((input_B_LA2 And loading) = loading) And _
                ((input_B_LA2 And lonely) = lonely) And _
                (input_A_LA48 And choice_k) = choice_k) _
                Or ((ind_imit_gun = 2) And _
                ((input_B_LA2 And loading) = loading) And _
                ((input_B_LA2 And lonely) = lonely) And _
                (input_A_LA48 And choice_k) = choice_k) _
                Or ((ind_imit_gun = 2) And _
                ((input_B_LA2 And loading) = loading) And _
                ((input_B_LA2 And mashin) = mashin) And _
                (input_A_LA48 And choice_k) = choice_k) _
                Or ((ind_imit_gun = 3) And _
                ((input_B_LA2 And loading) = loading) And _
                ((input_B_LA2 And mashin) = mashin) And _
                (input_A_LA48 And choice_k) = choice_k) _
                Or ((ind_imit_gun = 4) And _
                ((input_B_LA2 And loading) = loading) And _
                ((input_B_LA2 And lonely) = lonely) And _
                (input_A_LA48 And choice_k) = choice_k) _
                Or ((ind_imit_gun = 6) And _
               ((input_B_LA2 And loading) = loading) And _
                ((input_B_LA2 And lonely) = lonely) And _
                (input_A_LA48 And choice_k) = choice_k) Then

    Вот такая страшная проверка нужных битов битовыми масками используется в одном военном ПО xD
    И на мой взгляд тут есть ошибки,но почему то работает.

    Ramirag, 05 Марта 2015

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

    +157

    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
    <?php
    class smth {
        protected static $MARK_UNDEFINED = 'Undefined';
        protected static $MARK_F  = 'ECTS-F';
        protected static $MARK_FX = 'ECTS-FX';
        protected static $MARK_E  = 'ECTS-E';
        protected static $MARK_D  = 'ECTS-D';
        protected static $MARK_C  = 'ECTS-C';
        protected static $MARK_B  = 'ECTS-B';
        protected static $MARK_A  = 'ECTS-A';
    
        protected function getECTSMark($rate, $current, $examRate)
        {
            $color = self::$MARK_UNDEFINED;
            if ($current > 0) {
                $percent = $rate / $current;
                if ($examRate !== NULL AND $examRate < 22)
                    $color = self::$MARK_FX;
                elseif ($percent < 0.31)
                    $color = self::$MARK_F;
                elseif ($percent < 0.60)
                    $color = self::$MARK_FX;
                elseif ($percent < 0.65)
                    $color = self::$MARK_E;
                elseif ($percent < 0.71)
                    $color = self::$MARK_D;
                elseif ($percent < 0.85)
                    $color = self::$MARK_C;
                elseif ($percent < 0.95)
                    $color = self::$MARK_B;
                else
                    $color = self::$MARK_A;
            }
            return $color;
        }
    }

    Сижу и думаю, как это вообще можно как-то.. отговнокодить? О_о

    xamgore, 05 Марта 2015

    Комментарии (20)
  10. Куча / Говнокод #17726

    +145

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    ###
    CoffeeScript
    Give a fuck
    ###
    while fuck isnt given
    	do give_a_fuck until orgasm

    mikamika83, 04 Марта 2015

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