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

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

    +177

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    enum
    {
       QUEST_5727              = 5727,
       QUEST_6566              = 6566,
    };

    chaoswithin, 06 Марта 2011

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

    +160

    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
    <html> 
    <head>
    <title>Калькулятор</title> 
    </head>
    <body>
    <?
    function show()
    {
    global $action, $result, $first, $second;
    ?>
    <FORM method="GET" action="">
    <input type="text" name="first">
    <input type="text" name="second">
    <table>
    <tr>
    <td><input type="submit" name="action" value="sum"></td>
    <td><input type="submit" name="action" value="min"></td>
    <td><input type="submit" name="action" value="mult"></td>
    </tr>
    <tr>
    <td><input type="submit" name="action" value="dev" ;></td>
    <td><input type="submit" name="action" value="stepen";></td>
    <td><input type="submit" name="action" value="procent";></td>
    <td><input type="submit" name="action" value="koren";></td>
    </tr>
    </table>
    </form>
    <?
    }
    function calc() 
    { 
    global $action, $result, $first, $second; 
    switch($action)
    {
    case "sum": $result = $first+$second; 
    break;
    case "min": $result = $first-$second; 
    break;
    case "mult": $result = $first*$second; 
    break;
    case "dev":
    if (!$second) 
    {
    exit("Извините, программа не может выполнить действие: на ноль делить нельзя");
    }
    $result=$first/$second; 
    break;
    case "procent": $result = $first*($second/100); 
    break;
    case "stepen": $result = pow($first, $second); 
    break;
    case "koren": $result = pow($first,0.5); 
    break;
    }
    ?>
    <b> <? echo $result; ?> </b> 
    <?
    }
    if ($action) 
    calc(); 
    else show();
    ?>
    </body> 
    </html>

    qbasic, 04 Марта 2011

    Комментарии (10)
  4. JavaScript / Говнокод #5815

    +145

    1. 1
    <noscript><meta http-equiv="refresh" content="0; URL=/badbrowser.php"></noscript>

    Паша Дура запретил отрубать его говноскрипты, теперь все должны смотреть на контакт, засранный скриптами.

    TarasB, 27 Февраля 2011

    Комментарии (10)
  5. JavaScript / Говнокод #5785

    +169

    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
    <script type="text/javascript"> 
    opt_text13=new Array("Internet","Hardware","Mobiles","Soft","Sequrity","Networks","Interface");
    opt_val13=new Array("14","28","44","54","61","67","72");
    opt_val113=new Array("114","115","116","117","118","119","120","121");
    opt_text122=new Array("Essays","Scintific Publications","Online Lessons & Tests","Scintific Libraries","Other");
    opt_val122=new Array("123","124","125","126","127");
    opt_text128=new Array("Your Appartment","Cookery","All for Holidays","Family","Pats","Health","Fashion and Beauty","Purchases");
    opt_val128=new Array("129","138","146","155","162","170","179","189");
    opt_text129=new Array("Country Cottage","Repair","Construction","Interior Design","Landscape Design","Building Materials","Sanitary","Other");
    opt_val129=new Array("130","131","132","133","134","135","136","137");
    opt_text138=new Array("Recepies","Diet","Products","Tabacco","Bavarage","Delivery","Other");
    opt_val138=new Array("139","140","141","142","143","144","145");
    opt_text146=new Array("E-Cards","Tostes and scenaries","Gifts","Flowers Delivery","Holiday Organization","Fireworks","Holidays","Other");
    opt_val146=new Array("147","148","149","150","151","152","153","154");
    opt_text155=new Array("For Parents","For Children","Relation's Psyhology","Marrage","Marrage Agancies","Other");
    //...............
    opt_val252=new Array("253","254","255","256","257","258");opt_text259=new Array("Astrology","Fortune-telling","Esotericism","UFO","Other");
    opt_val259=new Array("260","261","262","263","264");
    opt_text268=new Array("Places","Tourism","Vocation","Hobbies");
    opt_val268=new Array("269","280","292","297");
    opt_text269=new Array("Restaurants & Bars","Clubs & Diskos","Bowling & Billiard","Casinos","Places for children","Circuses","Parks & Zoos","Theaters","Cinemas","Other");
    opt_val269=new Array("270","271","272","273","274","275","276","277","278","279");
    opt_text428=new Array("Newspapers","Magazines","Publishing Houses","Business publications","Computer publications","Motor-Car publications","Sport publications","Entertaining publications","Music/Cinema/TV","Publications for women","Publications for men","Publications for kids","Other publications");opt_val428=new Array("429","430","431","432","433","434","435","436","437","438","439","440","441");opt_text446=new Array("Metallurgy","Mechanical engineering","Equipment","Electronics","Energetics","Chemical industry","Agriculture","Food Industry","Factories","Light Industry","Heavy Industry","Other industries");opt_val446=new Array("447","451","458","469","473","479","483","484","485","486","487","488");opt_text447=new Array("Iron industry","Non-ferrous metallurgy","Other");opt_val447=new Array("448","449","450");opt_text451=new Array("Motor-car Factories","Engeenering Factories","Agricultural Factories","Sheepbuilding","Aircraft building","Other");
    //........
    opt_text529=new Array("Office equipment","Office furneture","Lock boxes","Stationery","Other");opt_val529=new Array("530","531","532","533","534");opt_text536=new Array("Encyclopedias","Transport","Maps","Addresses & Phones","Search people","Dictionaries","Weather","Other");opt_val536=new Array("537","543","552","553","554","555","556","557");opt_text537=new Array("Universal","Medical","Biographical","Subject encyclopedia","Other");opt_val537=new Array("538","539","540","541","542");opt_text543=new Array("Timetables","Air transport","Railway","Sailing","Urban transport","Taxi & Car rent","Bus transport","Other");opt_val543=new Array("544","545","546","547","548","549","550","551");opt_text558=new Array("Other");
    opt_val558=new Array("559");//**************************************************************

    qbasic, 23 Февраля 2011

    Комментарии (10)
  6. Perl / Говнокод #5754

    −123

    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
    sub check_interface
    {
    	my $int_input = shift;
    	my $all_intr_local = [];
    	$_ = qx[ip a];
    	s[\d{1,}:[ ]{1,}([^ ]{1,}):.*]<unshift(@$all_intr_local, $1)>ge;
    	if ( ! grep( { /^$config_params{$int_input}$/ } @$all_intr_local ))
    	{
    		$warning->debug("Error: interface $int_input can't found local!!!");
    		exit 1;         
    	}
    	else
    	{
    		$info->debug("Load param $int_input = $config_params{$int_input}.");   
    	}
    }

    А вот так мы сканируем сетевые интерфейсы...

    SadKo, 21 Февраля 2011

    Комментарии (10)
  7. Си / Говнокод #5722

    +136

    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
    static int getDns(int eid, webs_t wp, int argc, char_t **argv)
    {
            //....тут были еще переменные...
            int type, idx = 0, req = 0;
    
            if (ejArgs(argc, argv, T("%d"), &type) == 1) {
                    if (1 == type)
                            req = 1;
                    else if (2 == type)
                            req = 2;
                    else
                            return websWrite(wp, T(""));
            }
            //...дальше операции с req...
    }

    Такой вот китайский код демона goahead, пользуемого в embedded железяках...

    NiTr0man, 19 Февраля 2011

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

    +116

    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
    public static class ControlManager
        {
            public static UIElement GetControlByName(UIElement control, string name)
            {
                if (EntityType.GetValue(control, "Name").Equals(name))
                    return control;
                if (EntityType.IsProperty(control, "Children"))
                {
                    foreach (var element in (UIElementCollection)EntityType.GetValue(control, "Children"))
                    {
                        if (EntityType.GetValue(element, "Name").Equals(name))
                            return element;
                        var temp = GetControlByName(element, name);
                        if (temp != null)
                            return temp;
                    }
                }
                if (EntityType.IsProperty(control, "Child"))
                {
                    var element = (UIElement)EntityType.GetValue(control, "Child");
                    if (EntityType.GetValue(element, "Name").Equals(name))
                        return element;
                    var temp = GetControlByName(element, name);
                    if (temp != null)
                        return temp;
                }
                if (EntityType.IsProperty(control, "SelectionElement"))
                {
                    var element = (UIElement)EntityType.GetValue(control, "SelectionElement");
                    if (EntityType.GetValue(element, "Name").Equals(name))
                        return element;
                    var temp = GetControlByName(element, name);
                    if (temp != null)
                        return temp;
                }
                return null;
            }
    
            public static UIElement GetControlByType(UIElement control, Type type)
            {
                if (control.GetType() == type)
                    return control; 
                if (EntityType.IsProperty(control, "Children"))
                {
                    foreach (var element in (UIElementCollection)EntityType.GetValue(control, "Children"))
                    {
                        if (element.GetType() == type)
                            return element;
                        var temp = GetControlByType(element, type);
                        if (temp != null)
                            return temp;
                    }
                }
                if (EntityType.IsProperty(control, "Child"))
                {
                    var element = (UIElement)EntityType.GetValue(control, "Child");
                    if (element.GetType() == type)
                        return element;
                    var temp = GetControlByType(element, type);
                    if (temp != null)
                        return temp;
                }
                if (EntityType.IsProperty(control, "SelectionElement"))
                {
                    var element = (UIElement)EntityType.GetValue(control, "SelectionElement");
                    if (element.GetType() == type)
                        return element;
                    var temp = GetControlByType(element, type);
                    if (temp != null)
                        return temp;
                }
                return null;
            }
        }

    Автор тот же.
    Этот код пошатнул мою психику. А может так и надо. а?
    всё-таки stringly-static programming....

    tubus, 15 Февраля 2011

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

    +165

    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
    <?     
     include_once("connect.php");
          if (isset($_POST['submit']))
          {
          if(empty($_POST['secondname']))
          {
          echo 'Вы не ввели фамилию';
          }
          elseif(empty($_POST['name']))
          {
          echo 'Вы не ввели свое имя';
          }
          elseif(empty($_POST['thirdname']))
          {
          echo 'Вы не указали свое отчество';
          }
          elseif(empty($_POST['birthday']))
          {
          echo 'Вы не указали дату своего рождения';
          }
              elseif(empty($_POST['stepen']))
          {
          echo 'Вы не указали свою ученую степень';
          }
              elseif(empty($_POST['zvanie']))
          {
          echo 'Вы не указали свое ученое звание';
          }
              elseif(empty($_POST['org']))
          {
          echo 'Вы не указали свою организацию';
          }
              elseif(empty($_POST['adress']))
          {
          echo 'Вы не указали адрес организации';
          }
              elseif(empty($_POST['dolgnost']))
          {
          echo 'Вы не указали свою должность';
          }
              elseif(empty($_POST['doklad']))
          {
          echo 'Вы не указали название доклада';
          }
              elseif(empty($_POST['vid']))
          {
          echo 'Вы не указали вид доклада';
          }
              elseif(empty($_POST['rukovod']))
          {
          echo 'Вы не указали своего руководителя';
          }
              elseif(empty($_POST['mail']))
          {
          echo 'Вы не указали свою электронную почту';
          }
              elseif(empty($_POST['phone']))
          {
          echo 'Вы не указали свой телефон';
          }
          else
          {
          $secondname = $_POST['secondname'];
          $name = $_POST['name'];
          $thirdname = $_POST['thirdname'];
              $birthday = $_POST['birthday'];
              $stepen = $_POST['stepen'];
              $zvanie = $_POST['zvanie'];
              $org = $_POST['org'];
              $adress = $_POST['adress'];
              $dolgnost = $_POST['dolgnost'];
              $doklad = $_POST['doklad'];
              $vid = $_POST['vid'];
              $mail = $_POST['mail'];
              $phone = $_POST['phone'];
          $query = "SELECT `id`
          FROM `Registration`
          WHERE `secondname`='{$secondname}' AND `name`='{$name}' AND `thirdname`='{$thirdname}'
          ";
          $sql = mysql_query($query) or die(mysql_error());
          if (mysql_num_rows($sql) > 0)
          {
          echo 'Такой участник уже существует';
          }
           else
          {
          $query = "INSERT INTO Registration(secondname ,name ,thirdname, birthday, stepen, zvanie, org, adress, dolgnost, doklad, vid, mail, phone)
          VALUES ('$secondname', '$name', '$thirdname', '$birthday', '$stepen', '$zvanie', '$org', '$adress', '$dolgnost', '$doklad', '$vid', '$mail', '$phone',)";
          $result = mysql_query($query) or die(mysql_error());;
          echo 'Регистрация успешно прошла';
          }
          }
          }
          ?>

    qbasic, 13 Февраля 2011

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

    +165

    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
    if (seismicDriver()->has3DSeismic() && !seismicDriver()->has2DSeismic() ) {
        enableSeismicTab(0, true);
        enableSeismicTab(1, false);
      }
      else if (!seismicDriver()->has3DSeismic() && seismicDriver()->has2DSeismic() ) {
        enableSeismicTab(0, false);
        enableSeismicTab(1, true);
      }
      else if (seismicDriver()->has3DSeismic() && seismicDriver()->has2DSeismic() ) {
        enableSeismicTab(0, true);
        enableSeismicTab(1, true);
      }
      else if (!seismicDriver()->has3DSeismic() && !seismicDriver()->has2DSeismic() ) {
        enableSeismicTab(0, false);
        enableSeismicTab(1, false);
      }

    Этим своим первым постом предворяю серию говнокода, который пишет мой коллега, китаец, имеющий PhD по физике.

    В этом сниппете советую обратить внимание на два компонента в условиях if и на расстановку true и false в соответствии с ними.

    kitaec, 08 Февраля 2011

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

    +161

    1. 1
    throw &std::exception();

    Из того же проекта, что и http://www.govnokod.ru/5581 .
    Естественно это потом иногда удаляется по delete...

    Говногость, 08 Февраля 2011

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