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

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

    +169.8

    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
    if ( ( $_GET [ "lang" ] ) || ( $_POST [ "lang" ] ) )
     {
      if ( ( $_GET [ "lang" ] == "de" ) || ( $_POST [ "lang" ] == "de" ) ) { include ( "../language/german_setup.php"     ); $lang = "de"; }
      if ( ( $_GET [ "lang" ] == "en" ) || ( $_POST [ "lang" ] == "en" ) ) { include ( "../language/english_setup.php"    ); $lang = "en"; }
      if ( ( $_GET [ "lang" ] == "nl" ) || ( $_POST [ "lang" ] == "nl" ) ) { include ( "../language/dutch_setup.php"      ); $lang = "nl"; }
      if ( ( $_GET [ "lang" ] == "it" ) || ( $_POST [ "lang" ] == "it" ) ) { include ( "../language/italian_setup.php"    ); $lang = "it"; }
      if ( ( $_GET [ "lang" ] == "es" ) || ( $_POST [ "lang" ] == "es" ) ) { include ( "../language/spanish_setup.php"    ); $lang = "es"; }
      if ( ( $_GET [ "lang" ] == "fa" ) || ( $_POST [ "lang" ] == "fa" ) ) { include ( "../language/farsi_setup.php"      ); $lang = "fa"; }
      if ( ( $_GET [ "lang" ] == "dk" ) || ( $_POST [ "lang" ] == "dk" ) ) { include ( "../language/danish_setup.php"     ); $lang = "dk"; }
      if ( ( $_GET [ "lang" ] == "fr" ) || ( $_POST [ "lang" ] == "fr" ) ) { include ( "../language/french_setup.php"     ); $lang = "fr"; }
      if ( ( $_GET [ "lang" ] == "tr" ) || ( $_POST [ "lang" ] == "tr" ) ) { include ( "../language/turkish_setup.php"    ); $lang = "tr"; }
      if ( ( $_GET [ "lang" ] == "hu" ) || ( $_POST [ "lang" ] == "hu" ) ) { include ( "../language/hungarian_setup.php"  ); $lang = "hu"; }
      if ( ( $_GET [ "lang" ] == "pt" ) || ( $_POST [ "lang" ] == "pt" ) ) { include ( "../language/portuguese_setup.php" ); $lang = "pt"; }
      if ( ( $_GET [ "lang" ] == "he" ) || ( $_POST [ "lang" ] == "he" ) ) { include ( "../language/hebrew_setup.php"     ); $lang = "he"; }
     }
    else
     {
      include ( "../language/german_setup.php" );   # include language vars
      $lang = "de";
     }

    Из известного php web stat релиза 2009 в июле.
    В первом попавшимся на глаза скрипте.

    vov4ik, 02 Февраля 2010

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

    +147.7

    1. 1
    http://rmd.atdmt.com/tl/DocumentDotWrite.js

    Оригинал http://thedailywtf.com/Articles/Amazingly-Brilliant-or-Incredibly-Stupid.aspx

    HyperGeek, 02 Февраля 2010

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

    +65.5

    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
    private static String getUTF8String(byte[] b, int off, int len) {
    	// First, count the number of characters in the sequence
    	int count = 0;
    	int max = off + len;
    	int i = off;
    	while (i < max) {
    	    int c = b[i++] & 0xff;
    	    switch (c >> 4) {
    	    case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7:
    		// 0xxxxxxx
    		count++;
    		break;
    	    case 12: case 13:
    		// 110xxxxx 10xxxxxx
    		if ((int)(b[i++] & 0xc0) != 0x80) {
    		    throw new IllegalArgumentException();
    		}
    		count++;
    		break;
    	    case 14:
    		// 1110xxxx 10xxxxxx 10xxxxxx
    		if (((int)(b[i++] & 0xc0) != 0x80) ||
    		    ((int)(b[i++] & 0xc0) != 0x80)) {
    		    throw new IllegalArgumentException();
    		}
    		count++;
    		break;
    	    default:
    		// 10xxxxxx, 1111xxxx
    		throw new IllegalArgumentException();
    	    }
    	}
    	if (i != max) {
    	    throw new IllegalArgumentException();
    ....

    В либе работы с зипом

    Cdf-EaSy, 01 Февраля 2010

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

    +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
    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
    node_t* read_record(FILE *file) {
        int success = 0;
        node_t *record = 0;
        do {
            int nsz, dsz;
            record = (node_t*)malloc(sizeof(node_t));
            if (!record) {
                break;
            }
            record->data = 0;
            record->next = 0;
    
            if (fread(&nsz, sizeof(int), 1, file) != 1 || feof(file)) {
                break;
            }
    
            if (fread(record->name, 1, nsz, file) != nsz || feof(file)) {
                break;
            }
    
            /* ... */
    
            record->nsz = nsz;
            record->dsz = dsz;
            success = 1;
        } while (0);
    
        if (record && !success) {
            free_list(record);
            record = 0;
        }
    
        return record;
    }
    
    
    void write_record(FILE *file, node_t *record) {
        int dsz = record->dsz;
        int nsz = record->nsz;
    
        if ((fwrite(&nsz, sizeof(int), 1, file) != 1) ||
            (fwrite(record->name, 1, nsz, file) != nsz) ||
            (fwrite(&csz, sizeof(int), 1, file) != 1) ||
            (fwrite(record->data, 1, dsz, file) != dsz) ||
            ferror(file)) {
            fputs("Error: write_record", stderr);
        }
    }

    govnopetya, 26 Января 2010

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

    +162.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
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    $cities_id=array(1,2,3,4,5,6);
     $cities_name=array("MSK","SPB","NN","KZ","NOV","UFA");
     
     GHTML::Run(array("html_autoinsert_on"=>0,"html_method"=>"_POST"));
    
     print GHTML::Link("/test.php",null,GHTML::Link("/test.php","style='font-weight:bold;font-size:20px;'")->Html("[Главная]"))->Html("[Главная]");
     print " ";
     print GHTML::Link("/test.php?act=reg",null,GHTML::Link("/test.php?act=reg","style='font-weight:bold;font-size:20px;'")->Html("[Регистрация]"))->Html("[Регистрация]");
      
      
     print GHTML::Form("POST","")
     ->HTML(
         GHTML::Input("name","text","Имя пользователя",null,true)->Html(),
         "<br>",
         GHTML::Input("pass1","password","Пароль")->Html(),
    	 "<br>",
         GHTML::Input("pass2","password","Пароль ещё раз")->Html(),
    	 "<br>",
         GHTML::Select("city")->Html(
               GHTML::Option("")->Html("Выберите город"),
               GHTML::Option($cities_id,$_POST['city'])->Html($cities_name)
         ),
    	 "<br>",
    	 GHTML::CheckBoxList("che_cities[]",$cities_id,null,$_POST['che_cities'])->Html($cities_name),
         "<br>",
    	 GHTML::RadioList("r_cities[]",$cities_id,null,$_POST['r_cities'])->Html($cities_name),
    	 "<br>",
         GHTML::Textarea("resume",50,9,null,true)->Html("Ненмого о себе"),
    	 "<br>",	 
    	 GHTML::Input("","submit","Жми!")->Html()
     );
    
    
    //////////////////////////////////////////////////////////////////////////////////////////////////
    //////////////////////////////////////////////////////////////////////////////////////////////////
    //////////////////////////////////////////////////////////////////////////////////////////////////
    
    
    <a href='/test.php'  />[Главная]</a> <a href='/test.php?act=reg' style='font-weight:bold;font-size:20px;' />[Регистрация]</a><form method='POST' action='' /><input type='text' name='name' value='Имя пользователя'  /><br><input type='password' name='pass1' value='Пароль'  /><br><input type='password' name='pass2' value='Пароль ещё раз'  /><br><select name='city'  /><option value=''  />Выберите город</option><option value='6'  />MSK</option><option value='5'  />SPB</option><option value='4'  />NN</option><option value='3'  />KZ</option><option value='2'  />NOV</option><option value='1'  />UFA</option></select><br><input type='checkbox' name='che_cities[]' value='6'  />MSK<br /><input type='checkbox' name='che_cities[]' value='5'  />SPB<br /><input type='checkbox' name='che_cities[]' value='4'  />NN<br /><input type='checkbox' name='che_cities[]' value='3'  />KZ<br /><input type='checkbox' name='che_cities[]' value='2'  />NOV<br /><input type='checkbox' name='che_cities[]' value='1'  />UFA<br /><br><input type='radio' name='r_cities[]' value='6'  />MSK<br /><input type='radio' name='r_cities[]' value='5'  />SPB<br /><input type='radio' name='r_cities[]' value='4'  />NN<br /><input type='radio' name='r_cities[]' value='3'  />KZ<br /><input type='radio' name='r_cities[]' value='2'  />NOV<br /><input type='radio' name='r_cities[]' value='1'  />UFA<br /><br><textarea name='resume' cols='50' rows='9'  />Ненмого о себе</textarea><br><input type='submit' name='' value='Жми!'  /></form>

    хорошо что php гиппертекстовый ;)

    Mitusbka, 24 Января 2010

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

    +138.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
    18. 18
    public static class Test3
            {
                public delegate object MyDelegate(object o);
                public delegate T MyDelegate<T>(T o);
    
                public static void Run()
                {
                    MyDelegate dlgA = (o) => { return o; };
                    
                    MyDelegate<object> dlgB = (i) => { return i; };
    
                    MyDelegate dlg = ChangeType<MyDelegate>(dlgB);
                }
                static T ChangeType<T>(Delegate dlg)
                {
                    return (T)(object)Delegate.CreateDelegate(typeof(T), dlg.Target, dlg.Method);
                }
            }

    Люблю вкусняшку))

    fekrado, 22 Января 2010

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

    −113.6

    1. 1
    2. 2
    3. 3
    4. 4
    sub append {
        my $appendstring = @_[0];
        $returnstring = "$returnstring$appendstring";
    }

    Из плагина к nagios'у, который проверяет состояние интерфейсов на cisco-девайсах. http://svn.opsview.org/opsview/trunk/opsview-core/nagios-plugins/check_snmp_cisco_ifstatus .

    aag, 20 Января 2010

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

    +162

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    <?
    $str = ""; 
    $amp="";
    foreach ($p as $i=>$v)
    {
             $str .= $amp."$i=$v";
             $amp = "&";
    }
    ?>

    xXx_totalwar, 15 Января 2010

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

    +106.6

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    if WordCount>GetWord(i) then else if WordCount>GetWord(i) then
      begin
        // ...
        // ...
      end;

    при каких условиях выполнится код между begin-end?..

    TAX, 26 Декабря 2009

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

    +171.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
    if ( !empty( $page ) )
    {
        if ( $page == "login" )
        {
            $spage = "Login.inc";
        }
        else if ( $page == "rules" )
        {
            $spage = "rules.inc";
        }
        else if ( $page == "help" )
        {
            $spage = "help.inc";
        }
        else if ( $page == "wm" )
        {
            $spage = "wm.inc";
        }
        else if ( $page == "game" 
        {
            $spage = "game.inc";
        }
        else if ( $page == "webmoney" )
        {
            $spage = "webmoney.inc";
        }
        else if ( $page == "egold" )
        {
            $spage = "egold.inc";
        }
        else if ( $page == "cashin" )
        {
            $spage = "cashin.inc";
        }
        else if ( $page == "ballans" )
        {
            $spage = "ballans.inc";
        }
        else if ( $page == "remind" )
        {
            $spage = "remind.inc";
        }
        else if ( $page == "contact" )
        {
            $spage = "contact.inc";
        }
        else if ( $page == "reg" )
        {
            $spage = "reg.inc";
        }

    :(((

    azzz, 25 Декабря 2009

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