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

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

    +144.2

    1. 1
    2. 2
    3. 3
    4. 4
    if ($result)
        return true;
    else
        return false;

    Вот это да...

    Umnik, 14 Апреля 2010

    Комментарии (17)
  3. JavaScript / Говнокод #2982

    +144.8

    1. 1
    <li><script type="text/javascript" src="http://reformal.ru/tab.js?title=%C3%EE%E2%ED%EE%EA%EE%E4.%F0%F3%3A+%EF%EE+%EA%EE%EB%E5%ED%EE+%E2+%EA%EE%E4%E5&amp;domain=govnokod&amp;color=adadad&amp;align=left&amp;charset=utf-8&amp;ltitle=%CE%F2%E7%FB%E2%FB&amp;lfont=Verdana,%20Geneva,%20sans-serif&amp;lsize=11px&amp;waction=0&amp;regime=1"></script></li>

    А теперь отгадайте с какого это сайта

    hromjo, 10 Апреля 2010

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

    +60.2

    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
    bool CMLayer::operator==(CMLayer ^a, CMLayer ^b)
    {
    	CLayer *pA;
    	CLayer *pB;
    	bool bA = false;
    	bool bB = false;
    
    	// Проверка в катче
    	try
    	{
    		pA = a->m_pelMain;
    	}
    	catch (System::NullReferenceException ^)
    	{
    		pA = NULL;
    		bA = true;
    	}
    
    	// Проверка в катче
    	try
    	{
    		pB = b->m_pelMain;
    	}
    	catch (System::NullReferenceException ^)
    	{
    		pB = NULL;
    		bB = true;
    	}
    
    	if ((bA == true) && (bB == true))
    		return true;
    	else if ((bA == true) || (bB == true))
    		return false;
    
    	return pA == pB;
    }

    Код на Management C++, тот кто его писал был явно в ажуре))))
    Проверяются указатели на внутрении данные, а штоб System::NullReferenceException не выскакивал при сравнее на null все сделанно в катче

    Snake2101, 09 Апреля 2010

    Комментарии (17)
  5. Си / Говнокод #2968

    +129.2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    new = ngx_pnalloc(cf->pool, sizeof("; domain=") - 1 + domain->len);
        if (new == NULL) {
            return NGX_CONF_ERROR;
        }
    
        p = ngx_cpymem(new, "; domain=", sizeof("; domain=") - 1);
        ngx_memcpy(p, domain->data, domain->len);
    
        domain->len += sizeof("; domain=") - 1;

    Это, между прочим, файл nginx-0.7.62\src\http\modules\ngx_http_userid_ filter_module.c.
    Такие вот разочарования случаются...

    dmitry_113, 08 Апреля 2010

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

    +67.4

    1. 1
    2. 2
    Apache POI
    The apache project has a library which called POI that can read and write the HSSF (Horrible Spread Sheet Format)

    Не говнокод, но официальное название формата доставляет :)

    zlob.jc, 02 Апреля 2010

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

    +160.2

    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
    function createCategory(){
    	global $_POST,$_SESSION;
    	$result = mysql_query(sprintf("INSERT INTO `categories` (`id` ,`name` ,`description`)
    									VALUES (NULL , %s, %s);",
    	$this->prepare($_POST['name']), $this->prepare($_POST['description'])));
    	
    	return $result?true:false;
    }
    function prepare($data,$type = 'other'){
    		if($type == 'other'){
    		if(is_numeric($data) or is_float($data)){
    			return "'".$data."'";
    		}else if(is_string($data)){
    			return "'".mysql_real_escape_string($data)."'";
    		}
    		}else if($type == 'pswd'){
    			return "'".sha1($data.SECRET_WORD)."'";
    		}
    	}

    Насколько это защищено от sql injection?

    DanxilLs, 26 Марта 2010

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

    +162.2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    $l = array('q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'z', 'x', 'c', 'v', 'b', 'n', 'm', '-', '.');
    $len = 9;
    for ($i = 0; $i < 100; $i++) //цикл для проверки=)
    {
        $login = '';
        while (strlen($login) < $len) {
            $current = $l[mt_rand(0, (((strlen($login) + 1 == $len) || (strlen($login) == 0)) ? count($l) - 3 : count($l) - 1))]; //мама ради миня абратна
            $login. = ((substr($login, strlen($login) - 1, 1)) == $current) ? '' : $current;
        }
    
        echo $login."<br>";
    }

    наверно самый извращенный код для генереции случайних строк который я когда либо писал=)
    примерно такие требования
    в начале и в конце как точки, так и тире быть тоже не должно
    Т.е другими словами, должен начинаться буквой и заканчиваться буквой
    не иметь двух тире и двухточие подряд

    nur, 15 Марта 2010

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

    +161

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    function isValidEmail(address) {
        if (address.indexOf('@') < 1) return false;
        var name = address.substring(0, address.indexOf('@'));
        var domain = address.substring(address.indexOf('@') + 1);
        if (name.indexOf('(') != -1 || name.indexOf(')') != -1 || name.indexOf('<') != -1 || name.indexOf('>') != -1 || name.indexOf(',') != -1 || name.indexOf(';') != -1 || name.indexOf(':') != -1 || name.indexOf('\\') != -1 || name.indexOf('"') != -1 || name.indexOf('[') != -1 || name.indexOf(']') != -1 || name.indexOf(' ') != -1) return false;
        if (domain.indexOf('(') != -1 || domain.indexOf(')') != -1 || domain.indexOf('<') != -1 || domain.indexOf('>') != -1 || domain.indexOf(',') != -1 || domain.indexOf(';') != -1 || domain.indexOf(':') != -1 || domain.indexOf('\\') != -1 || domain.indexOf('"') != -1 || domain.indexOf('[') != -1 || domain.indexOf(']') != -1 || domain.indexOf(' ') != -1) return false;
        return true;
    }

    проверка email на валидность по индусски

    avm, 15 Марта 2010

    Комментарии (17)
  10. Pascal / Говнокод #2793

    +94.2

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    procedure TNamePlay.OKBtnClick(Sender: TObject);
    var
     reg:treginifile;
     a,s,d,f,g,h,j,k,l,z,x:integer;
    begin
    if setp.CheckBox1.Checked =true then
    playsound('Music\xxx.WAV',0,snd_async);
    
     if vopros.Easy.Checked=false then
      och.Caption:=inttostr(strtoint(och.caption)+50);
     with gamers do begin
       Reg := TReginifile.Create;
       Reg.RootKey := HKEY_LOCAL_MACHINE;
       with reg do begin
        o1.caption:=readstring('Software\xxx\Gamers\Result','First','');
        o2.caption:=readstring('Software\xxx\Gamers\Result','Two','');
        o3.caption:=readstring('Software\xxx\Gamers\Result','Three','');
        o4.caption:=readstring('Software\xxx\Gamers\Result','Four','');
        o5.caption:=readstring('Software\xxx\Gamers\Result','Five','');
        o6.caption:=readstring('Software\xxx\Gamers\Result','Six','');
        o7.caption:=readstring('Software\xxx\Gamers\Result','Seven','');
        o8.caption:=readstring('Software\xxx\Gamers\Result','Eight','');
        o9.caption:=readstring('Software\xxx\Gamers\Result','Nine','');
        o10.caption:=readstring('Software\xxx\Gamers\Result','Ten','');
        g1.caption:=readstring('Software\xxx\Gamers','First','');
        g2.caption:=readstring('Software\xxx\Gamers','Two','');
        g3.caption:=readstring('Software\xxx\Gamers','Three','');
        g4.caption:=readstring('Software\xxx\Gamers','Four','');
        g5.caption:=readstring('Software\xxx\Gamers','Five','');
        g6.caption:=readstring('Software\xxx\Gamers','Six','');
        g7.caption:=readstring('Software\xxx\Gamers','Seven','');
        g8.caption:=readstring('Software\xxx\Gamers','Eight','');
        g9.caption:=readstring('Software\xxx\Gamers','Nine','');
        g10.caption:=readstring('Software\xxx\Gamers','Ten','');
       end;
     end;
     if password.Text='' then
      raise erangeerror.Create('Вы не ввели имени')
     else begin
      with gamers do begin
       a:=strtoint(o1.caption);
       s:=strtoint(o2.caption);
       d:=strtoint(o3.caption);
       f:=strtoint(o4.caption);
       g:=strtoint(o5.caption);
       h:=strtoint(o6.caption);
       j:=strtoint(o7.caption);
       k:=strtoint(o8.caption);
       l:=strtoint(o9.caption);
       z:=strtoint(o10.caption);
       x:=strtoint(nameplay.och.caption);
       if x>a then begin
        g10.Caption:=g9.Caption;
        o10.Caption:=o9.caption;
        g9.Caption:=g8.Caption;
        o9.Caption:=o8.caption;
        g8.Caption:=g7.Caption;
        o8.Caption:=o7.caption;
        g7.Caption:=g6.Caption;
        o7.Caption:=o6.caption;
        g6.Caption:=g5.Caption;
        o6.Caption:=o5.caption;
        g5.Caption:=g4.Caption;
        o5.Caption:=o4.caption;
        g4.Caption:=g3.Caption;
        o4.Caption:=o3.caption;
        g3.Caption:=g2.Caption;
        o3.Caption:=o2.caption;
        g2.Caption:=g1.Caption;
        o2.Caption:=o1.caption;
        g1.Caption:=nameplay.Password.Text;
        o1.Caption:=nameplay.och.Caption;
       end else if x=a then begin
        g1.Caption:=nameplay.Password.Text;
        o1.Caption:=nameplay.och.Caption;
       end else if x<a then begin
        if x>s then begin
         g10.Caption:=g9.Caption;
         o10.Caption:=o9.caption;
         g9.Caption:=g8.Caption;
         o9.Caption:=o8.caption;
         g8.Caption:=g7.Caption;
         o8.Caption:=o7.caption;
         g7.Caption:=g6.Caption;
         o7.Caption:=o6.caption;
         g6.Caption:=g5.Caption;
         o6.Caption:=o5.caption;
         g5.Caption:=g4.Caption;
         o5.Caption:=o4.caption;
         g4.Caption:=g3.Caption;
         o4.Caption:=o3.caption;
         g3.Caption:=g2.Caption;
         o3.Caption:=o2.caption;
         g2.Caption:=nameplay.Password.Text;
         o2.Caption:=nameplay.och.Caption;
        end else if x=s then begin
         g2.Caption:=nameplay.Password.Text;
         o2.Caption:=nameplay.och.Caption;
        end else if x<s then begin
    ...

    Ололо, феерический говнокод! LOL

    ancestor, 15 Марта 2010

    Комментарии (17)
  11. Си / Говнокод #2770

    +138.9

    1. 1
    2. 2
    3. 3
    4. 4
    res =  Wlxtbl.WlxLoggedOutSAS(pWlxContext,dwSasType,pAuthenticationId,pLogonSid,pdwOptions,phToken,pNprNotifyInfo,pProfile);
    switch(res) {
    	case WLX_SAS_ACTION_LOGON:
    		if(res == WLX_SAS_ACTION_LOGON) {

    Пишу свою gina.dll, только что заметил вот это...

    zitzy, 12 Марта 2010

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