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

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

    +156.8

    1. 1
    2. 2
    3. 3
    if (ereg("[0-9]+")) $id = (int)$_GET['id'];
    elseif (ereg("[0-9\.]+"))  $id = (float)$_GET['id'];
    else $id = $_GET['id'];

    Не то, чтоб жуткий говнокод, но как-то глуповато.

    pasha, 06 Апреля 2010

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

    +162.6

    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
    <?php
    
    
    if($_GET['id'] == 10 ){
    
    $location = "/articles/lyustry/lustra-na-kuhne/";
    }elseif($_GET['id'] == 13 and $_GET['id_type'] == 17){
    $location = "/market/interernye_svetilniki/lyustry/";
    }elseif(
    $_GET['id'] == 13 and $_GET['id_type'] == 22 and $_GET['act'] == 'sub_type'){
    $location = "/market/interernye_svetilniki/bolshie_lyustry/";
    }elseif(
    $_GET['id'] == 13 and $_GET['id_type'] == 34 and $_GET['act'] == 'sub_type'){
    $location = "/market/interernye_svetilniki/lyustry/bolee_6_rozhkov/";
    }elseif(
    $_GET['id'] == 13 and $_GET['id_type'] == 2 ){
    $location = "/market/interernye_svetilniki/podvesnye/";
    }elseif(
    $_GET['id'] == 13 and $_GET['id_type'] == 40 and $_GET['act'] == 'sub_type'){
    $location = "/market/interernye_svetilniki/podvesnye/odinochnyj_podves/";
    }elseif(
    $_GET['id'] == 13 and $_GET['id_type'] == 41 and $_GET['act'] == 'sub_type'){
    $location = "/market/interernye_svetilniki/podvesnye/trojnoj_i_bolee/";
    }elseif(
    $_GET['id'] == 13 and $_GET['id_type'] == 5 ){
    $location = "/market/interernye_svetilniki/nastenno-potolochnye/";
    }elseif(
    $_GET['id'] == 13 and $_GET['id_type'] == 35 and $_GET['act'] == 'sub_type'){
    $location = "/market/interernye_svetilniki/potolochnye/";
    }elseif(
    $_GET['id'] == 13 and $_GET['id_type'] == 52 ){
    $location = "/market/interernye_svetilniki/vlagozawitnye/";
    }elseif(
    $_GET['id'] == 13 and $_GET['id_type'] == 51 ){
    $location = "/market/interernye_svetilniki/podsvetka_kartin/";
    }elseif(
    $_GET['id'] == 13 and $_GET['id_type'] == 7 ){
    $location = "/market/interernye_svetilniki/bra/";
    }elseif(
    $_GET['id'] == 13 and $_GET['id_type'] == 37 and $_GET['act'] == 'sub_type'){
    $location = "/market/interernye_svetilniki/bra/odnorozhkovye/";
    }elseif(
    $_GET['id'] == 13 and $_GET['id_type'] == 38 and $_GET['act'] == 'sub_type'){
    $location = "/market/interernye_svetilniki/bra/dvuhrozhkovye/";
    }elseif(
    $_GET['id'] == 13 and $_GET['id_type'] == 39 and $_GET['act'] == 'sub_type'){
    $location = "/market/interernye_svetilniki/bra/treh_i_bolee_rozhkovye/";
    }elseif(
    $_GET['id'] == 13 and $_GET['id_type'] == 1 ){
    $location = "/market/interernye_svetilniki/tochechnye/";
    }elseif(
    $_GET['id'] == 13 and $_GET['id_type'] == 42 and $_GET['act'] == 'sub_type'){
    $location = "/market/interernye_svetilniki/tochechnye/odinochnye/";
    }elseif(
    $_GET['id'] == 13 and $_GET['id_type'] == 43 and $_GET['act'] == 'sub_type'){
    $location = "/market/interernye_svetilniki/tochechnye/dvojnye/";
    }elseif(
    $_GET['id'] == 13 and $_GET['id_type'] == 44 and $_GET['act'] == 'sub_type'){
    $location = "/market/interernye_svetilniki/tochechnye/tri_i_bolee/";
    }
    elseif(
    $_GET['id'] == 13 and $_GET['id_type'] == 8){
    $location = "/market/interernye_svetilniki/nastolnye_lampy/";
    }elseif(
    $_GET['id'] == 13 and $_GET['id_type'] == 46 and $_GET['act'] == 'sub_type'){
    $location = "/market/interernye_svetilniki/nastolnye_lampy/ofisnye/";
    }elseif(
    $_GET['id'] == 13 and $_GET['id_type'] == 47 and $_GET['act'] == 'sub_
    type'){
    $location = "/market/interernye_svetilniki/nastolnye_lampy/prikrovatnye_domashnie_ili_interernye/";
    }elseif(
    $_GET['id'] == 13 and $_GET['id_type'] == 6 ){
    $location = "/market/interernye_svetilniki/torshery/";
    }elseif(
    $_GET['id'] == 13 and $_GET['id_type'] == 9 ){
    $location = "/market/ulichnye_svetilniki/";
    }...
    И так далее..

    Клиент поставил нашу CMS, на старой были ссылки типа /?id=10 и т.д. Сделал ему для примера скрипт редиректа с использованием switch case и вот что я увидел через две недели 0_0 Неприкрытый говнокод.

    VeroLom, 01 Апреля 2010

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

    +170.2

    1. 1
    2. 2
    3. 3
    ...
    <title><?php echo iconv('utf-8', 'windows-1251', 'Какой-то текст'); ?>
    ...

    и такие извращения для каждого куска текста в шаблоне
    вот такой вот оригинальный способ перевести шаблон в utf-8
    подозреваю, что человеку очень мешали BOM, от которых он не мог избавится, других причин не вижу

    develx0, 28 Марта 2010

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

    +144

    1. 1
    2. 2
    3. 3
    4. 4
    if (mysql_num_rows($res)) {while($row = mysql_fetch_assoc($res)) {
       $aSingStat[] = $row;
       }
    }

    толи строчек жалко, толи решил обфусцыровать код для меньшей узнаваемости.
    написал уже б так: if (mysql_num_rows($res)) while($row = mysql_fetch_assoc($res)) $aSingStat[] = $row;
    Тогда б я вообще не парился и дропнул нафиг строчку.

    Андрюха, не пиши больше так!
    Вот пример как надо писать http://www.sergunik.name/?p=178

    Sergunik, 16 Марта 2010

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

    +160

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    # сегодняшнее число
    $date2 = date(
        "d.m.Y",
        mktime(0,   0,  0, date("m")  , date("d"), date("Y"))
        );

    psrustik, 11 Марта 2010

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

    +144.5

    1. 1
    define('MYSQL_PASS', 'пароль');

    нет, ну вот прям так вот и лежит посреди кода :)

    stereojazz, 15 Февраля 2010

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

    +144.9

    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
    public class YobaButton : Button
    {
        public YobaButton ()
        {
            this.Click += (s1, e1) =>
            {
                MessageBox.Show ("Оп хуй.");
     
                this.Click -= (EventHandler)Delegate.CreateDelegate (typeof (EventHandler), this, (MethodInfo)MethodBase.GetCurrentMethod ());
     
                this.Click += (s2, e2) =>
                {
                    MessageBox.Show ("Оп тупой хуй.");
                };
            };
        }
    }

    Yurik, 30 Января 2010

    Комментарии (22)
  9. C++ / Говнокод #2479

    +61.8

    1. 1
    2. 2
    CStringA * str = new CStringA; - создает и пашет на ура
    CStringA * str = (CStringA *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(CStringA)); часов 5 назад так же пахало на ура, помылся в душе и ... бля мистика возвращает неверный указатель

    был мне задан такой вопрос =)

    tz-lom, 24 Января 2010

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

    +92.8

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    name[0].InnerText = Regex.Replace(name[0].InnerText, @"<[^>]+>", string.Empty);
    name[0].InnerText = Regex.Replace(name[0].InnerText, "a*[a-z]*A*[A-Z]*", string.Empty);
    name[0].InnerText = Regex.Replace(name[0].InnerText, ",", string.Empty);
    name[0].InnerText = Regex.Replace(name[0].InnerText, "\\.", string.Empty);
    name[0].InnerText = Regex.Replace(name[0].InnerText, ";", string.Empty);
    name[0].InnerText = Regex.Replace(name[0].InnerText, "&", string.Empty);
    name[0].InnerText = Regex.Replace(name[0].InnerText, "\\?", string.Empty); 
    name[0].InnerText = Regex.Replace(name[0].InnerText, "\n", string.Empty);
    name[0].InnerText = Regex.Replace(name[0].InnerText, " ", string.Empty);

    такие дела. кстати, как улучшить? :)) Нужно, чтобы обрезалось все, кроме чисел (положительных и отрицательных) Я какбе начинающий

    Yurik, 07 Января 2010

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

    +170.7

    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($type=="amulet") {$w=60;$h=20;}
            else if($type=="sergi") {$w=60;$h=20;}
                else if($type=="sword") {$w=60;$h=60;}
                    else if($type=="axe") {$w=60;$h=60;}
                        else if($type=="fail") {$w=60;$h=60;}
                            else if($type=="knife") {$w=60;$h=60;}
                                else if($type=="spear") {$w=60;$h=60;}
                                    else if($type=="armour") {$w=60;$h=80;}
                                        else if($type=="ring1") {$w=20;$h=20;}
                                            else if($type=="ring2") {$w=20;$h=20;}
                                                else if($type=="ring3") {$w=20;$h=20;}
                                                    else if($type=="helmet") {$w=60;$h=60;}
                                                        else if($type=="perchi") {$w=60;$h=40;}
                                                            else if($type=="shield") {$w=60;$h=60;}
                                                                else if($type=="boots") {$w=60;$h=40;}

    про elseif не в курсе

    dicos, 11 Декабря 2009

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