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

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

    +136

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    enum Bool
    {
        True,
        False,
        FileNotFound
    };

    Как оказывается Boolean может быть не только long, но и FileNotFound.

    Нашел зде©ь http://thedailywtf.com/Articles/What_Is_Truth_0x3f_.aspx

    HyperGeek, 19 Мая 2010

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

    +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
    function key_exists_check($key,$ar)
    {
            if (empty($key))
                    $key = '0.001';
    
            strval($key);
    
            if (array_key_exists($key,$ar))
                    while (array_key_exists($key,$ar))
                            $key=strval(floatval($key)+0.001);
    
            return strval($key);
    }

    Другого решения не вижу - задача при добавлении в массив - делать уникальные ключи, которые типа float.

    atarix12, 12 Мая 2010

    Комментарии (23)
  4. Куча / Говнокод #3121

    +144

    1. 1
    2. 2
    3. 3
    if if = then then
        then = else;
    else else = if;

    Следующий фрагмент вполне допустим при программировании на PL/1, но написать такое может только идиот со справкой. "Совершенный код" (c)

    freakru, 27 Апреля 2010

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

    +141

    1. 1
    #define ass assert (false)

    ...

    XAKEP, 22 Апреля 2010

    Комментарии (23)
  6. SQL / Говнокод #3032

    −131.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
    SELECT ct.com_id, cdt.com_name, ct.tax_id, pt.tax_name, tt.date  FROM com_table AS ct LEFT OUTER 
    JOIN com_des_table AS cdt ON cdt.id = ct.com_id LEFT OUTER JOIN payments_table AS pt ON pt.id = 
    ct.tax_id LEFT OUTER JOIN tax_table AS tt ON tt.tax_id = ct.tax_id WHERE ct.tax_id LIKE '001%' and 
    ct.com_id = '1' UNION SELECT ct.com_id, cdt.com_name, ct.tax_id, rt.tax_name, tt.date  FROM com_table 
    AS ct LEFT OUTER JOIN com_des_table AS cdt ON cdt.id = ct.com_id LEFT OUTER JOIN reports_table AS 
    rt ON rt.id = ct.tax_id LEFT OUTER JOIN tax_table AS tt ON tt.tax_id = ct.tax_id WHERE ct.tax_id LIKE 
    '002%' and ct.com_id = '1' UNION SELECT ct.com_id, cdt.com_name, ct.tax_id, pt.tax_name, tt.date  FROM 
    com_table AS ct LEFT OUTER JOIN com_des_table AS cdt ON cdt.id = ct.com_id LEFT OUTER JOIN 
    payments_table AS pt ON pt.id = ct.tax_id LEFT OUTER JOIN tax_table AS tt ON tt.tax_id = ct.tax_id 
    WHERE ct.tax_id LIKE '001%' and ct.com_id = '0' UNION SELECT ct.com_id, cdt.com_name, ct.tax_id, 
    rt.tax_name, tt.date  FROM com_table AS ct LEFT OUTER JOIN com_des_table AS cdt ON cdt.id = ct.com_id 
    LEFT OUTER JOIN reports_table AS rt ON rt.id = ct.tax_id LEFT OUTER JOIN tax_table AS tt ON tt.tax_id = 
    ct.tax_id WHERE ct.tax_id LIKE '002%' and ct.com_id = '0' UNION SELECT ct.com_id, cdt.com_name, 
    ct.tax_id, pt.tax_name, tt.date  FROM com_table AS ct LEFT OUTER JOIN com_des_table AS cdt ON cdt.id = 
    ct.com_id LEFT OUTER JOIN payments_table AS pt ON pt.id = ct.tax_id LEFT OUTER JOIN tax_table AS tt 
    ON tt.tax_id = ct.tax_id WHERE ct.tax_id LIKE '001%' and ct.com_id = '2' UNION SELECT ct.com_id, 
    cdt.com_name, ct.tax_id, rt.tax_name, tt.date  FROM com_table AS ct LEFT OUTER JOIN com_des_table AS 
    cdt ON cdt.id = ct.com_id LEFT OUTER JOIN reports_table AS rt ON rt.id = ct.tax_id LEFT OUTER JOIN 
    tax_table AS tt ON tt.tax_id = ct.tax_id WHERE ct.tax_id LIKE '002%' and ct.com_id = '2' UNION SELECT 
    ct.com_id, cdt.com_name, ct.tax_id, pt.tax_name, tt.date  FROM com_table AS ct LEFT OUTER JOIN 
    com_des_table AS cdt ON cdt.id = ct.com_id LEFT OUTER JOIN payments_table AS pt ON pt.id = ct.tax_id 
    LEFT OUTER JOIN tax_table AS tt ON tt.tax_id = ct.tax_id WHERE ct.tax_id LIKE '001%' and ct.com_id = '3' 
    UNION SELECT ct.com_id, cdt.com_name, ct.tax_id, rt.tax_name, tt.date  FROM com_table AS ct LEFT 
    OUTER JOIN com_des_table AS cdt ON cdt.id = ct.com_id LEFT OUTER JOIN reports_table AS rt ON rt.id = 
    ct.tax_id LEFT OUTER JOIN tax_table AS tt ON tt.tax_id = ct.tax_id WHERE ct.tax_id LIKE '002%' and 
    ct.com_id = '3';

    Не помню, что именно. Вырыл в старом логе. К сожалению из-за местных ограничений по длине кода не удалось выложить подобные портянки длинной в 10 тыщ символов.

    Washington, 17 Апреля 2010

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

    +115.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
    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
    class TReadWrapper<TItemType>
        {
    		public static object item(string ItemString)
            {
    			if (typeof(TItemType) == typeof(double))
    				return Convert.ToDouble(ItemString);
                TDbg.Assert(false);
                return null;
            }
        };
    
        class TRead<TItemType>
        {
    		public static TItemType item(StreamReader BinaryStream)
            {
    			string ItemString = BinaryStream.ReadLine();
    			if (ItemString == null)
    				throw new Exception();
    			return (TItemType)TReadWrapper<TItemType>.item(ItemString);
            }
        };
    
    	class TFileToList<TListItem> : List<TListItem>
        {
            public TFileToList(string FileName)
            {
    			if(typeof(TListItem)==typeof(char))
    			{
    				StreamReader file = new StreamReader(FileName, Encoding.Unicode);
    				string FileData = file.ReadToEnd();
    				foreach (char item in FileData)
    					this.Add((TListItem)(object)item);
    				file.Close();
    				return;
    			};
    
    			StreamReader fileSource = new StreamReader(FileName, Encoding.Unicode);
    			try
                {
    				for (;;)
    					this.Add(TRead<TListItem>.item(fileSource));
    			}
    			catch
    			{
    			};
    			fileSource.Close();
            }
        }
    
        class TListToFile<TListItem>
        {
            static public void rewrite(string NameOfDestinationFile, List<TListItem> Source)
            {
    			if(typeof(TListItem)==typeof(char))
    			{
    				StreamWriter file = new StreamWriter(NameOfDestinationFile, false, Encoding.Unicode);
    				foreach (TListItem item in Source)
    					file.Write(item);
    				file.Flush();
    				file.Close();
    				return;
    			};
    
    			StreamWriter fileDestination = new StreamWriter(NameOfDestinationFile, false, Encoding.Unicode);
    			foreach (TListItem item in Source)
    				fileDestination.WriteLine(Convert.ToString(item));
    			fileDestination.Flush();
    			fileDestination.Close();
            }
        }

    Говногость, 11 Апреля 2010

    Комментарии (23)
  8. Pascal / Говнокод #2972

    +110

    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 IsBigLet(Let: String): Boolean;
    var r: bool;
    begin
    r:=false;
    if pos('Й',Let)>0 then r:=true;
    if pos('Ц',Let)>0 then r:=true;
    if pos('У',Let)>0 then r:=true;
    if pos('К',Let)>0 then r:=true;
    if pos('Е',Let)>0 then r:=true;
    if pos('Н',Let)>0 then r:=true;
    if pos('Г',Let)>0 then r:=true;
    if pos('Ш',Let)>0 then r:=true;
    if pos('Щ',Let)>0 then r:=true;
    if pos('З',Let)>0 then r:=true;
    if pos('Х',Let)>0 then r:=true;
    if pos('Ф',Let)>0 then r:=true;
    if pos('Ы',Let)>0 then r:=true;
    if pos('В',Let)>0 then r:=true;
    if pos('А',Let)>0 then r:=true;
    if pos('П',Let)>0 then r:=true;
    if pos('Р',Let)>0 then r:=true;
    if pos('О',Let)>0 then r:=true;
    if pos('Л',Let)>0 then r:=true;
    if pos('Д',Let)>0 then r:=true;
    if pos('Ж',Let)>0 then r:=true;
    if pos('Э',Let)>0 then r:=true;
    if pos('Я',Let)>0 then r:=true;
    if pos('Ч',Let)>0 then r:=true;
    if pos('С',Let)>0 then r:=true;
    if pos('М',Let)>0 then r:=true;
    if pos('И',Let)>0 then r:=true;
    if pos('Т',Let)>0 then r:=true;
    if pos('Б',Let)>0 then r:=true;
    if pos('Ю',Let)>0 then r:=true;
    Result:=r;
    end;

    Немножко индусского кода!

    Temnenkov, 09 Апреля 2010

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

    +186.2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    $AmountOfChairs=0;
    foreach($faculty['Chair'] as $currChair)
    {
        $AmountOfChairs++;
    }
    echo $AmountOfChairs;

    Shiz89, 07 Апреля 2010

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

    +162.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
    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
    <?php 
       function db_connect($host, $user, $pass, $db) {
           global $glink;
           $glink = mysql_connect($host, $user, $pass) or db_give_error(3, '', db_error($glink));
            mysql_select_db($db, $glink) or db_give_error(4, '', db_error($glink));
    		mysql_query("SET CHARSET cp1251",$glink);
           return $glink;
       }
       
       function db_query($sql, $log = 0) {
           global $glink;
           $res = mysql_query($sql, $glink) or db_give_error(5, $sql, db_error($glink));
           return $res;
       }
                
       function db_fetch_row($res) {
           $row = empty($res) ? false : mysql_fetch_row($res);
           return $row;
       }
       
       function db_num_rows($res, $stmt = '') {
           $rows = mysql_num_rows($res); 
           if (null === $rows) db_give_error(6, '', db_error($glink));
           return $rows;
       }
      
       function db_num_fields($res, $stmt = '') {
           $fields = empty($res) ? false : mysql_num_fields($res);
           if (null === $fields) db_give_error(7, '', db_error($glink));
           return $fields;
       }
        
       function db_field_name($res, $fld) {
           $name = (empty($res) or !isset($fld)) ? false : mysql_field_name($res, $fld);
           if (false === $name) db_give_error(8, '', db_error($glink));
           return $name;
       }
       
       function db_affected_rows($res) {
           global $glink;
           $rows = mysql_affected_rows($glink); 
           if (null === $rows) db_give_error(9, '', db_error($glink));
           return $rows;
       }
    
       function db_insert_id($id = 0) {
           $id = mysql_insert_id();
           return ($id) ? $id : 1;
       }
       
       function db_next_id($table, $field, $seqname = 'seq') {
           return 0;
       }
       
       function db_errno($res) {
           return mysql_errno($res);
       }
       
       function db_error($res) {
           return mysql_error();
       }
       
       function db_free_result($res) {
           $res = mysql_free_result($res);
           return $res;
       }
    ?>

    Все из того же проекта (http://govnokod.ru/2929). авторам видимо надоело писать mysql_ и они решили сделать свой аналог db_. При чем смысла от этого полный NULL. Говнокод, он и в Африке говнокод

    MoLe-X, 05 Апреля 2010

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

    +163.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
    if($id>542)
           {        
             echo '<img Name="altimg" src="'.$foto.'" border=0>';
           }
           else
           {
           	 $size = getimagesize ($foto);
            if($size['0']>=500 ? $w=500:$w=$size['0']);
            if($size['1']>=500 ? $h=500:$h=$size['1']);
            
            echo '<img Name="altimg" src="'.$foto.'" width="'.$w.'" height="'.$h.'" border=0>';
           }

    вот что значит запускать бета верси говноскрипта в действие. Не продумав изначально что не плохо бы изменять размеры изображения при заливке пришлось вот так говнокодить.

    GoodTalkBot, 26 Марта 2010

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