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

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

    +118

    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
    private void Gamexxx_Bolls_KeyDown(object sender, KeyEventArgs e)
    {
    OTCTeleText ttText;
    List TTList;
    TTList = new List();
    if (e.KeyValue == 13)
    {
    try
    {
    //Control ctrl = (Control)sender;
    ctrl = (Control)sender;
    String szName = ctrl.Name.Substring(16);
    int nOrderNumber = Convert.ToInt32(szName);
    int nNumber = 0;
    try
    {
    nNumber = Convert.ToInt32(ctrl.Text);
    }
    catch (Exception /*ex*/)
    {
    }
    
    .......
    
    }
    catch (Exception /*ex*/)
    {
    }
    }
    }

    Ярое использование трайкетча и чрезмерное внимание к женщинам лёгкого поведения ведут к освенциму.
    TryParse вместо тысячи слов
    Да, аве мне, аве!

    ursus, 28 Апреля 2011

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

    +151

    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
    if(get_magic_quotes_gpc()) {
        deslash($_GET);
        deslash($_POST);
    }
    
    /*
     * function deslash(&$a)
     * убирает слеши из данных извне
     */
    function deslash(&$a) {
        if(defined('DEBUG'))echo '<br/>deslashing: '.print_r($a,true).'<br/>';
        foreach($a as $k=>$v)
            if (is_array($v)) {
                deslash($a[$k]);
            } else {
                if(defined('DEBUG')) echo 'was: '.$k.' => '.$v.'<br/>';
                $a[$k] = stripslashes($v);
                if(defined('DEBUG')) echo 'become: '.$k.' => '.$a[$k].'<br/>';
            }
    }

    Слэши не пройдут!

    RomaShka, 15 Апреля 2011

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

    +172

    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
    CString convertInt2Str(int i_Number, int i_NumDigits)
    {
    	CString str = "";
    	for(int j=1; j<i_NumDigits; j++)
    	{
    		int digits = (int) pow((float) 10, j);
    		
    		if(i_Number<digits) str += "0";			
    	}	
    	CString num;
    	num.Format("%d", i_Number);
    	return str+num;
    }

    Adding leading zeros...

    Aleskey, 29 Марта 2011

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

    +165

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    function shake(dom, power, count, duration) {
        dom.stop();
        for (var i = 0; i < count; i++) {
            dom.animate({'margin-left': ((i%2 == 0) ? '+' : '-') + '=' + ((i == 0 || i == count-1) ? power/2 : power)}, duration);
        }
    }

    Оптимизация рулит :)

    serj_alekseev, 22 Февраля 2011

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

    +172

    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
    /* Теперь задаём сами функции перекодировки translita в кириллицу и обратно. Вот код: */
    
    function ruslat ($string) # Задаём функцию перекодировки кириллицы в транслит.
    {
    $string = ereg_replace("ж","zh",$string);
    $string = ereg_replace("ё","yo",$string);
    $string = ereg_replace("й","i",$string);
    $string = ereg_replace("ю","yu",$string);
    $string = ereg_replace("ь","'",$string);
    $string = ereg_replace("ч","ch",$string);
    $string = ereg_replace("щ","sh",$string);
    $string = ereg_replace("ц","c",$string);
    $string = ereg_replace("у","u",$string);
    $string = ereg_replace("к","k",$string);
    $string = ereg_replace("е","e",$string);
    $string = ereg_replace("н","n",$string);
    $string = ereg_replace("г","g",$string);
    $string = ereg_replace("ш","sh",$string);
    $string = ereg_replace("з","z",$string);
    $string = ereg_replace("х","h",$string);
    $string = ereg_replace("ъ","''",$string);
    $string = ereg_replace("ф","f",$string);
    $string = ereg_replace("ы","y",$string);
    $string = ereg_replace("в","v",$string);
    $string = ereg_replace("а","a",$string);
    $string = ereg_replace("п","p",$string);
    $string = ereg_replace("р","r",$string);
    $string = ereg_replace("о","o",$string);
    $string = ereg_replace("л","l",$string);
    $string = ereg_replace("д","d",$string);
    $string = ereg_replace("э","yе",$string);
    $string = ereg_replace("я","jа",$string);
    $string = ereg_replace("с","s",$string);
    $string = ereg_replace("м","m",$string);
    $string = ereg_replace("и","i",$string);
    $string = ereg_replace("т","t",$string);
    $string = ereg_replace("б","b",$string);
    $string = ereg_replace("Ё","yo",$string);
    $string = ereg_replace("Й","I",$string);
    $string = ereg_replace("Ю","YU",$string);
    $string = ereg_replace("Ч","CH",$string);
    $string = ereg_replace("Ь","'",$string);
    $string = ereg_replace("Щ","SH'",$string);
    $string = ereg_replace("Ц","C",$string);
    $string = ereg_replace("У","U",$string);
    $string = ereg_replace("К","K",$string);
    $string = ereg_replace("Е","E",$string);
    $string = ereg_replace("Н","N",$string);
    $string = ereg_replace("Г","G",$string);
    $string = ereg_replace("Ш","SH",$string);
    $string = ereg_replace("З","Z",$string);
    $string = ereg_replace("Х","H",$string);
    $string = ereg_replace("Ъ","''",$string);
    $string = ereg_replace("Ф","F",$string);
    $string = ereg_replace("Ы","Y",$string);
    $string = ereg_replace("В","V",$string);
    $string = ereg_replace("А","A",$string);
    $string = ereg_replace("П","P",$string);
    $string = ereg_replace("Р","R",$string);
    $string = ereg_replace("О","O",$string);
    $string = ereg_replace("Л","L",$string);
    $string = ereg_replace("Д","D",$string);
    $string = ereg_replace("Ж","Zh",$string);
    $string = ereg_replace("Э","Ye",$string);
    $string = ereg_replace("Я","Ja",$string);
    $string = ereg_replace("С","S",$string);
    $string = ereg_replace("М","M",$string);
    $string = ereg_replace("И","I",$string);
    $string = ereg_replace("Т","T",$string);
    $string = ereg_replace("Б","B",$string);
    return $string;
    }

    Нашел сие чудо на: http://protoplex.ru/lib/?showid=89

    code_master, 10 Февраля 2011

    Комментарии (25)
  7. PHP / Говнокод #5118

    +164

    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
    <?php
    /**
    * Sticky Notes pastebin
    * @ver 0.1
    * @license BSD License - www.opensource.org/licenses/bsd-license.php
    *
    * Copyright (c) 2011 Sayak Banerjee <[email protected]>
    * All rights reserved. Do not remove this copyright notice.
    */
    
    class core
    {
        // Global vars
        var $build;
    
        // Constructor
        function __construct()
        {
            $this->build = '0.1.17122010.2';
        }
    
        // Function to return root path
        function path()
        {
            $path = $_SERVER['PHP_SELF'];
            $snip = strrpos($path, '/');
            $path = substr($path, 0, $snip + 1);
    
            return $path;
        }
    
        // Function to return remote IP
        function remote_ip()
        {
            return $_SERVER['REMOTE_ADDR'];
        }
    
        // Function to set a cookie
        function setcookie($name, $value, $expire = 0)
        {
            setcookie('stickynotes_' . $name, $value, $expire);
        }
    
        // Slash fix
        function fixslashes(&$data, $list = false)
        {
    	global $db;
    
    	$data = addslashes($data);
    	$db->unescape($data);
        }
    
        // Function to fetch query strings / post data
        function variable($name, $default, $is_cookie = false)
        {
            if (gettype($default) == "integer")
            {
                settype($default, "double");
            }
    
            if ($is_cookie && isset($_COOKIE['stickynotes_' . $name]))
            {
                $cookie_data = $_COOKIE['stickynotes_' . $name];
                settype($cookie_data, gettype($default));
    
                return $cookie_data;
            }
            else if (isset($_POST[$name]))
            {
                $post_data = $_POST[$name];
                settype($post_data, gettype($default));
    
                return $post_data;
            }
            else if (isset($_GET[$name]))
            {
                $get_data = $_GET[$name];
                settype($get_data, gettype($default));
    
                return $get_data;
            }
            else
            {
                return $default;
            }
    
        }

    qbasic, 30 Декабря 2010

    Комментарии (25)
  8. ActionScript / Говнокод #5103

    −87

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    [ArgumentOutOfRangeException: Length cannot be less than zero. Parameter name: length]
       System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy) +10082728
       RabotaUA.ChannelWeb.Helpers.KOHelper.header1() +810
       ASP.views_shared_header_ko_ascx.__Render__control1(HtmlTextWriter __w, Control parameterContainer) in c:\Inetpub\wwwroot\ChannelWeb\Views\Shared\Header\KO.ascx:38
       System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +115
       System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +240
       System.Web.UI.Page.Render(HtmlTextWriter writer) +38
       System.Web.Mvc.ViewPage.Render(HtmlTextWriter writer) +94
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4240

    гиперпространство ?

    bahamot, 29 Декабря 2010

    Комментарии (25)
  9. Си / Говнокод #4869

    +134

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    ............................
    int mas1[5]={1,6,3,4,9};
    int mas2[5]={9,6,3,4,1};
    int mas3[5];
    mas mas3[1]=sqr (mas1[1]*mas2[1]);  
    mas mas3[2]=sqr (mas1[2]*mas2[2]);
    mas mas3[3]=sqr (mas1[3]*mas2[3]);
    mas mas3[4]=sqr (mas1[4]*mas2[4]);
    mas mas3[5]=sqr (mas1[5]*mas2[5]);
    ............................

    Данный пример народного творчества попался мне в работе одного стюдента ) синтаксис сохранен в оригинале там точно написано sqr :). А пример должен был вычислять среднегеометрическое и писать в третий массив.

    USERNAME, 08 Декабря 2010

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

    +161

    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
    $sec_in_year = 31536000;
    $sec_in_lyear = 31622400;
    $sec_in_28 = 2419200;
    $sec_in_29 = 2505600;
    $sec_in_30 = 2592000;
    $sec_in_31 = 2678400;
    $sec_in_day = 86400;
    $sec_in_hour = 3600;
    $sec_in_min = 60;
    $year_count = 1970;
    $month_count = 0;
    $day_count = 1;
    $hour_count = 0;
    $min_count = 0;
    $lyear_count = 2;                                                // Make an array of seconds per month for ease of use.
    $months = array(2678400, 2419200, 2678400, 2592000, 2678400, 2592000, 2678400, 2678400, 2592000, 2678400, 2592000, 2678400);
    $lmonths = array(2678400, 2505600, 2678400, 2592000, 2678400, 2592000, 2678400, 2678400, 2592000, 2678400, 2592000, 2678400);
    $month_list = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec');
    
    while($utime >= $sec_in_year) {                        // Count the year since 1970.
            if($lyear_count % 4 == 0) {
              $utime -= $sec_in_lyear;                // Compensate for leap years.
            }
            else {
              $utime -= $sec_in_year;
            }
            $year_count++;
            $lyear_count++;
    }
    while($utime >= $months[$month_count]) {        // Count the months since Jan.
            if($lyear_count % 4 == 0) {
                    $utime -= $lmonths[$month_count];        // Compensate for leap year Feb.
            }
            else {
                    $utime -= $months[$month_count];
            }
            $month_count++;
    }

    И еще куча строк кода.
    Конвертим никсовый временной штамп, в читаемый для человека формат... aka date()

    fork, 07 Декабря 2010

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

    +168

    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
    function check() {
       $pattern = '|^[-\d]*$|i';
       if ($this->is_required) {
         # Проверяем поле value на максимальное и минимальное значение
         if ($this->min_value != $this->max_value) {
           if ($this->value < $this->min_value || $this->value > $this->max_value) {
             return "Поле \"".$this->caption."\"  должно быть больше ".$this->min_value." и меньше ".$this->max_value."";
           }
         }
         $pattern = "|^[-\d]+$|i";
       }
       # Проверяем, является ли введённое значениe целым числом
       if(!preg_match($pattern, $this->value)) {
         return "Поле \"".$this->caption."\" должно содержать лишь цифры";
       }
       return "";
    }

    Целое число - это число, в котором может быть целая куча знаков минус, но самое главное - без учёта регистра! (Softtime.ru)

    dwinner, 03 Декабря 2010

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