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

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

    +144

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    $_GET = array_merge($_GET, $_POST);
    	if($_GET['kalba']) {
    		$kalba=$_GET['kalba'];
    		if($_GET[admin]) echo "".$connect[1]."_".$connect[2]."_".$connect[3]."";
    	} else $kalba="LT";
    
    		if($_SESSION['kalba']="") {
    			session_start(); 
    			$_SESSION['kalba'] = $kalba;
    		} else $_SESSION['kalba'] = $kalba;

    вот кусок из сайта, как писал в http://govnokod.ru/3511#comment33961
    исходное форматирование сохранено

    продолжение причем еще следует

    зы: "kalba" переводится как "язык"

    Lure Of Chaos, 21 Июня 2010

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

    +137

    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
    /*
    sub iterm(i,ne(2),na(2),x(2),xx(2),d(2),p(2),mp,np,ii,im)
    shared nkp
    fl = 0
    FOR k = 1 TO na(0, i): ma = na(k, i): me = ne(k, i)
    FOR j = 1 TO mp
    x=x(j,ma): d=x(j,me)-x: x=x+p(1,i)*d: x(j,ma)=x: ad=ABS(d)
    IF ad > ABS(p(2, i) * x) AND it<im THEN fl = 1
    NEXT j, k: it=it+1: IF fl = 1 THEN ii = p(nkp, i) - 1 else it=0
     end sub: REM ИТЕР-БЛОК (мод.)
    */
    
     void iterm(int i, int ne[4][7],int na[3][7], float x[3][6],
    float d, float p[3][7], int mp, int np, int ii, int im)
    {extern int nkp; float xx,ad; static int it=0;
    int fl = 0, k, j, ma, me;
    for (k = 1; k<=na[0][ i];++k)
    { ma = na[k][ i]; me = ne[k][ i];
    for( j = 1;j<= mp;++j)
    {xx=x[j][ma]; d=x[j][me]-xx; xx=xx+p[1][i]*d; x[j][ma]=xx; ad=fabs(d);
    if( ad > fabs(p[2][ i] * xx) && it<im) fl = 1;
    }} it=it+1; if( fl == 1)  ii = p[nkp][ i] - 1; else it=0;
    } // ИТЕР-БЛОК (мод.)
    
    /*
    cls
    ? fnpr$;  REM ПОДГОТОВКА ДАННЫХ
    REM ОРГАНИЗУЮЩАЯ ПОДПРОГРАММА
    call op(ne(),na(),x(),s(),pr(),md(),n,mp,np,p(),mk,ki,im)
    ?: ?"Общее число итераций ="ki". Жми пробел.": S$=input$(1)
    */

    как обычно вместо того чтобы написать программу с нуля,был найден код на бейсике и начал безжалостно копипаститься в С
    ну и сам код на бэйсике естественно тоже говно

    tz-lom, 14 Июня 2010

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

    +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
    16. 16
    17. 17
    18. 18
    19. 19
    #include <stdio.h>
    #include <string.h>
    int reg (char str[])
    {
    	int i;
    	int n=strlen(str);
    	for (i=0; i<n; i++)
    	if (str[i]<91) str[i]=str[i]+32;
    	return str[i];
    }
    int main ()
    {
    	char str[100]="OlololOlolOloLolOlooLololOlOllllOOOloLoloOlO";
    	int a=reg(str);
    	int i,n=strlen(str);
    	reg(str);
    	printf("%s",str);
    	return 0;
    }

    Программа собственно переводит в нижний регистр. Но как-то жестко написана. Очень сокрушаюсь, что нас еще не научили strwlr и strupr в институте. Оправдано такое написание или все же лучше пользоваться библиотечными функциями?

    ForEveR, 09 Июня 2010

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

    +159

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    public static function getSizeformat($iNumber){
        $value = "-";
        if($iNumber){
          $iNumber = $iNumber/100000;
          $value = number_format($iNumber, 2, '.', '');
        }
        return $value;
      }

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

    psych, 01 Июня 2010

    Комментарии (23)
  6. 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)
  7. 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)
  8. Куча / Говнокод #3121

    +144

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

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

    freakru, 27 Апреля 2010

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

    +141

    1. 1
    #define ass assert (false)

    ...

    XAKEP, 22 Апреля 2010

    Комментарии (23)
  10. 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)
  11. 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)