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

    В номинации:
    За время:
  2. 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)
  3. 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)
  4. Си / Говнокод #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)
  5. 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)
  6. 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)
  7. PHP / Говнокод #4668

    +164

    1. 1
    2. 2
    3. 3
    4. 4
    public function __destruct () {
      $props =& get_object_vars($this);
      $props = array();
    }

    Двойное уничтожение (если прокатит )))).

    dwinner, 17 Ноября 2010

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

    +163

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    // и нафига я использовал тут исключения? :)
      try {
        if(!trim($to)) throw new Exception('aдpecaт');
        if(!trim($in['msg'])) throw new Exception('тeкcт');
        if(!trim($in['subj'])) throw new Exception('тема');
      } catch (Exception $e) {
        raise_error('Отсутствует '.$e->GetMessage().' сообщения.', 'write.php?to='.$to.'&amp;'.SID);

    да, нафига?)

    DmitryDick, 08 Ноября 2010

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

    −125

    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
    while (<>)
      {
        chomp;
        s/\r$//;
        next unless $_;
        my ($tag, $value) = split / /, $_, 2;
        die "Font is not fixed width\n"
          if $tag eq 'SPACING' and not $value =~ /[CM]/i;
    
        $currentchar = $value if $tag eq 'ENCODING';
        $minchar = $currentchar if not defined $minchar
          or ($currentchar < $minchar && $currentchar >= 0);
        $maxchar = $currentchar if not defined $maxchar
          or ($currentchar > $maxchar && $currentchar >= 0);

    И дальше в том же духе...
    Взято из файла bdf2gdfont.pl

    Arigato, 01 Ноября 2010

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

    +139

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    <noindex>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    ...
    <noindex>

    Заказчик попросил изменить шаблон. Открываю, а там это

    Setti, 31 Октября 2010

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

    +138

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    <div class="foot-menu">
    	<ul><li><a href='/artprojects/proekty-vystavki/'>Проекты<br />Выставки</a></li></ul>
    	<ul><li><a href='/theatre/teatralqnye-proekty/'>Театральные проекты</a></li></ul>
    	<ul><li><a href='/fashion/fashion-fotosessii/'>Fashion фотосессии</a></li></ul>
    	<ul><li><a href='/portfolio/aktery--teatra-i-kino/'>Актеры<br />театра и кино</a></li></ul>
    	<ul><li><a href='/wedding/svadebnye--fotografii/'>Свадебные<br />фотографии</a></li></ul>
    	<ul><li><a href='/advert/reklama--advertising/'>Реклама<br />Advertising</a></li></ul>
    	<ul><li><a href='/celeb/raznoe--film-prod/'>Oбучение<br />master class.</a></li></ul>
    </div>

    Семантичное меню должно быть сделано списками!

    Jesus, 26 Октября 2010

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