1. PHP / Говнокод #9111

    +147

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    if($row['status_id'] != 6){
        if($row['assist_type'] == 0){
            $row['assist_type'] == 3;
        }
        ...
    }

    :-|

    temka, 13 Января 2012

    Комментарии (15)
  2. C# / Говнокод #9110

    +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
    public partial class ProductForm : Form
        {
            private delegate bool ProductManipulation();
    
            private static ProductManipulation pmd;
    
            public ProductForm()
            {
                InitializeComponent();
                this.FormClosing += this.ProductForm_Closing;
                ProductsLB.DoubleClick += this.ChangeBtn_Click;
                ProductsLB.Click += this.LoadProductKey;
    
                pmd = LoadDataToLB;
                pmd();
            }
    
    ...
    
            private void AddBtn_Click(object sender, EventArgs e)
            {
                pmd -= LoadDataToLB;
                pmd += AddProduct + pmd;
                pmd += LoadDataToLB;
                pmd(); 
                pmd -= AddProduct;
            }
    
    ...

    Обильное делегирование

    Ekstrem, 13 Января 2012

    Комментарии (1)
  3. Куча / Говнокод #9109

    +142

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    CREATE TABLE `users` (
    
    нормальные поля типо имя
    
      `ff` text NOT NULL,
      `da` char(100) NOT NULL,

    Дали мне дампик таблицы... В полях ДА! вот это...
    00A00A00000A0A0AA793655265A00AA000000A00 00A000A72540000AA0A00560A000000A9A990000 0000AAA00000104A004010A00A000A0A0A0AA599 135A00A000A0A0000A00000000A4A450000A0AAA 010AAAA000AA9A0000AAAAA0AAA0A000104AA04A AAA000A0000A00000000AAA000A0A00000000A00 0070000AA00A0000000000A0000000A00000A080 900A0000000A00A00000AAA0000A000A00000000 A00000A0A000000000000070000A00000A000000 00A00000000000A000001A1A0000000000000000 0A00000A00000000A00000000A0A0A000A000A00 0000000000000A00AAAA00AAA000A0A00A0000A0 00AAAAA0A0AA0A00A000','01000000000100000 000000001B261000000000000000000000000000 0000000000000000000000000000000000000000 000

    kyzi007, 13 Января 2012

    Комментарии (15)
  4. Ruby / Говнокод #9108

    −106

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    def simpleEncrDecr( alphabet, alphabetKey, encrDecrWord, triger) #простой метод одну букву из алфавита заменяет другой
      alphabet = alphabet.chars.to_a
      alphabetKey = alphabetKey.chars.to_a
      encrDecrWord = encrDecrWord.chars.to_a
      if triger == 'encryption' then
        for i in 0..encrDecrWord.length-1
           encrDecrWord[i] = alphabetKey[alphabet.rindex(encrDecrWord[i])]
        end
      elsif triger == 'decryption'
        for i in 0..encrDecrWord.length-1
           encrDecrWord[i] = alphabet[alphabetKey.rindex(encrDecrWord[i])]
        end
      else
        p "You is looser! :-)"
      end
      encrDecrWord.join
    end
    
    def manyAlphEncrDecr( alphabet, alpKey, encrDecrWord, triger)  #для закодування нужное слово которое будет ключом
      alphabet = alphabet.chars.to_a
      encrDecrWord = encrDecrWord.chars.to_a
      if triger == 'encryption' then
        for i in 0..encrDecrWord.length-1
          sum = alphabet.rindex(encrDecrWord[i])+alphabet.rindex(alpKey[i])
          encrDecrWord[i] = alphabet[sum%alphabet.length]
        end
      elsif triger == 'decryption'
        for i in 0..encrDecrWord.length-1
           div = alphabet.rindex(encrDecrWord[i])-alphabet.rindex(alpKey[i])
           encrDecrWord[i] = alphabet[div]
        end
      else
        p "You is looser! :-)"
      end
      encrDecrWord.join
    end
    
    def permutationEncrDecr( permKeyNew, encrDecrWord, triger)  #меняет местами буквы в соответствии с ключом, 1234 <=> 3241
      encrDecrWord = encrDecrWord.chars.to_a
      encrDecrWordNew = Array.new
      if triger == 'encryption' then
        for i in 0..encrDecrWord.length-1
          encrDecrWordNew[i] = encrDecrWord[permKeyNew[i]]
        end
      elsif triger == 'decryption'
        for i in 0..encrDecrWord.length-1
           encrDecrWordNew[permKeyNew[i]] = encrDecrWord[i]
        end
      else
        p "You is looser! :-)"
      end
      encrDecrWordNew.join
    end
    
    def frequencyAnalysis(textForAnalis) #частотный анализ текста (подсчет букв)
      analisHash = Hash.new
      for i in 0..textForAnalis.length-1
        analisHash[textForAnalis[i]] = 0
      end
      for i in 0..textForAnalis.length-1
        analisHash[textForAnalis[i]] += 1
      end
      puts "Frequency Analysis - #{analisHash}"
    end
    
    p "Alphabet - #{alphabet = ('0'..'z').to_a.join}"
    print "Enter words for encryption/decryption:"
    wordForEncryped = gets.chomp
    print "Type method:\n1-simple\n2-many alphabetic\n3-permutation\n"
    method = gets.chomp
    case
      when method == '1' then
        puts "Key for alphabet - #{alphabetKey = alphabet.chars.to_a.shuffle.join}"
        puts "Simple Encryped - #{encrypedWord = simpleEncrDecr( alphabet, alphabetKey, wordForEncryped, 'encryption')}"
        frequencyAnalysis(encrypedWord)
        puts "Simple Decryped - #{simpleEncrDecr( alphabet, alphabetKey, encrypedWord, 'decryption')}"
      when method == '2' then
        print "Enter word for many alphabetical encryption/decryption:"
        wordForManyAlphKey = gets.chomp.chars.to_a
        manyAlphKey = Array.new
        for i in 0..wordForEncryped.length-1
          manyAlphKey[i] = wordForManyAlphKey[i%wordForManyAlphKey.length] 
        end
        puts "Many Alphabetic Encryped - #{encrWordForManyAlph = manyAlphEncrDecr( alphabet, manyAlphKey, wordForEncryped, 'encryption')}"
        frequencyAnalysis(encrWordForManyAlph)
        puts "Many Alphabetic Decryped - #{manyAlphEncrDecr( alphabet, manyAlphKey, encrWordForManyAlph, 'decryption')}"
      when method == '3' then
        print 'Please typed key(f.e. 23451):'
        permKey = gets.chomp.chars.to_a
        lengthForSum = permKey.length
        newPermKey = Array.new
        for i in 0..wordForEncryped.length-1
          lengthForSum += permKey.length if i==lengthForSum
          newPermKey[i] = permKey[i%permKey.length].to_i + lengthForSum - permKey.length-1
        end
        puts "Permutation Encryped - #{encrypedWordForPrem = permutationEncrDecr( newPermKey, wordForEncryped, 'encryption')}"
        frequencyAnalysis(encrypedWordForPrem)
        puts "Permutation Decryped - #{permutationEncrDecr( newPermKey, encrypedWordForPrem, 'decryption')}"
      else p 'Incorect typed'
    end

    Методьі кодирования
    1. простой метод одну букву из алфавита заменяет другой
    2. для закодування нужное слово которое будет ключом
    3. меняет местами буквы в соответствии с ключом, 1234 <=> 3241
    4. частотный анализ текста (подсчет букв)
    у каждого метода кроме 4 есть триггер - выбор в каком режиме метод будет работать (кодирование или декодирование)

    bartezic, 13 Января 2012

    Комментарии (7)
  5. Java / Говнокод #9107

    +65

    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
    for (...) {
      Comparator<Date> date_comparator = new Comparator<Date>() {
        @Override
        public int compare(Date s1, Date s2) {
          long n1 = s1.getTime();
          long n2 = s2.getTime();
          if (n1 < n2)
            return -1;
          else if (n1 > n2)
            return 1;
          else
            return 0;
        }
      };
      Date beforeSaveDate = (Date) beforeSaveParam.getValue();
      beforeSaveDate.setSeconds(0);
      Date toSaveDate = (Date) toSaveParam.getValue();
      comparedValue = date_comparator.compare(beforeSaveDate, toSaveDate);
    }

    Задача была сравнить две даты, игнорируя при этом секунды.

    LexeY4eg, 13 Января 2012

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

    +167

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    $zfunctv=0;
    if ($zfunctv==1 || $zfunctv==2 || $zfunctv==3 || $zfunctv==4) require_once('function1.php');
    if ($zfunctv==2 || $zfunctv==3) require_once('function2.php');
    if ($zfunctv==3 || $zfunctv==4) require_once('function3.php');
    if ($zfunctv==''){
    	require_once('function1.php');//Для всех окон
    	require_once('function2.php');//Для полноразмерных окон
    	require_once('function3.php');//Для оборудования
    	require_once('admfunct.php');
    }

    Какого хрена? Как это работает?! Код коммерческой системы UserSide v2.48

    Neka, 13 Января 2012

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

    +132

    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
    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <cstdlib>
    #include <time.h>
    char a[150],c[150];
    int main(int argc, char **argv) {	
    	FILE * tmp;
    	while(1) {
    		int b=0,b1=0;
    		bool A=0;
    		tmp=fopen(".tmp.txt","r");
    		fgets(c,150,tmp);
    		fclose(tmp);
    		system("rm .tmp.txt");
    		system("xwininfo -tree -root | grep -i '\\- deadbeef-0.5.1' > .tmp.txt");
    		tmp=fopen(".tmp.txt","r");
    		fgets(a,150,tmp);
    		fclose(tmp);
    		for(int i=16;i<149;i++) {
    
    			c[i-16]=c[i];
    			a[i-16]=a[i];
    			if(a[i-16]=='-')
    				b++;
    			if(c[i-16]=='-')
    				b1++;
    			if(b==2)
    				a[i-16]=0;
    			if(b1==2)
    				c[i-16]=0;
    		}
    		for(int j=0;j<(int)strlen(c);j++) {
    			if (a[j]!=c[j])	A=true;
    		}
    		if (A) {
    			char lamp[]="/usr/bin/purple-remote \"setstatus?status=available&message=";
    			strcat(lamp,a);
    			strcat(lamp,"\"");
    			system(lamp);
    		}
    		sleep(5);
    	}
    	return 0;
    }

    Реализация аналога pidgin-musictracker для deadbeef

    Abbath, 13 Января 2012

    Комментарии (13)
  8. Куча / Говнокод #9104

    +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
    Попался на одном сайте опрос:
    
    Approximately how speedy is your Internet connection?
      
      Pony express
      512kb/s
      1Mb/s
      2Mb/s
      4Mb/s
      10Mb/s
      100Mb/s
      Greased lightning

    Увидев первый пункт в опросе, и учитывая местный культ, решил поделиться :)

    koodeer, 13 Января 2012

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

    +121

    1. 1
    2. 2
    3. 3
    ibox.com.ua/
    
    ibox.com.ua/index.php

    Решил тут найти почитать что можно пополнить через терминал ibox. Там флешка и закрыть ее я не нашел где... ну ради прикола на index.php ринулся.
    На сервере установлен PHP версии 5.1.6, однако для WordPress 3.3.1 требуется хотя бы 5.2.4.
    Ну вот скажите разве такая прибыльная компания не может себе нормальный сайт заказать?

    LmSys, 12 Января 2012

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

    −129

    1. 1
    SELECT COUNT(*)  FROM passwords WHERE program=program AND website=website AND login=login AND password=password

    Okay :(

    TBoolean, 12 Января 2012

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