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

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

    +149

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    // Категории 
    
    $cat_get = textfilter($_GET['name']);
    $cat1 = mysql_query("SELECT * FROM category WHERE url = '".$cat_get."'");
    $cat2 = mysql_fetch_array($cat1);
    $id_cat = $cat2['id'];
    $result = mysql_query("SELECT * FROM articles WHERE category = '".$id_cat."'");
    $row = mysql_fetch_array($result);
    if ($cat_get) { echo $row['title']; }

    Мне до сих пор страшно, накодил и не понял как и что это, но работает!

    kuler, 19 Марта 2012

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

    +117

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    @if(@Html.Raw(message.Summary).ToString().IndexOf("Добавлен комментарий") >= 0) { 
                                    <a href="@href">
                                        @Html.Raw(@message.Summary)
                                   </a>
                                }

    Arbium, 16 Марта 2012

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

    +142

    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
    94. 94
    static void Reading_instruction(string Command)
    {
    	string[] CommandLine = null;
    	try
    	{
    		#region Команды консоли.
    		#region -boxmessage выводит сообщение в диалоговом окне.
    				
    		//Пример: -boxmessage:Привет!*/
    				
    		if (Command.ToLower().StartsWith("-boxmessage"))
    		{
    			CommandLine = Command.Split(new char[] {':'});
    			System.Windows.Forms.MessageBox.Show(CommandLine[1]);
    		}
    		#endregion
    		#region -errormessage выводит сообщение c ошибкой в диалоговом окне.
    				
    		//Пример: -errormessage:Вы забанены!!!:Критическая ошибка!
    				
    		if (Command.ToLower().StartsWith("-errormessage"))
    		{
    			CommandLine = Command.Split(new char[] {':'});
    			System.Windows.Forms.MessageBox.Show(CommandLine[1], CommandLine[2], System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error, System.Windows.Forms.MessageBoxDefaultButton.Button1, System.Windows.Forms.MessageBoxOptions.ServiceNotification);
    		}
    		#endregion
    		#region -consolemessage выводит текст в консоль.
    				
    		//Пример: -consolemessage:Привет!
    				
    		if (Command.ToLower().StartsWith("-consolemessage"))
    		{
    			CommandLine = Command.Split(new char[] {':'});
    			Console.WriteLine(CommandLine[1]);
    		}
    		#endregion
    		#region -killprocess убивает процесс.
    				
    		//Пример: -killprocess explorer
    				
    		if (Command.ToLower().StartsWith("-killprocess"))
    		{
    			CommandLine = Command.Split(new char[] {' '});
    			System.Diagnostics.Process[] myProcesses = System.Diagnostics.Process.GetProcessesByName(CommandLine[1]);
    			foreach (System.Diagnostics.Process instance in myProcesses)
    			{
    				instance.Kill();
    			}
    		}
    		#endregion
    		#region -startprocess запускает новый процесс или открывает файл.
    				
    		//Пример: -startprocess explorer.exe
    				
    		if (Command.ToLower().StartsWith("-startprocess"))
    		{
    			CommandLine = Command.Split(new char[] {' '});
    			System.Diagnostics.Process.Start(CommandLine[1]);
    		}
    		#endregion
    		#region -createfile создает файл.
    				
    		//Пример: -createfile С:\TestFile.txt
    				
    		if (Command.ToLower().StartsWith("-createfile"))
    		{
    			CommandLine = Command.Split(new char[] {' '});
    			System.IO.File.Create(CommandLine[1]);
    		}
    		#endregion
    		#region -deletefile удаляет файл.
    				
    		//Пример: -deletefile С:\TestFile.txt
    				
    		if (Command.ToLower().StartsWith("-deletefile"))
    		{
    			CommandLine = Command.Split(new char[] {' '});
    			System.IO.File.Delete(CommandLine[1]);
    		}
    		#endregion
    		#region -shutdown выключает компьютер.
    				
    		//Пример: -shutdown
    				
    		if (Command.ToLower().StartsWith("-shutdown"))
    		System.Diagnostics.Process.Start("shutdown", "/s /t 0");
    		#endregion
    		#region -reboot перезагружает компьютер.
    				
    		//Пример: -reboot
    				
    		if (Command.ToLower().StartsWith("-reboot"))
    			System.Diagnostics.Process.Start("shutdown", "/r /t 0");
    		#endregion

    Вот кусок говна обнаруженное в моих древних искходниках. Весь смысл закллючается в том что сервер посылает клиенту команду, а клиент ее выполняет.

    KusokGovna, 16 Марта 2012

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

    +156

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    class store_mod_multi_ftp extends store_mod_ftp {
        public function __construct($options) {
            //...
        }
        protected function connect($url, $login) {
            parent::__construct($url, $login);
        }
        //...
    }

    ФТП-мод, который умеет стягивать файлы с разных серверов сразу, в отличие от своего родителя. И ведь работает, зараза!

    Lowezar, 14 Марта 2012

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

    +156

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    $phone = str_replace("с",",",$phone);
    $phone = str_replace("до","",$phone);
    $phone = str_replace("д",",",$phone);
    $phone = str_replace("раб","",$phone);
    $phone = str_replace("м.","",$phone);
    $phone = str_replace("т","",$phone);
    $phone = str_replace("и",",",$phone);

    Silverthorne, 14 Марта 2012

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

    −144

    1. 1
    СуммаРЗ = СуммаРЗ;

    Капитан, это вы?

    mrbus, 14 Марта 2012

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

    +199

    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
    _bc_do_compare: function (n1, n2, use_sign, ignore_last) {
                var n1ptr, n2ptr; // int
        var count; // int
        /* First, compare signs. */
        if (use_sign && (n1.n_sign != n2.n_sign)) {
            if (n1.n_sign == libbcmath.PLUS) {
                return (1); /* Positive N1 > Negative N2 */
            } else {
                return (-1); /* Negative N1 < Positive N1 */
            }
        }
    
        /* Now compare the magnitude. */
        if (n1.n_len != n2.n_len) {
            if (n1.n_len > n2.n_len) { /* Magnitude of n1 > n2. */
                if (!use_sign || (n1.n_sign == libbcmath.PLUS)) {
                    return (1);
                } else {
                    return (-1);
                }
            } else { /* Magnitude of n1 < n2. */
                if (!use_sign || (n1.n_sign == libbcmath.PLUS)) {
                    return (-1);
                } else {
                    return (1);
                }
            }
        }
    
        if (count !== 0) {
            if (n1.n_value[n1ptr] > n2.n_value[n2ptr]) { /* Magnitude of n1 > n2. */
                if (!use_sign || n1.n_sign == libbcmath.PLUS) {
                    return (1);
                } else {
                    return (-1);
                }
            } else { /* Magnitude of n1 < n2. */
                if (!use_sign || n1.n_sign == libbcmath.PLUS) {
                    return (-1);
                } else {
                    return (1);
                }
            }
        }
    
        /* They are equal up to the last part of the equal part of the fraction. */
        if (n1.n_scale != n2.n_scale) {
            if (n1.n_scale > n2.n_scale) {
                for (count = (n1.n_scale - n2.n_scale); count > 0; count--) {
                    if (n1.n_value[n1ptr++] !== 0) { /* Magnitude of n1 > n2. */
                        if (!use_sign || n1.n_sign == libbcmath.PLUS) {
                            return (1);
                        } else {
                            return (-1);
                        }
                    }
                }
            } else {
                for (count = (n2.n_scale - n1.n_scale); count > 0; count--) {
                    if (n2.n_value[n2ptr++] !== 0) { /* Magnitude of n1 < n2. */
                        if (!use_sign || n1.n_sign == libbcmath.PLUS) {
                            return (-1);
                        } else {
                            return (1);
                        }
                    }
                }
            }
    }

    Свежий подход к написанию бульщитов от создателей phpjs.

    3.14159265, 10 Марта 2012

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

    +200

    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
    for (k = 0; k < xl; k += 16) {
            AA = a;
            BB = b;
            CC = c;
            DD = d;
            a = _FF(a, b, c, d, x[k + 0], S11, 0xD76AA478);
            d = _FF(d, a, b, c, x[k + 1], S12, 0xE8C7B756);
            c = _FF(c, d, a, b, x[k + 2], S13, 0x242070DB);
            b = _FF(b, c, d, a, x[k + 3], S14, 0xC1BDCEEE);
            a = _FF(a, b, c, d, x[k + 4], S11, 0xF57C0FAF);
            d = _FF(d, a, b, c, x[k + 5], S12, 0x4787C62A);
            c = _FF(c, d, a, b, x[k + 6], S13, 0xA8304613);
            b = _FF(b, c, d, a, x[k + 7], S14, 0xFD469501);
            a = _FF(a, b, c, d, x[k + 8], S11, 0x698098D8);
            d = _FF(d, a, b, c, x[k + 9], S12, 0x8B44F7AF);
            c = _FF(c, d, a, b, x[k + 10], S13, 0xFFFF5BB1);
            b = _FF(b, c, d, a, x[k + 11], S14, 0x895CD7BE);
            a = _FF(a, b, c, d, x[k + 12], S11, 0x6B901122);
            d = _FF(d, a, b, c, x[k + 13], S12, 0xFD987193);
            c = _FF(c, d, a, b, x[k + 14], S13, 0xA679438E);
            b = _FF(b, c, d, a, x[k + 15], S14, 0x49B40821);
            a = _GG(a, b, c, d, x[k + 1], S21, 0xF61E2562);
            d = _GG(d, a, b, c, x[k + 6], S22, 0xC040B340);
            c = _GG(c, d, a, b, x[k + 11], S23, 0x265E5A51);
            b = _GG(b, c, d, a, x[k + 0], S24, 0xE9B6C7AA);
            a = _GG(a, b, c, d, x[k + 5], S21, 0xD62F105D);
            d = _GG(d, a, b, c, x[k + 10], S22, 0x2441453);
            c = _GG(c, d, a, b, x[k + 15], S23, 0xD8A1E681);
    <40 строк поспипано>
            b = _II(b, c, d, a, x[k + 9], S44, 0xEB86D391);
            a = addUnsigned(a, AA);
            b = addUnsigned(b, BB);
            c = addUnsigned(c, CC);
            d = addUnsigned(d, DD);
    }

    http://phpjs.org/downloads/phpjs.commonjs.js.
    Там оказалось реально много жира. Я сначала подумал, что сеть Фейштеля, но потом-таки разглядел MD5.
    Говносути это конечно не меняет.

    3.14159265, 07 Марта 2012

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

    +153

    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
    $('#panAll').click( function(){
    	                $(this).addClass('panactive');
    	                
    	                $('#panPan').removeClass('panactive');
    	                $('#pan3D').removeClass('panactive');
    	                $('#panVtour').removeClass('panactive');
    	                
    	                $('#AllDesc').css('display', 'block');
    	                $('#PanDesc').css('display', 'none');
    	                $('#3DDesc').css('display', 'none');
    	                $('#VtourDesc').css('display', 'none');
    	            }); 
    	            
    	            $('#panPan').click( function(){
    	                $(this).addClass('panactive');
    	                
    	                $('#panAll').removeClass('panactive');
    	                $('#pan3D').removeClass('panactive');
    	                $('#panVtour').removeClass('panactive');
    	                
    	                $('#AllDesc').css('display', 'none');
    	                $('#PanDesc').css('display', 'block');
    	                $('#3DDesc').css('display', 'none');
    	                $('#VtourDesc').css('display', 'none');
    	            }); 
    	            
    	            $('#pan3D').click( function(){
    	                $(this).addClass('panactive');
    	                
    	                $('#panAll').removeClass('panactive');
    	                $('#panPan').removeClass('panactive');
    	                $('#panVtour').removeClass('panactive');
    	                
    	                $('#AllDesc').css('display', 'none');
    	                $('#PanDesc').css('display', 'none');
    	                $('#3DDesc').css('display', 'block');
    	                $('#VtourDesc').css('display', 'none');
    	            }); 
    	            $('#panVtour').click( function(){
    	                $(this).addClass('panactive');
    	                
    	                $('#panAll').removeClass('panactive');
    	                $('#panPan').removeClass('panactive');
    	                $('#pan3D').removeClass('panactive');
    	                
    	                $('#AllDesc').css('display', 'none');
    	                $('#PanDesc').css('display', 'none');
    	                $('#3DDesc').css('display', 'none');
    	                $('#VtourDesc').css('display', 'block');
    	            });

    Висит задание в црм - доделать ***.
    Таким вот образом был реализован функционал
    переключения между 4мя дивами, содержащими в себе данные.

    denum, 05 Марта 2012

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

    +209

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    const evalScript = "with (__win__.__scope__.vars) { with (__win__.__scope__.api) { with (__win__.__scope__.userVars) { with (__win__) {" +
        "try {" +
            "__win__.__scope__.callback(eval(__win__.__scope__.expr));" +
        "} catch (exc) {" +
            "__win__.__scope__.callback(exc, true);" +
        "}" +
    "}}}}";

    http://code.google.com/p/fbug/source/browse/branches/firebug1.2/content/firebug/commandLine.js?r=444

    3.14159265, 03 Марта 2012

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