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

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

    −121

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    CASE st.testmode_order_active
    WHEN NULL THEN '1'
    WHEN '1' THEN '0'
    WHEN '0' THEN '1'
    as testmode_product_active

    кусок sql запроса с реального проекта. логика в БД одна, в приложении - обратная.

    codename, 10 Февраля 2012

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

    +167

    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
    <p class="last_pay">
                            <?if($arResult["history"]["PROPERTIES"]["payment10_date"]["VALUE"]):?>
                                 <?=$arResult["history"]["PROPERTIES"]["payment10_date"]["VALUE"]?> Произведен платеж на ... бла бла
                            <?else:?>
                                <?if($arResult["history"]["PROPERTIES"]["payment9_date"]["VALUE"]):?>
                                     <?=$arResult["history"]["PROPERTIES"]["payment9_date"]["VALUE"]?> Произведен платеж на сумму ... 
                                <?else:?>
                                    <?if($arResult["history"]["PROPERTIES"]["payment8_date"]["VALUE"]):?>
                                         <?=$arResult["history"]["PROPERTIES"]["payment8_date"]["VALUE"]?> Произведен платеж на сумму ... 
                                    <?else:?>
                                        <?if($arResult["history"]["PROPERTIES"]["payment7_date"]["VALUE"]):?>
                                             <?=$arResult["history"]["PROPERTIES"]["payment7_date"]["VALUE"]?> Произведен платеж на сумму  ... 
                                        <?else:?>
                                            <?if($arResult["history"]["PROPERTIES"]["payment6_date"]["VALUE"]):?>
                                                 <?=$arResult["history"]["PROPERTIES"]["payment6_date"]["VALUE"]?> Произведен платеж на сумму  ...
                                            <?else:?>
                                                <?if($arResult["history"]["PROPERTIES"]["payment5_date"]["VALUE"]):?>
                                                     <?=$arResult["history"]["PROPERTIES"]["payment5_date"]["VALUE"]?> Произведен платеж на сумму  ...
                                                <?else:?>
                                                    <?if($arResult["history"]["PROPERTIES"]["payment4_date"]["VALUE"]):?>
                                                         <?=$arResult["history"]["PROPERTIES"]["payment4_date"]["VALUE"]?> Произведен платеж на сумму  ... 
                                                    <?else:?>
                                                        <?if($arResult["history"]["PROPERTIES"]["payment3_date"]["VALUE"]):?>
                                                             <?=$arResult["history"]["PROPERTIES"]["payment3_date"]["VALUE"]?> Произведен платеж на сумму  ... 
                                                        <?else:?>
                                                            <?if($arResult["history"]["PROPERTIES"]["payment2_date"]["VALUE"]):?>
                                                                 <?=$arResult["history"]["PROPERTIES"]["payment2_date"]["VALUE"]?> Произведен платеж на сумму  ... 
                                                            <?else:?>
                                                                <?if($arResult["history"]["PROPERTIES"]["payment1_date"]["VALUE"]):?>
                                                                     <?=$arResult["history"]["PROPERTIES"]["payment1_date"]["VALUE"]?> Произведен платеж на сумму  ... 
                                                                <?else:?>
                                                                    Вы пока не производили платежи
                                                                <?endif;?>
                                                            <?endif;?>
                                                        <?endif;?>
                                                    <?endif;?>
                                                <?endif;?>
                                            <?endif;?>
                                        <?endif;?>
                                    <?endif;?>
                                <?endif;?>
                            <?endif;?>
                        <?endif;?>
     
                        </p>

    красиво

    SuperChel, 03 Февраля 2012

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

    +157

    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
    <ul>
        <?
        $AchievmentPoints = $opts->getAchievmentPoints();
        $dost='';
        $stat='';
        ?>
    
                
                
        <? foreach ($achievments as $id => $item): ?>
    <?
    
        
        ?>
         <?$dost.='<li style="width:100%;clear:both;" class="table1"><div class="table">
             <div style="width:35px;float:left;display:table-cell;text-align: right">'.$item->getImg().'
                  </div><div style="float:left;"><div><span class="caption">'.$item->caption.'
                     </span> <span class="small minor" style="font-size:14px;">('.$item->level.')
                         </span></div><div class="minor small" style="width:100%">'.$item->subtext.':
                             <span  class="ach"><span>'.$item->count.'</span><span>/'.$item->nextLevelCount().'
                                 </span></span></div></div></div><div style="height:40px;"></div></li>';?>
        <? endforeach; ?>
    <?
    $stat.='
        <li style="width:100%;clear:both;" class="table1"> 
        <p style="padding-top: -2px;margin-top: 7px;"></p>
        <div class="table">
            <div style="width:35px;float:left;display:table-cell;text-align: right">
                        <img width="16" height="16" src="/images/icons/achive_on.png" alt="o"/>  
                    </div>
            <div style="float:left;">
                <span class="caption">Получено</span>
                <span  class="ach">
                                <span>('.$getAchievmentPoints.')</span>
                            </span>
            </div></div></li>
    <li style="width:100%;clear:both;" class="table1"> <div class="table">
            <div style="width:35px;float:left;display:table-cell;text-align: right">
                        <img width="16" height="16" src="/images/icons/achive_off.png" alt="o"/>  
                    </div>
            <div style="float:left;">
                <span class="caption" >Не получено</span>
                            <span  class="ach">
                                <span>('.(count($achievments) - $AchievmentPoints).')</span>
                            </span>
            </div></div></li>
            <p style="padding-top: -2px;margin-top: 7px;"></p>
            <div class="eventlight" style="height:2px;width:100%;"></div>
    ';
    echo $stat.$dost;
    ?>
    <li style="width:100%;clear:both;" class="table1"> <div class="table">
            <div style="width:35px;float:left;display:table-cell;text-align: right">
                        <img width="16" height="16" src="/images/icons/achive_off.png" alt="o"/>  
                    </div>
            <div style="float:left;">
                <span class="caption" >Всего достижений:</span>
                            <span  class="ach">
                                <span>(<?= $AchievmentPoints;?>)</span>
                            </span>
            </div></div></li>
     
        </ul>

    Мой первый гомнокод :)

    kolko91, 02 Февраля 2012

    Комментарии (16)
  5. C# / Говнокод #9283

    +121

    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
    class Program
    {
        static bool v1;
        static bool v2;
        static bool v3;
        static bool v4;
        //...
    
        static void Main()
        {
            getValues();
    
            if (v1)
            { }
            else
            {
                //Делаем раз
            }
            if (v2)
            { }
            else
            {
                //Делаем два
            }
            if (v3)
            { }
            else
            {
                //Делаем три
            }
            if (v4)
            { }
            else
            {
                //Делаем три с половиной
            }
        }
    
        static void getValues()
        {
            //Булевым переменным присваиваются значения из БД
        }
    }

    Один из студентов усердно выдавал такие конструкции. Логическое отрицание? Не, не слышал...

    vistefan, 31 Января 2012

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

    +159

    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
    function hash($password='', $unique_id=0)
        {
            $unique_id = $this-> unique_id();// by Lebnik: rand(0, time());
            $itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
            $random_state = $unique_id;
            $random = '';
            $count = 6;
    
            //
            if (($fh = @fopen('/dev/urandom', 'rb')))
            {
                $random = fread($fh, $count);
                fclose($fh);
            }
    
            if (strlen($random) < $count)
            {
                $random = '';
    
                for ($i = 0; $i < $count; $i += 16)
                {
                    $random_state = md5($unique_id . $random_state);
                    $random .= pack('H*', md5($random_state));
                }
                $random = substr($random, 0, $count);
            }
    
            $hash = $this-> hash_crypt_private($password, $this-> hash_gensalt_private($random, $itoa64), $itoa64);
    
            if (strlen($hash) == 34)
            {
                return $hash;
            }
    
            return md5($password);
        }

    АД

    Tsukasa-mixer, 31 Января 2012

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

    +154

    1. 1
    http://habrahabr.ru/blogs/web_security/137196/

    Нанотехнологии в действии

    Spider, 28 Января 2012

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

    +166

    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
    95. 95
    96. 96
    if ($id == 1) {
        $source = 'GallerySkins/s/skin_01.png';
        $dest = "MinecraftSkins/$user.png";
    	
    	if(!copy($source, $dest)) {
            echo "Ошибка<br />\n";
        }
    }
    elseif ($id == 2) {
        $source = 'GallerySkins/s/skin_02.png';
        $dest = "MinecraftSkins/$user.png";
    	
    	if(!copy($source, $dest)) {
            echo "Ошибка<br />\n";
        }
    }
    elseif ($id == 3) {
        $source = 'GallerySkins/s/skin_03.png';
        $dest = "MinecraftSkins/$user.png";
    	
    	if(!copy($source, $dest)) {
            echo "Ошибка<br />\n";
        }
    }
    elseif ($id == 4) {
        $source = 'GallerySkins/s/skin_04.png';
        $dest = "MinecraftSkins/$user.png";
    	
    	if(!copy($source, $dest)) {
            echo "Ошибка<br />\n";
        }
    }
    elseif ($id == 5) {
        $source = 'GallerySkins/s/skin_05.png';
        $dest = "MinecraftSkins/$user.png";
    	
    	if(!copy($source, $dest)) {
            echo "Ошибка<br />\n";
        }
    }
    elseif ($id == 6) {
        $source = 'GallerySkins/s/skin_06.png';
        $dest = "MinecraftSkins/$user.png";
    	
    	if(!copy($source, $dest)) {
            echo "Ошибка<br />\n";
        }
    }
    elseif ($id == 7) {
        $source = 'GallerySkins/s/skin_07.png';
        $dest = "MinecraftSkins/$user.png";
    	
    	if(!copy($source, $dest)) {
            echo "Ошибка<br />\n";
        }
    }
    elseif ($id == 8) {
        $source = 'GallerySkins/s/skin_08.png';
        $dest = "MinecraftSkins/$user.png";
    	
    	if(!copy($source, $dest)) {
            echo "Ошибка<br />\n";
        }
    }
    elseif ($id == 9) {
        $source = 'GallerySkins/s/skin_09.png';
        $dest = "MinecraftSkins/$user.png";
    	
    	if(!copy($source, $dest)) {
            echo "Ошибка<br />\n";
        }
    }
    elseif ($id == 10) {
        $source = 'GallerySkins/s/skin_10.png';
        $dest = "MinecraftSkins/$user.png";
    	
    	if(!copy($source, $dest)) {
            echo "Ошибка<br />\n";
        }
    }
    elseif ($id == 11) {
        $source = 'GallerySkins/s/skin_11.png';
        $dest = "MinecraftSkins/$user.png";
    	
    	if(!copy($source, $dest)) {
            echo "Ошибка<br />\n";
        }
    }
    elseif ($id == 12) {
        $source = 'GallerySkins/s/skin_12.png';
        $dest = "MinecraftSkins/$user.png";
    	
    	if(!copy($source, $dest)) {
            echo "Ошибка<br />\n";
        }
    }

    Разгребал систему скинов и наткнулся на это... даже не знаю, как это чудо назвать.
    Заменяется элементарным
    $source = 'GallerySkins/s/skin_'.$id.'.png'; // Исходная директория файла
    $dest = "MinecraftSkins/$user.png"; // Конечная директория файла

    if(!copy($source, $dest)) // Если файл не скопирован:
    {
    echo "Ошибка<br />\n";
    }

    FanAs, 28 Января 2012

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

    +158

    1. 1
    2. 2
    3. 3
    4. 4
    if(strlen(trim($row['article']))!=0)
    {
     // Some action
    }

    empty? не, это из будущего.
    Суки! Сколько можно это писать!

    Zerstoren, 26 Января 2012

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

    +150

    1. 1
    2. 2
    3. 3
    http://php.net/include/layout.inc
    http://php.net/include/site.inc
    http://php.net/include/languages.inc

    без комментариев :)

    Beat, 24 Января 2012

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

    +147

    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
    #include <string>
    using namespace std;
    int main();
    void pushvalues(const string&, const string&, string&);
    
    int main {
    	string lol1;
    
    	//OUTPUT
    	
    	if (!(lol1))
    		return 1;
    	string lol2;
    	string *word1, *word2 = new string;
    	
    	for (int i = 0; i != '101'; ++i) {
    		//Насколько я помню pop_back и pop_front возвращает удаленное значение, в противном случае сам допиши
    		word1.push_back(lol1.pop_front); // 123456 <- 7 <- 89 :)
    		if (word1[i-1] == ' ') {
    			word1.pop_back;
    			i = 101;
    		}
    	
    	}
    	for (int i = 0; i != '101'; ++i) {
    		word2.push_back(lol1.pop_front);
    		if (word2[i-1] == ' ') {
    			word2.pop_back;
    			i = 101;
    		}
    
    	}
    	
    		pushvalues(&word1, &word2, &lol2); // (word2 word1) (word3 word4 word5)
    
    	while (lol1) // word1 <-> word3 | while anything in lol1 (1. Recognise word3 2. wrap with word1 3. ??? 4. PROFIT!)
    	{
    		for (int i = 0; i != '101'; ++i) {
    			word2.push_back(lol1.pop_front);
    			if (word2[i-1] == ' ') { // WORD3 RECOGNISED FUCK YEAH ;[
    				word2.pop_back;
    				i = 101;
    			}
    		}
    	
    		pushvalues(&word1, &word2, &lol2);
    	}
    
    	delete word1, word2;
    //OUTPUT
    return 0; }
    
    /*void change(string& word1, string& word2) {
    string temp;
    temp = word1;
    word1 = word2;
    word2 = temp;
    return; }*/
    
    void pushvalues(const string& word1, const string& word2, string& container) {
    	container.push_back(word2);
    	container.push_back(' ');
    	container.push_back(word1);
    return; }

    Кодил ночью в режиме потока сознания :)
    Input и output не запилил тогда, попросили помощи, писал в общих чертах
    Этот код, кстати вылетает с ошибками компиляции.
    Плюсы вообще в последнее время начали страдать, ибо взялся за другой язык и бросил учить плюсы

    ReckO, 12 Января 2012

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